[ieee 2008 international conference on information technology (icit) - bhunaneswar, orissa, india...

5
Regression Testing Techniques for Agent Oriented Software Praveen Ranjan Srivastava 1 , Karthik Anand V 2 , Subba Reddy V 3 , Raghurama G 4 1 Computer Science & Information Systems Group, BITS Pilani 2 Yahoo! Inc, India 3 Stratify Inc, India 4 Electrical Electronics and Instrumentation Group, BITS Pilani [email protected], [email protected], [email protected],[email protected] Abstract- In recent years, agent-based systems have received considerable attention in both academics and industry. The agent-oriented paradigm can be considered as a natural exten- sion of the object-oriented (OO) paradigm. In this paper, a pro- cedure using message flow graph (MFG) for regression testing of agent oriented software systems is proposed. This method however can be used when the interaction pattern of an agent changes. Furthermore a procedure for selection of modifica- tion-traversing regression test cases using execution trace is proposed. For illustration purpose, a multi agent air ticket booking system is implemented using JADE 3.5 and tested using our proposed methods. Key-Words: Agents, Regression testing, Software Testing, JADE, MFG I. INTRODUCTION The software systems now a days need to be adaptive, auto- nomous and dynamic to serve the needs of varied consumers. These systems have evolved very fast in the past few dec- ades. As the technology advanced, we are driven more to- wards abstraction and generalization. Software agents are an abstraction to describe computer programs that act for a user or another program [1]. They can be dedicated to a particular task or, if endowed with enough intelligence can act on be- half of a client [2]. Agents autonomously work in dynamic and uncertain environments [3]. Each agent senses the envi- ronment and acts accordingly. The agent oriented methodol- ogies provide us a platform for making our system abstract, generalize, dynamic and autonomous. In a related, we have discussed the extension of object oriented software testing techniques to agent oriented software systems [4]. This work proposes regression testing techniques for agent oriented software systems. Any software system S evolves with time to S 1 . Accordingly the software has to be tested with respect to the existing and newly added functionality. This type of testing which is known as regression testing, refers to that portion of test suite T in which the system S 1 is tested to ensure that not only does the newly added or modified behaviour of the code be- haves correctly, but also the code carried over unchanged from the previous version S continues to behave correctly. The environment in which the agent resides changes dynami- cally. The construction of the agents should be such that it able to accomplish the desired tasks by collaborating with other agents. Agents collaborate with each other through messages. Any change in the functionality will usually in- volve a change in the interaction pattern among the agents. These high level changes could be identified by drawing Message Flow Graphs (MFG). The MFGs can be used to test S 1 to ensure that the changes made do not affect the functio- nality carried over from S. While this could be achieved by executing S 1 against all the non-obsolete test suites, by using MFG we select only those that are necessary to check if the modification made do not afftect the functionality common to S and S 1 . However the modifications need not be always at the message level. It can be as simple as just modifying one or two statements without affecting the message pattern. These changes cannot be identified by the MFG. To address this, a test selection procedure based on execution trace is proposed. This technique can be split into two phases. In the first phase the agent is executed, the MFG is drawn and the execution trace is recorded for each test case designed for S. In the second phase, the MFG of S 1 is drawn and compared with S and the modification-traversing regression test cases are identified by an analysis of the execution trace and node comparison of the MFG obtained in the first phase. An example of air ticket booking agent system is described in section two. This example is used as a reference and the testing techniques are applied on that. Section three discussion the use of MFG’s in regression testing. Section four discusses the test selection procedure based on execution trace. The paper concludes with a summary of the work and some suggestions for future work. II. AIR TICKET BOOKING AGENT SYSTEM The paper presents the implementation of an agent based air ticket booking system using JADE 3.5 (Java Agent Devel- opment Framework). JADE simplifies the implementation of multi-agent systems through a middle-ware that complies with the FIPA specifications and through a set of graphical tools that supports the debugging and deployment phases [5, 6, 7, 8,]. The agent platform can be distributed across ma- chines (which not even need to share the same OS) and the configuration can be controlled via a remote GUI. The confi- guration can be even changed at run-time by moving agents from one machine to another one, as and when required [2]. International Conference on Information Technology 978-0-7695-3513-5/08 $25.00 © 2008 IEEE DOI 10.1109/ICIT.2008.30 221

Upload: raghurama

Post on 11-Mar-2017

224 views

Category:

Documents


3 download

TRANSCRIPT

Regression Testing Techniques for Agent Oriented Software

Praveen Ranjan Srivastava1, Karthik Anand V 2, Subba Reddy V 3, Raghurama G 4 1 Computer Science & Information Systems Group, BITS Pilani

2Yahoo! Inc, India 3Stratify Inc, India

4Electrical Electronics and Instrumentation Group, BITS Pilani [email protected], [email protected], [email protected],[email protected]

Abstract- In recent years, agent-based systems have received considerable attention in both academics and industry. The agent-oriented paradigm can be considered as a natural exten-sion of the object-oriented (OO) paradigm. In this paper, a pro-cedure using message flow graph (MFG) for regression testing of agent oriented software systems is proposed. This method however can be used when the interaction pattern of an agent changes. Furthermore a procedure for selection of modifica-tion-traversing regression test cases using execution trace is proposed. For illustration purpose, a multi agent air ticket booking system is implemented using JADE 3.5 and tested using our proposed methods. Key-Words: Agents, Regression testing, Software Testing, JADE, MFG

I. INTRODUCTION The software systems now a days need to be adaptive, auto-nomous and dynamic to serve the needs of varied consumers. These systems have evolved very fast in the past few dec-ades. As the technology advanced, we are driven more to-wards abstraction and generalization. Software agents are an abstraction to describe computer programs that act for a user or another program [1]. They can be dedicated to a particular task or, if endowed with enough intelligence can act on be-half of a client [2]. Agents autonomously work in dynamic and uncertain environments [3]. Each agent senses the envi-ronment and acts accordingly. The agent oriented methodol-ogies provide us a platform for making our system abstract, generalize, dynamic and autonomous. In a related, we have discussed the extension of object oriented software testing techniques to agent oriented software systems [4]. This work proposes regression testing techniques for agent oriented software systems.

Any software system S evolves with time to S1. Accordingly the software has to be tested with respect to the existing and newly added functionality. This type of testing which is known as regression testing, refers to that portion of test suite T in which the system S1 is tested to ensure that not only does the newly added or modified behaviour of the code be-haves correctly, but also the code carried over unchanged from the previous version S continues to behave correctly. The environment in which the agent resides changes dynami-cally. The construction of the agents should be such that it able to accomplish the desired tasks by collaborating with

other agents. Agents collaborate with each other through messages. Any change in the functionality will usually in-volve a change in the interaction pattern among the agents. These high level changes could be identified by drawing Message Flow Graphs (MFG). The MFGs can be used to test S1 to ensure that the changes made do not affect the functio-nality carried over from S. While this could be achieved by executing S1 against all the non-obsolete test suites, by using MFG we select only those that are necessary to check if the modification made do not afftect the functionality common to S and S1 .

However the modifications need not be always at the message level. It can be as simple as just modifying one or two statements without affecting the message pattern. These changes cannot be identified by the MFG. To address this, a test selection procedure based on execution trace is proposed. This technique can be split into two phases. In the first phase the agent is executed, the MFG is drawn and the execution trace is recorded for each test case designed for S. In the second phase, the MFG of S1 is drawn and compared with S and the modification-traversing regression test cases are identified by an analysis of the execution trace and node comparison of the MFG obtained in the first phase. An example of air ticket booking agent system is described in section two. This example is used as a reference and the testing techniques are applied on that. Section three discussion the use of MFG’s in regression testing. Section four discusses the test selection procedure based on execution trace. The paper concludes with a summary of the work and some suggestions for future work.

II. AIR TICKET BOOKING AGENT SYSTEM The paper presents the implementation of an agent based air ticket booking system using JADE 3.5 (Java Agent Devel-opment Framework). JADE simplifies the implementation of multi-agent systems through a middle-ware that complies with the FIPA specifications and through a set of graphical tools that supports the debugging and deployment phases [5, 6, 7, 8,]. The agent platform can be distributed across ma-chines (which not even need to share the same OS) and the configuration can be controlled via a remote GUI. The confi-guration can be even changed at run-time by moving agents from one machine to another one, as and when required [2].

International Conference on Information Technology

978-0-7695-3513-5/08 $25.00 © 2008 IEEE

DOI 10.1109/ICIT.2008.30

221

The air ticket booking system is a multi agent system com-prising of buyer and a seller agent. The seller agent registers with the service directory. The buyer agent will read the flight details through the command line and search the cor-responding seller agents who are satisfying the flight re-quirements. The directory service maintains the list of all available sellers. Furthermore, the buyer receives the propos-als from all the seller agents and will select the seller with best price offer. Moreover it confirms the ticket with the sel-ler. The seller agent will respond to the queries made by the buyer agent and updates its state on successful transaction. The buyer agent re-executes its plan if there are no seller agents. The buyer agent is blocked until there is a seller of tickets. The sequence diagram for the buyer and seller agents is shown in the Figure 1.

Figure 1. Sequence diagram for air ticket booking system show-ing the interaction between buyer, seller and search directory Agents

An agent does not have any publicly visible methods which the other agents can call. The communication is achieved by agent communication language. The communication between the agents in JADE is done by sending ACLMessage like CFP (call for purpose), propose, failure, inform etc.

III. REGRESSION TESTING USING MFG A message flow graph (G) is defined as a finite set N of nodes and a finite set E of directed edges. An edge (i, j) in E, with an arrow directed from i to j connects nodes ni and nj in

N. We often write G= (N, E) to denote a message flow graph with nodes in N and edges in E. Start and End are two special nodes in N. Every other node in G is reachable from start and also every node in N has a path terminating at End. Node start has no incoming edge and end has no out going edge. Message flow graph is drawn for each behaviour of an agent. The various types of messages like CFP (call for purpose), propose failure, inform etc, are identified along with the mes-sage parameters. The message forms the node N and the edges E indicate the pattern of flow of messages. A pictorial representation of an MFG is used in the analysis of the beha-viour of the agent. Each message node is represented by a symbol, usually a rectangular box. These boxes are labeled by their corresponding message types. The boxes are con-nected by lines representing edges. Arrows are used to indi-cate the direction of flow. There can be multiple responses to a given message and these are indicated by two edges out of the message nodes. The following diagram shows the MFG for the RequestPerformer behaviour (it requests the seller agents for tickets) of the buyer agent in the case study dis-cussed in section 2.

Start

End

CFP (flight details)

Propose (price)

Accept proposal (flight details)

Inform (success) Inform (failure)

Inform (not available)

1

2 3

4

5 6

Figure 2- Message flow graph of RequestPerformer behaviour of buyer agent A.

The test cases can be designed based on the techniques dis-cussed in [4]. Assume that the designed test case for the buy-er agent A verifies the following message path.

T1: Start – 1 – 3 – End

T2: Start – 1 – 2 – 4 – 5 – End

T3: Start – 1 – 2 – 4 – 6 – End

Let us assume that a new business rule demands that the seller agent has to be selected not only based on price but also based on the time taken to travel which is fed as an input to the agent. This necessitates the inclusion of a secondary parameter called time to travel in the node 2. This change

222

will be indicated in the message flow graph of A1 (shown in Fig 3). For comparing A and A1 we use the following algo-rithm [9].

Step1: We Represent the MFG as an array of nodes wherein a node is a structure containg the numbers of ‘from’ state-ment and ‘to’ statement in the code.

Step2: Input the two MFG’s in two arrays and sort both us-ing any sorting algorithm in increasing order of the ‘from’ nodes of the messages entered.

Step3: Initialize an array result to zero. This array is used to mark those nodes of the old MFG that are also present in the new MFG.

Step4: Mark the common nodes of old and new MFG by marking the corresponding indices of the old MFG as ‘1’ in the result array. i.e. if old[i] = new[j], then result[i] =1

Step5: Print all the elements of the old MFG array for which corresponding result array element is 0.

By comparing A and A1, we can conclude that node 2 has changed. So each previously designed test cases containing node 2 must be selected for regression testing. So among T1, T2 and T3, we neglect T1, while T2 and T3 are selected for regression testing.

Start

End

CFP (flight details)

Propose (price,time to travel)

Accept proposal (flight details)

Inform (success) Inform (failure)

Inform (not available)

1

6

Figure 3- Message flow graph of RequestPerformer behaviour of buyer agent A1.

The above proposed method can be used only if the message pattern changes. This method plays an important role when the time available for regression testing is limited. However if there are internal logic changes which do not get reflected at the message flow level, they cannot be identified using MFG.

IV. EXECUTION TRACE BASED REGRESSION TESTING

The limitation of the technique discussed in section three can be overcome by using regression testing using execution trace. Two phases are involved in this method. Phase one

involves obtaining the execution trace with the help of CFG. The CFG is drawn for each behaviour of the agent. We ex-ecute agent A against each test case in test suite T. During the execution against t belongs to T, the execution trace is recorded as trace (t). The execution trace is a sequence of nodes. We save an execution trace as a set of nodes touched during the execution of P. Such a test is also known as an execution slice of A. Note That this is similar to the method discussed for execution trace by [10]. The second phase deals with selecting regression test cases by capturing the change in the statements at the node level in CFG. The CFG contains nodes representing block of statements. Two nodes are said to be equivalent if they have the same block of statements. The CFG is drawn for the behaviours in A and A1. The corresponding nodes in A and A1 are compared for their equivalence. The node in A which is not equivalent to its corresponding node in A1 is identified as N. The test cas-es previously designed for A and whose exection trace in-volves the node N is selected for regression testing. Consider the following behaviour of the seller agent dis-cussed in section 2. The agent behaviour is responsible for responding to the call for proposal message sent by the buy-er agents. Please refer to Appendix A for the source code.

The CFG of the agent’s behaviour is shown below.

Figure 4- Control flow graph G of OfferRequestsServer behaviour of seller agent A. The following test cases are designed for testing the above behaviour.

T1: Sending a null message. Execution trace: S – 1 – 2 – E

T2: Sending a non-matching proposal. Execution trace: S – 1 – 3 – 4 – 3 – 5 – 6 – 8 – E

T3: Sending a matching proposal. Execution trace: S – 1 – 3 – 4 – 3 – 5 – 7 – 8 – E

In node 7, the ticket price is sent to the buyer. Now the seller wishes to offer discount at 25 % per ticket. The statements in the node 7 will be modified in A1. Node number 7 in the code (Appendix A) changes as follows.

223

reply.setContent (String.valueOf (new Double (costPerTick-et*0.25) .intValue ()));

This modification will not cause any change in the CFG. However the contents of node 7 in A and A1 will be different. This is identified by comparing the block of statements that represents the node 7 in A and A1. Then test cases which have node 7 in their execution trace are selected for regres-sion testing of A1.

Now, suppose the seller decides to provide discount based upon the number of tickets ordered. This results in the change of code as follows.

reply.setPerformative(ACLMessage.PROPOSE);

Switch(requestrequiredticketcount) {

case 1:

reply.setContent (String.valueOf (new Double (costPerTick-et*025) .intValue ())); --- Node 9

break;

Case 2:

reply.setContent (String.valueOf (new Double (costPerTick-et*.35) .intValue ())); --- Node 10

break;

default:

reply.setContent (String.valueOf (new Double (costPerTick-et*0.6). intValue ())); --- Node 11

}

System.out.println ("Seller Agent> Sending ticket propos-al.");

Hence, new nodes will be introduced in the CFG of A corres-ponding to the switch case. The new CFG for A1 is shown below.

Figure 5- Control flow graph G of OfferRequestsServer behaviour of seller agent A1.

As you can see in fig 5, the node 9, 10 and 11 are introduced between 7 and 8. This change in A1 can be identified by finding the first equivalent node reachable from node 7 (i.e. node 8 in this case). Now, select the test cases which have nodes 7 and 8 in the execution trace for the regression test (i.e. t3 in this case).

V. CONCLUSION

In this paper, we have proposed two methods for the selection of test cases for the regression testing of agent based systems. These techniques are applied to a simple dual agent air ticket booking system. The execution trace based method overcomes the limitations of Message Flow Graph method. These techniques can be applied to other simple agent based information systems. However, these techniques have to be studied in detail before applying to complex multi agent systems.

REFERENCES [1] C D. Nguyen, A. Perini, and P. Tonella, “A goal oriented

software testing methodology”, Agent oriented software en-gineering VIII, (book series), LNCS, Springer Berlin, APRIL 2008.

[2] Dam K H, Winikoff M, “Comparing Agent-Oriented Metho-

dologies” In Proc. of 5th International Workshop on Agent Oriented Software Engineering, (2003).LNCS, Springer press.

[3] Yim H, Cho K, Kim J, and Park S: Architecture-Centric Ob-

ject-Oriented Design Method for Multi-Agent Systems” Pro-ceedings Fourth International Conference on MultiAgent Systems, IEEE, ICMAS 2000

[4] Praveen Ranjan Srivastava, et al., Extension of Object-

Oriented Software Testing Techniques to Agent Oriented Software Testing, Journal of Object Technology (JOT), Vol 7, No. 8, Nov-Dec 2008

[5] Zeid A: “A UML Extension for Agent-Oriented Analysis

and design, Department of Computer Science, the American University in Cairo(white paper),SEP 2002

[6] Jan Himmelspach,Mathias Röhl, Adelinde Uhrmacher, “Si-

mulation for testing software agents – An Exploration based on JAMES” Proceedings of the 35th Winter Simulation Con-ference: Driving Innovation, New Orleans, Louisiana, USA, December 7-10, 2003. ACM 2003, ISBN 0-7803-8132-7.

[7] JAva Agent DEvelopment Framework, http://jade.tilab.com [8] Amund Tveit, “A survey of Agent-Oriented Software Engi-

neering”, First NTNU CSGSC, May 2001 [9] Gregg Rothermel, Mary Jean Harrold: A Safe, Efficient Re-

gression Test Selection Technique, ACM Transactions on

9 11 10

8

7

5

224

Software Engineering and Methodology (TOSEM), pp 173-210, Volume 6, Issue 2, April 1997

[10] A P Mathur, “Foundations of Software Testing”, Pearson

Education Press, 2008.

APPENDIX A Node 1

private class OfferRequestsServer extends CyclicBehaviour {

public void action() { MessageTemplate mt =

MessageTemplate.MatchPerformative(ACLMes sage.CFP); ACLMessage msg = myAgent.receive(mt);

if (msg != null) { Node 2

String requestString= msg.getContent(); System.out.println("Seller Agent> Got a ticket request." +

requestString); ACLMessage reply = msg.createReply(); StringTokenizer st=new

StringTokenizer(requestString,";"); long requesttargetDate=0; String requesttargetFromPlace=null; String requesttargetToPlace=null; int requestrequiredticketcount=0; int tokenCount=1;

Node 3 while (st.hasMoreTokens()) {

Node 4 irequesttargetDate=Long.parseLong(st.nextToken()); requesttargetFromPlace=st.nextToken(); requesttargetToPlace=st.nextToken(); requestrequiredticketcount=Integer.parseInt(st.nextToken(

)); tokenCount++; }

Node 5 If((freeSeats>0)&&(requesttargetDate==departureDate)&

& targetFromPlace.equalsIgnoreCase(requesttarget FromPlace)&& requesttargetToPlace.equalsIgnoreCase(targetToPlace)&&freeSeats>= requestrequiredticketcount ) { Node 7

reply.setPerformative(ACLMessage.PROPOSE); reply.setContent(String.valueOf(new

Double(costPerTicket).intValue())); System.out.println("Seller Agent> Sending ticket

proposal.");} Node 6

else{ reply.setPerformative(ACLMessage.REFUSE); reply.setContent("not-available"); System.out.println("Seller Agent> Sending ticket reject."

);}

myAgent.send(reply);} Node 8

else {block();}} }

225