Skip to content

Commit 0b54c66

Browse files
Christoffer-Corteserik-edling
authored andcommitted
Test Execution Subscription Creation (#178)
* Add base * Add Test Execution subscriptions * Fix * Remove empty steps
1 parent 92910a9 commit 0b54c66

File tree

5 files changed

+154
-6
lines changed

5 files changed

+154
-6
lines changed

src/systemtest/java/com/ericsson/ei/systemtest/artifactflow/ArtifactFlowSteps.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class ArtifactFlowSteps extends AbstractTestExecutionListener{
2929

3030
@Given("^configurations are provided$")
3131
public void configurations_are_provided() {
32-
//Temporary for my change(done in another PR)
3332
config.initEIFrontend();
3433
config.initEIBackend();
3534
config.initJenkinsConfig();
@@ -58,7 +57,7 @@ public void a_jenkins_job_from_is_created(String jenkinsJobName, String scriptFi
5857

5958
@Then("^we continue with the next step$")
6059
public void we_continue_with_the_next_step() {
61-
//Just for cucumber to make sence
60+
//Just for cucumber to make sense
6261
}
6362

6463
@Then("^subscriptions and jenkins jobs should be removed$")
@@ -91,7 +90,7 @@ public void we_send_the_to_eiffel_intelligence_for_creation(String subscriptionN
9190

9291
@Given("^all previous tests passes\\.$")
9392
public void all_previous_tests_passes() {
94-
//Just for cucumber to make sence
93+
//Just for cucumber to make sense
9594
}
9695

9796
@When("^future story is done\\.$")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.ericsson.ei.systemtest.testexecutionflow;
2+
3+
import org.junit.runner.RunWith;
4+
5+
import cucumber.api.CucumberOptions;
6+
import cucumber.api.junit.Cucumber;
7+
8+
@RunWith(Cucumber.class)
9+
@CucumberOptions(features = "src/systemtest/resources/features/TestExecutionFlow.feature", glue = {
10+
"com.ericsson.ei.systemtest.testexecutionflow" }, plugin = { "pretty",
11+
"html:target/cucumber-reports/TestExecutionFlow"})
12+
public class TestExecutionFlowRunner {
13+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.ericsson.ei.systemtest.testexecutionflow;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertTrue;
5+
6+
import java.util.ArrayList;
7+
8+
import org.junit.Ignore;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
import org.springframework.test.context.support.AbstractTestExecutionListener;
12+
13+
import com.ericsson.ei.systemtest.utils.Config;
14+
import com.ericsson.ei.systemtest.utils.StepsUtils;
15+
import com.ericsson.eiffelcommons.utils.ResponseEntity;
16+
17+
import cucumber.api.java.en.Given;
18+
import cucumber.api.java.en.Then;
19+
import cucumber.api.java.en.When;
20+
21+
@Ignore
22+
public class TestExecutionFlowSteps extends AbstractTestExecutionListener{
23+
private static final Logger LOGGER = LoggerFactory.getLogger(TestExecutionFlowSteps.class);
24+
private static final String JENKINS_TOKEN = "123";
25+
private static final String JENKINS_JOB_XML = "jenkinsJobTemplate.xml";
26+
27+
private ArrayList<String> jenkinsJobNames = new ArrayList<String>();
28+
private Config config = new Config();
29+
30+
@Given("^configurations are provided$")
31+
public void configurations_are_provided() {
32+
config.initEIFrontend();
33+
config.initEIBackend();
34+
config.initJenkinsConfig();
35+
config.initRemRemConfig();
36+
}
37+
38+
@Given("^a jenkins job '\\\"([^\\\"]*)\\\"' from '\"([^\"]*)\"' is created$")
39+
public void a_jenkins_job_from_is_created(String jenkinsJobName, String scriptFileName) throws Throwable {
40+
boolean success = StepsUtils.createJenkinsJob(
41+
jenkinsJobName,
42+
scriptFileName,
43+
config.getJenkinsBaseUrl(),
44+
config.getJenkinsUsername(),
45+
config.getJenkinsPassword(),
46+
JENKINS_TOKEN,
47+
JENKINS_JOB_XML,
48+
config.getRemremBaseUrl()
49+
);
50+
51+
if (success) {
52+
jenkinsJobNames.add(jenkinsJobName);
53+
}
54+
55+
assertTrue("Failed to create jenkins job.", success);
56+
}
57+
58+
@Then("^subscriptions and jenkins jobs should be removed$")
59+
public void subscriptions_and_jenkins_jobs_should_be_removed() throws Throwable {
60+
StepsUtils.deleteJenkinsJobs(jenkinsJobNames);
61+
StepsUtils.deleteSubscriptions(config.getEiFrontendBaseUrl(), config.getEiBackendBaseUrl());
62+
}
63+
64+
@Given("^subscription object \"([^\"]*)\" is created which will trigger \"([^\"]*)\"$")
65+
public void subscription_is_created(String subscriptionName, String jenkinsJobName) throws Throwable {
66+
StepsUtils.createSubscription(subscriptionName, jenkinsJobName, config.getJenkinsUsername(), config.getJenkinsPassword(), config.getJenkinsBaseUrl());
67+
}
68+
69+
@When("^notification with key \"([^\"]*)\" and value \"([^\"]*)\" is added to \"([^\"]*)\"$")
70+
public void notification_with_key_and_value_is_added_to(String key, String value, String subscriptionName) throws Throwable {
71+
StepsUtils.addNotificationToSubscription(key, value, subscriptionName);
72+
}
73+
74+
@When("^condition with jmespath \"([^\"]*)\" is added to \"([^\"]*)\"$")
75+
public void condition_with_jmespath_is_added_to(String jmesPath, String subscriptionName) throws Throwable {
76+
StepsUtils.addConditionToRequirement(jmesPath, subscriptionName);
77+
}
78+
79+
@Then("^we send the \"([^\"]*)\" to eiffel intelligence for creation\\.$")
80+
public void we_send_the_to_eiffel_intelligence_for_creation(String subscriptionName) throws Throwable {
81+
ResponseEntity response = StepsUtils.sendSubscriptionToEiffelIntelligence(subscriptionName, config.getEiFrontendBaseUrl(), config.getEiBackendBaseUrl());
82+
83+
assertEquals("Failed to create subscription. Response: " + response.getBody(), 200, response.getStatusCode());
84+
}
85+
}

src/systemtest/resources/features/ArtifactFlow.feature

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
@AuthFeature
1+
@ArtifactFlowFeature
22
Feature: Artifact system test
33

44
@ArtifactFlowScenario
5-
Scenario: """Creates jenkins jobs, subscriptions and at last see that the flowcompletejob has been
6-
triggered in order to know if all events has been aggregated correctly."""
5+
Scenario: Creates jenkins jobs, subscriptions and at last see that the flowcompletejob has been
6+
triggered in order to know if all events has been aggregated correctly.
7+
78
Given configurations are provided
89
When a jenkins job '"ArtC2Job"' from '"src/systemtest/resources/JenkinsShellScripts/ArtC2Script.txt"' is created
910
And a jenkins job '"TCTJob"' from '"src/systemtest/resources/JenkinsShellScripts/TCTScript.txt"' is created
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@TestExecutionFlowFeature
2+
Feature: Test Execution system test
3+
4+
@TestExecutionFlowScenario
5+
Scenario: Creates jenkins jobs, subscriptions and at last see that the last job has been
6+
triggered in order to know if all events has been aggregated correctly.
7+
8+
Given configurations are provided
9+
10+
#####Add TestExecution_Subscription_01_ActT to EI#####
11+
Given subscription object "TestExecution_Subscription_01_ActT" is created which will trigger "TestExecution_Job_02_ActF"
12+
When notification with key "EVENT_ID" and value "activity_triggered_event_id" is added to "TestExecution_Subscription_01_ActT"
13+
And condition with jmespath "activity_started_event_id == null" is added to "TestExecution_Subscription_01_ActT"
14+
Then we send the "TestExecution_Subscription_01_ActT" to eiffel intelligence for creation.
15+
16+
#####Add TestExecution_Subscription_02_ActF to EI#####
17+
Given subscription object "TestExecution_Subscription_02_ActF" is created which will trigger "TestExecution_Job_03_TERCC"
18+
When notification with key "EVENT_ID" and value "activity_triggered_event_id" is added to "TestExecution_Subscription_02_ActF"
19+
And condition with jmespath "activity_finished_event_id != null" is added to "TestExecution_Subscription_02_ActF"
20+
And condition with jmespath "test_batches == null" is added to "TestExecution_Subscription_02_ActF"
21+
Then we send the "TestExecution_Subscription_02_ActF" to eiffel intelligence for creation.
22+
23+
#####Add TestExecution_Subscription_03_TERCC to EI#####
24+
Given subscription object "TestExecution_Subscription_03_TERCC" is created which will trigger "TestExecution_Job_04_TSS"
25+
When notification with key "EVENT_ID" and value "activity_triggered_event_id" is added to "TestExecution_Subscription_03_TERCC"
26+
And condition with jmespath "test_batches != null" is added to "TestExecution_Subscription_03_TERCC"
27+
And condition with jmespath "test_suite == null" is added to "TestExecution_Subscription_03_TERCC"
28+
Then we send the "TestExecution_Subscription_03_TERCC" to eiffel intelligence for creation.
29+
30+
#####Add TestExecution_Subscription_04_TSS to EI#####
31+
Given subscription object "TestExecution_Subscription_04_TSS" is created which will trigger "TestExecution_Job_05_TCT"
32+
When notification with key "EVENT_ID" and value "test_suite[0].test_suite_started_event_id" is added to "TestExecution_Subscription_04_TSS"
33+
And condition with jmespath "test_suite != null" is added to "TestExecution_Subscription_04_TSS"
34+
And condition with jmespath "test_suite[0].test_case == null" is added to "TestExecution_Subscription_04_TSS"
35+
Then we send the "TestExecution_Subscription_04_TSS" to eiffel intelligence for creation.
36+
37+
#####Add TestExecution_Subscription_05_TCT to EI#####
38+
Given subscription object "TestExecution_Subscription_05_TCT" is created which will trigger "TestExecution_Job_06_TCF"
39+
When notification with key "EVENT_ID_CASE1" and value "test_suite[0].test_case[0].test_case_triggered_event_id" is added to "TestExecution_Subscription_05_TCT"
40+
When notification with key "EVENT_ID_CASE2" and value "test_suite[0].test_case[1].test_case_triggered_event_id" is added to "TestExecution_Subscription_05_TCT"
41+
And condition with jmespath "test_suite[0].test_case[1] != null" is added to "TestExecution_Subscription_05_TCT"
42+
And condition with jmespath "test_suite[0].test_case[1].test_case_finished_event_id == null" is added to "TestExecution_Subscription_05_TCT"
43+
Then we send the "TestExecution_Subscription_05_TCT" to eiffel intelligence for creation.
44+
45+
#####Add TestExecution_Subscription_06_TCF to EI#####
46+
Given subscription object "TestExecution_Subscription_06_TCF" is created which will trigger "TestExecution_Job_07_Complete"
47+
When notification with key "TEST_CONCLUSION" and value "test_suite[0].test_case[0].conclusion" is added to "TestExecution_Subscription_06_TCF"
48+
And condition with jmespath "test_suite[0].test_case[0].conclusion == 'SUCCESSFUL'" is added to "TestExecution_Subscription_06_TCF"
49+
And condition with jmespath "test_suite[0].test_case[1].conclusion == 'SUCCESSFUL'" is added to "TestExecution_Subscription_06_TCF"
50+
Then we send the "TestExecution_Subscription_06_TCF" to eiffel intelligence for creation.

0 commit comments

Comments
 (0)