Skip to content

Commit 9121ed9

Browse files
Add script to run system tests (#234)
1 parent bc55b57 commit 9121ed9

File tree

10 files changed

+292
-16
lines changed

10 files changed

+292
-16
lines changed

.travis.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ language: java
77
services:
88
- docker
99

10+
# No output from git clone command
11+
git:
12+
quiet: true
13+
1014
# All environment variables must be in one line to trigger a single build.
1115
env:
1216
- EI_BACKEND_PORT=8099 JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
1317

18+
1419
# Using default 'test' stage for our tests, and only running deploy stage
1520
# (after merge) on master branch
1621
stages:
@@ -26,10 +31,14 @@ before_install:
2631
- export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
2732
- export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
2833
- java -version
29-
- source src/main/docker/env.bash
30-
- docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed
34+
- |
35+
if [[ $TRAVIS_JOB_NAME = integrationTests ]]; then
36+
source src/main/docker/env.bash
37+
docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed
38+
fi
3139
3240
41+
# Only used before integrationTests
3342
install:
3443
- git clone --depth=50 --branch=master https://github.com/eiffel-community/eiffel-intelligence.git
3544
- cd eiffel-intelligence
@@ -40,8 +49,11 @@ install:
4049
- cd ..
4150

4251
after_script:
43-
- docker-compose -f src/main/docker/docker-compose.yml down
44-
- fuser -k ${EI_BACKEND_PORT}/tcp
52+
- |
53+
if [[ $TRAVIS_JOB_NAME = integrationTests ]]; then
54+
docker-compose -f src/main/docker/docker-compose.yml down
55+
fuser -k ${EI_BACKEND_PORT}/tcp
56+
fi
4557
4658
4759
# Generate site documentation using mvn site plugin
@@ -61,7 +73,7 @@ jobs:
6173
- sudo apt-get update
6274
- sudo apt-get install -y openjdk-8-jdk
6375
- export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/local\/lib\/jvm\/openjdk11\/bin//')
64-
- export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
76+
- export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
6577
- echo $PATH
6678
- export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
6779
- java -version

src/main/docker/Dockerfile-Jenkins

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ARG JENKINS_IMAGE
2+
FROM ${JENKINS_IMAGE}
3+
4+
RUN /install-plugins.sh groovy:2.1

src/main/docker/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,29 @@ docker build -t eiffel-intelligence-frontend --build-arg URL=./${EIFFEL_WAR} -f
1919
By using the docker-compose file in this directory it is possible to set up a
2020
complete environment to run integration tests and/or system test scenarios
2121
for Eiffel Intelligence. If you want to test with your latest local changes,
22-
change the docker images used for the Eiffel Intelligence services.
22+
add the '--build' flag and docker-compose will build Eiffel Intelligence
23+
and Jenkins images based on the instructions in docker-compose.yml file.
2324

24-
To set up the environment for running system tests (from root directory):
25+
**To set up environment with latest code changes of Eiffel Intelligence (from root directory):**
26+
The --build flag ensures the Docker images will be rebuilt if you have other
27+
Docker images with the same name:tag lying around. Eiffel Intelligence back-ends
28+
and front-end and Jenkins containers will be built before starting up the environment.
2529

2630
source src/main/docker/env.bash
27-
docker-compose -f src/main/docker/docker-compose.yml up -d
31+
docker-compose -f src/main/docker/docker-compose.yml up -d --build
32+
33+
**To run with older (specific) versions of Eiffel Intelligence pulled from DockerHub:**
34+
To avoid building any Eiffel Intelligence images that don't exist locally,
35+
run the command 'docker-compose pull serviceName' on the images you want.
36+
This will pull the image with the version specified in the docker-compose.yml
37+
from DockerHub, so that when up command is run this image will be used, and
38+
it will not be rebuilt.
2839

40+
source src/main/docker/env.bash
41+
docker-compose -f src/main/docker/docker-compose.uml pull <serviceName>
42+
docker-compose -f src/main/docker/docker-compose.yml up -d
2943

30-
Or start up specific services (only ones needed for integration tests) by listing them like so:
44+
**Start up specific services (only ones needed for integration tests) by listing them like so:**
3145

3246
docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server
3347

src/main/docker/docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ services:
206206
jenkins:
207207
restart: always
208208
image: ${JENKINS_IMAGE}
209+
build:
210+
# The Docker image will be built using the specified image tag above
211+
context: ../../../
212+
dockerfile: ./src/main/docker/Dockerfile-Jenkins
213+
args:
214+
JENKINS_IMAGE: ${JENKINS_IMAGE}
209215
expose:
210216
- "8080"
211217
ports:
@@ -228,6 +234,12 @@ services:
228234
ei-backend-artifact:
229235
restart: always
230236
image: ${EI_BACKEND_IMAGE}
237+
build:
238+
# The Docker image will be built using the specified image tag above
239+
context: ../../../
240+
dockerfile: ./src/main/docker/Dockerfile
241+
args:
242+
URL: ./eiffel-intelligence/${EI_BACKEND_WAR_FILE}
231243
expose:
232244
- "8080"
233245
ports:
@@ -273,6 +285,12 @@ services:
273285
ei-backend-sourcechange:
274286
restart: always
275287
image: ${EI_BACKEND_IMAGE}
288+
build:
289+
# The Docker image will be built using the specified image tag above
290+
context: ../../../
291+
dockerfile: ./src/main/docker/Dockerfile
292+
args:
293+
URL: ./eiffel-intelligence/${EI_BACKEND_WAR_FILE}
276294
expose:
277295
- "8080"
278296
ports:
@@ -318,6 +336,12 @@ services:
318336
ei-backend-testexecution:
319337
restart: always
320338
image: ${EI_BACKEND_IMAGE}
339+
build:
340+
# The Docker image will be built using the specified image tag above
341+
context: ../../../
342+
dockerfile: ./src/main/docker/Dockerfile
343+
args:
344+
URL: ./eiffel-intelligence/${EI_BACKEND_WAR_FILE}
321345
expose:
322346
- "8080"
323347
ports:
@@ -365,6 +389,12 @@ services:
365389
ei-frontend:
366390
restart: always
367391
image: ${EI_FRONTEND_IMAGE}
392+
build:
393+
# The Docker image will be built using the specified image tag above
394+
context: ../../../
395+
dockerfile: ./src/main/docker/Dockerfile
396+
args:
397+
URL: ${EI_FRONTEND_WAR_FILE}
368398
expose:
369399
- "8080"
370400
ports:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public void configurations_are_provided() throws Throwable {
3131
config.initEIFrontend();
3232
config.initEIBackend("artifact");
3333
config.initJenkinsConfig();
34+
StepsUtils.installGroovy(config.getJenkinsExternalBaseUrl(),
35+
config.getJenkinsUsername(), config.getJenkinsPassword());
3436
config.initRemRemConfig();
3537
}
3638

src/systemtest/java/com/ericsson/ei/systemtest/sourcechangeflow/SourceChangeFlowSteps.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public void configurations_are_provided() throws Throwable {
3232
config.initEIFrontend();
3333
config.initEIBackend("sourcechange");
3434
config.initJenkinsConfig();
35+
StepsUtils.installGroovy(config.getJenkinsExternalBaseUrl(),
36+
config.getJenkinsUsername(), config.getJenkinsPassword());
3537
config.initRemRemConfig();
3638
}
3739

src/systemtest/java/com/ericsson/ei/systemtest/testexecutionflow/TestExecutionFlowSteps.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public void configurations_are_provided() throws Throwable {
3131
config.initEIFrontend();
3232
config.initEIBackend("testexecution");
3333
config.initJenkinsConfig();
34+
StepsUtils.installGroovy(config.getJenkinsExternalBaseUrl(),
35+
config.getJenkinsUsername(), config.getJenkinsPassword());
3436
config.initRemRemConfig();
3537
}
3638

src/systemtest/java/com/ericsson/ei/systemtest/utils/StepsUtils.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class StepsUtils {
3737
* @param jenkinsJobName - Name of the jenkins job
3838
* @param scriptFileName - FileName of the script which is to be executed when the job is triggered
3939
* @param jenkinsBaseUrl - Base url to jenkins e.g http://localhost:8070
40-
* @param jenkinsUserName - Username to the jenkins machine
40+
* @param jenkinsUsername - Username to the jenkins machine
4141
* @param jenkinsPassword - Password to the jenkins machine
4242
* @param jenkinsToken - Token to the jenkins job.
4343
*
@@ -61,12 +61,26 @@ public static boolean createJenkinsJob(String jenkinsJobName, String scriptFileN
6161

6262
jenkinsManager = new JenkinsManager(jenkinsBaseUrl, jenkinsUsername, jenkinsPassword);
6363

64+
return jenkinsManager.forceCreateJob(jenkinsJobName, jenkinsXmlAsString);
65+
}
66+
67+
/**
68+
* This method installs Groovy script in Jenkins
69+
* @param jenkinsBaseUrl - Base url to jenkins e.g http://localhost:8070
70+
* @param jenkinsUsername - Username to the jenkins machine
71+
* @param jenkinsPassword - Password to the jenkins machine
72+
*
73+
* @throws Exception
74+
*/
75+
public static void installGroovy(String jenkinsBaseUrl,
76+
String jenkinsUsername,
77+
String jenkinsPassword) throws Exception {
78+
jenkinsManager = new JenkinsManager(jenkinsBaseUrl, jenkinsUsername, jenkinsPassword);
79+
6480
if(!jenkinsManager.pluginExists("Groovy")) {
6581
jenkinsManager.installPlugin("Groovy", "2.1");
6682
jenkinsManager.restartJenkins();
6783
}
68-
69-
return jenkinsManager.forceCreateJob(jenkinsJobName, jenkinsXmlAsString);
7084
}
7185

7286
/**
@@ -93,23 +107,24 @@ public static void deleteJenkinsJobs(ArrayList<String> jenkinsJobNames) throws E
93107
*
94108
* @param subscriptionName
95109
* @param nameOfJobToBeTriggered
96-
* @param jenkinsUserame
110+
* @param jenkinsUsername
97111
* @param jenkinsPassword
98112
* @param jenkinsBaseUrl
99113
* @throws IOException
100114
* @throws JSONException
101115
*/
102-
public static void createSubscription(String subscriptionName, String nameOfJobToBeTriggered, String jenkinsUserame, String jenkinsPassword, String jenkinsBaseUrl, boolean hasParameters) throws IOException, JSONException {
116+
public static void createSubscription(String subscriptionName, String nameOfJobToBeTriggered, String jenkinsUsername, String jenkinsPassword, String jenkinsBaseUrl, boolean hasParameters) throws IOException, JSONException {
103117
RestPostSubscriptionObject subscription = new RestPostSubscriptionObject(subscriptionName);
104118
subscription.setRestPostBodyMediaType("application/x-www-form-urlencoded");
105-
subscription.setBasicAuth(jenkinsUserame, jenkinsPassword);
119+
subscription.setBasicAuth(jenkinsUsername, jenkinsPassword);
106120
String notificationMeta = jenkinsBaseUrl + "/job/" + nameOfJobToBeTriggered;
107121
if(hasParameters) {
108122
notificationMeta += "/buildWithParameters";
109123
} else {
110124
notificationMeta += "/build";
111125
}
112126
subscription.setNotificationMeta(notificationMeta);
127+
subscription.setAuthenticationType("BASIC_AUTH_JENKINS_CSRF");
113128
subscriptions.put(subscriptionName, subscription);
114129
}
115130

0 commit comments

Comments
 (0)