Skip to content

Commit fe0e699

Browse files
author
Anders Breid
authored
Add multiple test for rest post calls (#250)
* Updated how EI extracts url params, and now accepts JMESPATH * Edited message when email rejects. * fixed test that failed on validating notificationMeta * Fixed Testing url-form-post * Added test for form post subscription * Added integration tests for more advnced rest calls
1 parent 0c7f734 commit fe0e699

File tree

16 files changed

+547
-548
lines changed

16 files changed

+547
-548
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
</repositories>
6464

6565
<dependencies>
66+
<dependency>
67+
<groupId>com.github.eiffel-community</groupId>
68+
<artifactId>eiffel-commons</artifactId>
69+
<version>0.0.4</version>
70+
</dependency>
71+
6672
<dependency>
6773
<groupId>org.springframework.boot</groupId>
6874
<artifactId>spring-boot-starter</artifactId>

src/integrationtests/java/com/ericsson/ei/integrationtests/ArtifactFlowRunnerIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.junit.BeforeClass;
44
import org.junit.runner.RunWith;
5-
import org.springframework.test.context.TestPropertySource;
65

76
import cucumber.api.CucumberOptions;
87
import cucumber.api.junit.Cucumber;

src/integrationtests/java/com/ericsson/ei/integrationtests/FlowStepsIT.java

Lines changed: 235 additions & 107 deletions
Large diffs are not rendered by default.

src/integrationtests/java/util/IntegrationTestBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ protected JsonNode getJSONFromFile(String filePath) throws IOException {
214214
*/
215215
protected void waitForEventsToBeProcessed(int eventsCount) throws InterruptedException {
216216
// wait for all events to be processed
217+
long stopTime = System.currentTimeMillis() + 60000;
217218
long processedEvents = 0;
218-
while (processedEvents < eventsCount) {
219+
while (processedEvents < eventsCount && stopTime > System.currentTimeMillis()) {
219220
processedEvents = countProcessedEvents(database, event_map);
220221
LOGGER.info("Have gotten: " + processedEvents + " out of: " + eventsCount);
221222
TimeUnit.MILLISECONDS.sleep(1000);

src/integrationtests/java/util/JenkinsManager.java

Lines changed: 0 additions & 213 deletions
This file was deleted.

src/integrationtests/resources/features/ArtifactFlowIT.feature

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@
1717
## (Comments)
1818
#Sample Feature Definition Template
1919
Feature: Artifact flow Integrationtest
20-
Scenario: Send eiffel events for artifact flow and make sure EI is triggering on mail subscriptions
21-
Given that "mail" subscription with jmespath "id=='aacc3c87-75e0-4b6d-88f5-b1a5d4e62b43'" is uploaded
22-
And the rules "src/test/resources/ArtifactRules.json"
20+
21+
Scenario:
22+
Send eiffel events for artifact flow and make sure EI is triggering
23+
on mail subscriptions
24+
25+
# Setup Eiffel Intelligence
26+
Given the rules "src/test/resources/ArtifactRules.json"
2327
And the events "src/test/resources/ArtifactFlowTestEvents.json"
2428
And the resulting aggregated object "src/test/resources/AggregatedDocumentInternalCompositionLatestIT.json";
25-
And the expected aggregated object ID is "aacc3c87-75e0-4b6d-88f5-b1a5d4e62b43"
2629
And the upstream input "src/test/resources/upStreamInput.json"
30+
Then the expected aggregated object ID is "aacc3c87-75e0-4b6d-88f5-b1a5d4e62b43"
31+
# Setup subscription
32+
Given subscription object for "MAIL" with name "MailTestSubscription" is created
33+
When notification meta "some.cool.email@ericsson.com" is set in subscription
34+
And rest post body media type is set to "crazy-pinguin" is set in subscription
35+
And paremeter form key "" and form value "to_string(@)" is added in subscription
36+
And condition "id=='aacc3c87-75e0-4b6d-88f5-b1a5d4e62b43'" at requirement index '0' is added in subscription
37+
Then subscription is uploaded
38+
# Send Events and Check job triggered
39+
Given all previous steps passed
2740
When the upstream input events are sent
2841
And the eiffel events are sent
2942
Then mongodb should contain mail.
30-
31-

src/integrationtests/resources/features/SourceChangeFlowIT.feature

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,71 @@
1717
## (Comments)
1818
#Sample Feature Definition Template
1919
Feature: Source change flow integrationtest
20-
Scenario: Send eiffel events for source change flow and make sure EI is triggering on REST-POST subscriptions
20+
21+
Scenario:
22+
Send eiffel events for source change flow and make sure EI is triggering on
23+
REST-POST subscriptions using buildWithParameters and JMESPATH extracted correct
24+
data to add to parameter
25+
2126
Given the rules "src/test/resources/SourceChangeObjectRules.json"
2227
And the events "src/test/resources/TestSourceChangeObjectEvents.json"
2328
And the upstream input "src/test/resources/UpstreamEventsForSourceChange.json"
2429
And the resulting aggregated object "src/test/resources/aggregatedSourceChangeObject.json";
2530
And the expected aggregated object ID is "sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47"
26-
And jenkins is set up with a job "source-change-job"
27-
And that "REST/POST" subscription with jmespath "id=='sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47'" is uploaded
31+
# Setup jenkins
32+
Given jenkins data is prepared
33+
When job token "test-token-123" is added to jenkins data
34+
And parameter key "test_key" is added to jenkins data
35+
And bash script "echo 'param 1 ' $test_key" is added to jenkins data
36+
Then jenkins is set up with job name "sourceChangeTestJobParam"
37+
# Setup subscription
38+
Given subscription object for "REST/POST" with name "ParameterizedTriggerSubscription" is created
39+
When notification meta "http://${jenkinsHost}:${jenkinsPort}/job/${jenkinsJobName}/buildWithParameters?token='test-token-123'&test_key=id" is set in subscription
40+
And basic_auth authentication with username "admin" and password "admin" is set in subscription
41+
And rest post body media type is set to "application/x-www-form-urlencoded" is set in subscription
42+
And condition "id=='sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47'" at requirement index '0' is added in subscription
43+
Then subscription is uploaded
44+
# Send Events and Check job triggered
45+
Given all previous steps passed
2846
When the upstream input events are sent
29-
And the eiffel events are sent
30-
Then the jenkins job should have been triggered.
47+
When the eiffel events are sent
48+
And jenkins job status data fetched
49+
Then verify jenkins job data timestamp is after test subscription was creted
50+
And jenkins job status data has key "test_key" with value "sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47"
51+
And the jenkins job should be deleted
52+
53+
Scenario:
54+
Send eiffel events for source change flow and make sure EI is triggering on
55+
REST-POST subscriptions using buildWithParameters and JMESPATH extracted correct
56+
data to add to parameter
57+
58+
Given the rules "src/test/resources/SourceChangeObjectRules.json"
59+
And the events "src/test/resources/TestSourceChangeObjectEvents.json"
60+
And the upstream input "src/test/resources/UpstreamEventsForSourceChange.json"
61+
And the resulting aggregated object "src/test/resources/aggregatedSourceChangeObject.json";
62+
And the expected aggregated object ID is "sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47"
63+
# Setup jenkins
64+
Given jenkins data is prepared
65+
When job token "test-token-123" is added to jenkins data
66+
And parameter key "test_param_1" is added to jenkins data
67+
And parameter key "test_param_2" is added to jenkins data
68+
And bash script "echo 'param 1 ' $test_param_1" is added to jenkins data
69+
And bash script "echo 'param 2 ' $test_param_2" is added to jenkins data
70+
Then jenkins is set up with job name "sourceChangeTestJobBodyJson"
71+
# Setup subscription
72+
Given subscription object for "REST/POST" with name "ParameterInBodyTriggerSubscription" is created
73+
When notification meta "http://${jenkinsHost}:${jenkinsPort}/job/${jenkinsJobName}/build?token='test-token-123'" is set in subscription
74+
And basic_auth authentication with username "admin" and password "admin" is set in subscription
75+
And rest post body media type is set to "application/x-www-form-urlencoded" is set in subscription
76+
And paremeter form key "json" and form value "{parameter: [{name:'test_param_1', value:'Test Input Value'}, {name:'test_param_2', value:id}]}" is added in subscription
77+
And condition "id=='sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47'" at requirement index '0' is added in subscription
78+
Then subscription is uploaded
79+
# Send Events and Check job triggered
80+
Given all previous steps passed
81+
When the upstream input events are sent
82+
When the eiffel events are sent
83+
And jenkins job status data fetched
84+
Then verify jenkins job data timestamp is after test subscription was creted
85+
And jenkins job status data has key "test_param_1" with value "Test Input Value"
86+
And jenkins job status data has key "test_param_2" with value "sb6efi4n-25fb-4d77-b9fd-5f2xrrefe66de47"
87+
Then the jenkins job should be deleted

0 commit comments

Comments
 (0)