Skip to content

Commit

Permalink
Merge pull request #49 from virtualansoftware/parallelExecution
Browse files Browse the repository at this point in the history
Parallel execution
  • Loading branch information
elans3 committed Apr 28, 2021
2 parents f501176 + 62d729d commit 80f52b2
Show file tree
Hide file tree
Showing 20 changed files with 525 additions and 342 deletions.
4 changes: 2 additions & 2 deletions modules/idaithalam/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<artifactId>idaithalam</artifactId>
<packaging>jar</packaging>
<name>idaithalam-platform-testing</name>
<version>1.2.4-SNAPSHOT</version>
<version>1.2.8-SNAPSHOT</version>
<properties>
<cucumblan-api.version>1.1.11-SNAPSHOT</cucumblan-api.version>
<cucumblan-api.version>1.1.13</cucumblan-api.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static boolean invoke(String configMapper) throws InterruptedException {
.getResourceAsStream(configMapper);
ExecutionPlanner executionPlanner = yaml.load(inputStream);
ExecutorService executor = Executors
.newFixedThreadPool(executionPlanner.getApiExecutor().size());
.newFixedThreadPool(executionPlanner.getParallelExecution());
List<Future<Integer>> futures = new ArrayList<>();
executionPlanner.getApiExecutor().stream().forEach(
x -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public class Item {
*/
String skipScenario;

/**
* The Csvson.
*/
String hasCsvson;

/**
* The Csvson.
*/
List<String> csvson;

/**
* The Output file by path.
*/
Expand Down Expand Up @@ -487,6 +497,22 @@ public void setHasInputInline(String hasInputInline) {
}


public List<String> getCsvson() {
return csvson;
}

public void setCsvson(List<String> csvson) {
this.csvson = csvson;
}

public String getHasCsvson() {
return hasCsvson;
}

public void setHasCsvson(String hasCsvson) {
this.hasCsvson = hasCsvson;
}

/**
* Gets std type.
*
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ private static void extractedScenario(JSONObject object, Item item) {

private static void extractedOutput(JSONObject object, Item item, String path)
throws IOException {
if(!object.optString("csvson").trim().isEmpty()) {
item.setHasCsvson(object.optString("csvson"));
item.setCsvson(Arrays.asList(object.optString("csvson").split("\n")));
}
if (object.optString("outputFields") != null
&& !object.optString("outputFields").isEmpty()) {
item.setHasResponseByField(true);
Expand Down Expand Up @@ -394,14 +398,17 @@ private static Object getJSON(String json) {
try {
return new JSONArray(json);
} catch (Exception e) {
if (json.contains("{") && json.contains("}")) {
log.warn( json +" is not a valid JSON!. Correct the JSON file!");
}
return json;
}
}
}

private static String replaceSpecialChar(String request){
String skipChars = IdaithalamConfiguration.getProperty("SPECIAL_SKIP_CHAR");
skipChars = skipChars == null ? "\\|=\\\\\\\\|;" : skipChars;
skipChars = skipChars == null ? "\\|=\\\\\\\\|;\\\\n=\\\\\\\\n;\\\\r=\\\\\\\\r;" : skipChars;
String replacedChar = request;
for(String skipChar : skipChars.split(";") ) {
replacedChar = replacedChar.replaceAll(skipChar.split("=")[0], skipChar.split("=")[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ Feature: {{feature}} - API Contract validation status
And Update api with given input
{{/isPut}}
{{#inputJsonMap}}
| {{{key}}} | {{{value}}} |
| {{{key}}} | {{{value}}} |
{{/inputJsonMap}}
{{/hasInputJsonMap}}
When a user {{action}} {{contentType}} in {{url}} resource on {{resource}}
Then Verify the status code is {{httpStatusCode}}
{{#hasCsvson}}
And Verify api response csvson includes in the response
{{#csvson}}
| {{{.}}} |
{{/csvson}}
{{/hasCsvson}}
{{#stdType}}
{{#outputFile}}
And Verify-standard {{stdType}} all {{{outputFile}}} file {{url}} api includes following in the response
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>idaithalam-project</artifactId>
<packaging>pom</packaging>
<name>idaithalam-project</name>
<version>1.2.4-SNAPSHOT</version>
<version>1.2.8-SNAPSHOT</version>
<url>https://virtualan.io</url>
<scm>
<connection>scm:git:ssh://git@github.com/virtualansoftware/idaithalam.git</connection>
Expand Down Expand Up @@ -75,6 +75,7 @@
</activation>
<modules>
<module>samples/idaithalam-postmancoll-apitesting</module>
<module>samples/idaithalam-massapibatch-testing</module>
<module>samples/idaithalam-excel-apitesting</module>
<module>samples/idaithalam-openapi-contract</module>
</modules>
Expand Down
5 changes: 3 additions & 2 deletions samples/idaithalam-excel-apitesting/api-testing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
<suite name="End-2-End API automation Suite">
<test name="End-2-End API automation Suite">
<classes>
<class name="io.virtualan.test.APITestWithExcelAsRunManager">
<class name="io.virtualan.test.APITestWithExcelAsTestManager">
<methods>
<include name="executeApiTests_1"/>
<include name="executeApiTests_2"/>
<include name="executeApiTests_3"/>
<include name="executeApiTests_4"/>
<include name="executeApiTests_5"/>
<include name="executeApiTests_6"/>
<include name="executeApiTests_7"/>
<include name=" executeApiTests_empty_7"/>
<include name="executeApiTests_multiplesheet_8"/>
</methods>
</class>
</classes>
Expand Down
7 changes: 6 additions & 1 deletion samples/idaithalam-excel-apitesting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.1-SNAPSHOT</version>
<properties>
<slf4j.version>1.7.30</slf4j.version>
<idaithalam.version>1.2.2</idaithalam.version>
<idaithalam.version>1.2.8</idaithalam.version>
<testng.ver>7.4.0</testng.ver>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
Expand Down Expand Up @@ -51,6 +51,11 @@
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class APITestWithExcelAsRunManager {
public class APITestWithExcelAsTestManager {

@BeforeClass
public void testBeforeClass(){
Expand All @@ -32,12 +32,13 @@ public void testAfterClass(){
public void executeApiTests_1(){
int status =0 ;
try {
int testcase =1;
IdaithalamConfiguration.setProperty("SPECIAL_SKIP_CHAR","\\\\r\\\\n=\\\\\\\\r\\\\\\\\n");
int testcase =1;
List<String> list = new ArrayList<>();
//Add the testcaseName that List of testcases to be executed from the excel
//for the test selected execution
//list.add("PetPost");
//list.add("PetGet"); // uncomment and test again see the summary report
list.add("PetPost");
list.add("PetGet"); // uncomment and test again see the summary report
File f = new File(System.getProperty("user.dir") +"/target/"+testcase);
if(!f.exists())
f.mkdir();
Expand Down Expand Up @@ -228,4 +229,76 @@ public void executeApiTests_6() {
}
}

@Test
public void executeApiTests_empty_7() {
int status =0 ;
try {
//IdaithalamConfiguration.setProperty("SPECIAL_SKIP_CHAR","\\\\r\\\\n=\\\\\\\r\\\\\\\\n");
//pass the spreadsheet that you want to pass to the user
IdaithalamConfiguration.setProperty("workflow","Disabled");
List<String> list = new ArrayList<>();
//Add the testcaseName that List of testcases to be executed from the excel
//for the test selected execution
//list.add("PetPost");
//list.add("PetGet"); // uncomment and test again see the summary report
//list.add("PetGet-Test"); // uncomment and test again see the summary report


int testPlanIndex = 7;
File f = new File(System.getProperty("user.dir") +"/target/"+testPlanIndex);
if(!f.exists())
f.mkdir();
ExcelToCollectionGenerator.createCollection(list, "virtualan_collection_pet_empty.xlsx",
System.getProperty("user.dir") +"/target/"+testPlanIndex);
//Generate feature and summary page html report for the selected testcase from the excel
status = IdaithalamExecutor.validateContract("Scriptlet testcase execution version 5", System.getProperty("user.dir") +"/target/"+testPlanIndex);
System.out.println(status);
if(status != 0) {
Assert.assertTrue(false);
}
Assert.assertTrue (true);
}catch (Exception e){
System.out.println(e.getMessage());
Assert.assertTrue(false);
}
}



@Test
public void executeApiTests_multiplesheet_8() {
int status =0 ;
try {
//pass the spreadsheet that you want to pass to the user
IdaithalamConfiguration.setProperty("workflow","Disabled");
List<String> list = new ArrayList<>();
//Add the testcaseName that List of testcases to be executed from the excel
//for the test selected execution
list.add("EDI271_1");
list.add("EDI271");
list.add("PetPost_3");
//list.add("PetGet"); // uncomment and test again see the summary report
//list.add("PetGet-Test"); // uncomment and test again see the summary report


int testPlanIndex = 8;
File f = new File(System.getProperty("user.dir") +"/target/"+testPlanIndex);
if(!f.exists())
f.mkdir();
ExcelToCollectionGenerator.createCollection(list, "virtualan_collection_testcase_8.xlsx",
System.getProperty("user.dir") +"/target/"+testPlanIndex);
//Generate feature and summary page html report for the selected testcase from the excel
status = IdaithalamExecutor.validateContract("Scriptlet testcase execution version 5", System.getProperty("user.dir") +"/target/"+testPlanIndex);
System.out.println(status);
if(status != 0) {
Assert.assertTrue(false);
}
Assert.assertTrue (true);
}catch (Exception e){
System.out.println(e.getMessage());
Assert.assertTrue(false);
}
}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"category": {
"id": 200,
"name": "Bulldog"
"name": "Bulldog \r\n Testing \r\n again"
},
"id": 201,
"name": "",
Expand All @@ -12,7 +12,7 @@
"tags": [
{
"id": 201,
"name": "grey"
"name": "red"
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion samples/idaithalam-massapibatch-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.1-SNAPSHOT</version>
<properties>
<slf4j.version>1.7.30</slf4j.version>
<idaithalam.version>1.2.4-SNAPSHOT</idaithalam.version>
<idaithalam.version>1.2.8-SNAPSHOT</idaithalam.version>
<java.version>1.8</java.version>
<testng.ver>7.4.0</testng.ver>
<maven.compiler.source>${java.version}</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Feature: Sample.yaml - API Contract validation status
Scenario: Load initial set of data
Given Provided all the feature level parameters from file
@sample
Scenario: Create a new sample object. - POST api call
Given a user perform a api action
And Create api with given input
Expand All @@ -10,7 +9,6 @@ Feature: Sample.yaml - API Contract validation status
| version | 0.0.1 |
When a user post application/json in /sample resource on sample
Then Verify the status code is 201
@sample
Scenario: Sample path - GET api call
Given a user perform a api action
And add request with given path params
Expand Down
19 changes: 11 additions & 8 deletions samples/idaithalam-openapi-contract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<name>idaithalam-opeapi-contract</name>
<version>1.0.0-SNAPSHOT</version>
<properties>
<idaithalam.version>1.2.2</idaithalam.version>
<idaithalam.version>1.1.0</idaithalam.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<virtualan.version>1.0.7</virtualan.version>
<hsqldb.version>2.5.1</hsqldb.version>
<spring.boot.version>2.4.4</spring.boot.version>
<hsqldb.version>2.3.2</hsqldb.version>
<spring.boot.version>2.3.0.RELEASE</spring.boot.version>
<springfox.version>2.9.2</springfox.version>
<groovy.version>2.4.7</groovy.version>
<json.version>20190722</json.version>
Expand Down Expand Up @@ -118,11 +118,6 @@
<version>2.12.2</version>
</dependency>

<dependency>
<groupId>io.virtualan</groupId>
<artifactId>idaithalam</artifactId>
<version>${idaithalam.version}</version>
</dependency>

<!-- START Virtual Service API support -->
<dependency>
Expand All @@ -149,6 +144,14 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.virtualan</groupId>
<artifactId>idaithalam</artifactId>
<version>${idaithalam.version}</version>
</dependency>

<!-- START Virtual Service API support -->

<!-- HyperSQL DB -->
<dependency>
<groupId>org.hsqldb</groupId>
Expand Down
Loading

0 comments on commit 80f52b2

Please sign in to comment.