Blame view
kea_testing.groovy
9.13 KB
a7a0d7905 Add initial Jenki... |
1 2 3 4 5 6 7 8 9 10 |
/** * Jenkinsfile to deploy multiple Docker containers based on docker-compose into a DEV server and run any test. * This pipeline will run the Docker containers, execute the tests and then stop and remove the containers from the DEV * server automatically. **/ pipeline { agent any |
097a24e19 Fix whitespace |
11 |
environment { |
fb793d4ad Revert "Revert "A... |
12 |
|
97fe60fba Remove deployment... |
13 |
APP_URL = "https://kea.curex-project.eu" |
972595bcc Change Master to ... |
14 |
KEYCLOAK_URL = "https://keycloak.curex-project.eu/auth/realms/master/protocol/openid-connect/token" |
97fe60fba Remove deployment... |
15 16 17 |
USER = credentials('keycloak-test-user') PASSWORD = credentials('keycloak-test-password') CLIENT_ID = "KEA" |
a7a0d7905 Add initial Jenki... |
18 19 20 |
} stages { |
a7a0d7905 Add initial Jenki... |
21 |
|
097a24e19 Fix whitespace |
22 |
stage('Run tests') { |
a7a0d7905 Add initial Jenki... |
23 24 |
steps { script { |
f7afd8ea9 Add a simple test |
25 26 27 |
echo '*************' echo '*** TESTS ***' echo '*************' |
a7a0d7905 Add initial Jenki... |
28 |
/* Here do your tests */ |
f7afd8ea9 Add a simple test |
29 |
try { |
97fe60fba Remove deployment... |
30 31 |
// Get Keycloak auth token String token = sh(label: "get_keycloak_token", script: "curl -s -X POST $KEYCLOAK_URL -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=$USER' -d 'password=$PASSWORD' -d 'grant_type=password' -d 'client_id=$CLIENT_ID' | sed 's/.*access_token\":\"//g' | sed 's/\".*//g'", returnStdout: true) |
686bf5b89 Add tests KEA_F00... |
32 |
String testName = "KEA_F001" |
97fe60fba Remove deployment... |
33 34 |
String url = "$APP_URL" String responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
35 |
echo responseCode |
f7afd8ea9 Add a simple test |
36 37 38 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
39 |
|
55bf5645f Move F004 and F00... |
40 |
testName = "KEA_F002" |
97fe60fba Remove deployment... |
41 42 |
url = "$APP_URL/components/od" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
43 |
echo responseCode |
55bf5645f Move F004 and F00... |
44 45 46 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
47 |
|
55bf5645f Move F004 and F00... |
48 |
testName = "KEA_F003" |
97fe60fba Remove deployment... |
49 50 |
url = "$APP_URL/components/mltd" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
51 |
echo responseCode |
97fe60fba Remove deployment... |
52 53 54 55 56 57 58 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } testName = "KEA_F004" url = "$APP_URL/api/config" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
59 |
echo responseCode |
55bf5645f Move F004 and F00... |
60 61 62 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
63 64 65 66 |
testName = "KEA_F005" url = "$APP_URL/api/capec" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
67 |
echo responseCode |
3d1540d58 Revert "Disable t... |
68 69 70 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
71 |
|
9396f6c4a Move back grafana... |
72 73 74 |
testName = "KEA_F006" url = "https://kea-grafana.vlahavas.com/api/dashboards/home" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Αuthorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
75 |
echo responseCode |
cfd27a3cb Add back all tests |
76 77 78 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
79 |
|
9396f6c4a Move back grafana... |
80 81 |
testName = "KEA_F007" url = "https://kea-kibana.vlahavas.com/app/kibana" |
97fe60fba Remove deployment... |
82 |
responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
83 |
echo responseCode |
546bec5fd Revert "Disable t... |
84 85 86 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
87 |
|
9396f6c4a Move back grafana... |
88 89 |
testName = "KEA_F008" url = "$APP_URL/components/ceptd" |
97fe60fba Remove deployment... |
90 |
responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
91 |
echo responseCode |
a440995cf Move KEA_F003 to ... |
92 93 94 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
97fe60fba Remove deployment... |
95 |
|
296ef6417 Add OD test |
96 97 |
testName = "KEA_F009" url = "$APP_URL/api/v1/od/start" |
7ebc5964e Don't fetch only ... |
98 |
responseCode = sh(label: testName, script: "curl -m 10 -sL -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url", returnStdout: true) |
1504b1017 Add echo |
99 |
echo responseCode |
296ef6417 Add OD test |
100 101 102 103 104 105 |
if (!responseCode.endsWith('200')) { error("$testName: Returned status code = $responseCode when calling $url") } String processId = responseCode.split(",")[1].split(":")[1].split('"')[1]; url = "$APP_URL/api/v1/od/status" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
106 |
echo responseCode |
296ef6417 Add OD test |
107 108 109 110 111 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } url = "$APP_URL/api/v1/od/stop/$processId" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) |
3e893a46f Always echo the r... |
112 |
echo responseCode |
296ef6417 Add OD test |
113 114 115 |
if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
88b814847 Add MLTD tests |
116 117 118 119 120 121 122 123 |
testName = "KEA_F010" url = "$APP_URL/api/v1/mltd/start" responseCode = sh(label: testName, script: "curl -m 10 -sL -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url", returnStdout: true) echo responseCode if (!responseCode.endsWith('200')) { error("$testName: Returned status code = $responseCode when calling $url") } |
d852a28bf Process ID is not... |
124 |
processId = responseCode.split(",")[1].split(":")[1]; |
88b814847 Add MLTD tests |
125 126 127 128 129 130 131 132 133 134 135 136 |
url = "$APP_URL/api/v1/mltd/status" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) echo responseCode if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } url = "$APP_URL/api/v1/mltd/stop/$processId" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) echo responseCode if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
955d7930b Test ADT and VDM ... |
137 138 139 140 141 142 143 144 145 146 |
testName = "KEA_F011" url = "$APP_URL/api/v1/adt" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) echo responseCode if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } testName = "KEA_F012" |
6b180da53 Actually test VDM... |
147 |
url = "$APP_URL/api/v1/vdm" |
955d7930b Test ADT and VDM ... |
148 149 150 151 152 |
responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) echo responseCode if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
a515f488e Add xlsiem test |
153 154 155 156 157 158 159 160 |
testName = "KEA_F013" url = "$APP_URL/api/v1/xlsiem" responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) echo responseCode if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } |
296ef6417 Add OD test |
161 |
|
f7afd8ea9 Add a simple test |
162 163 164 165 |
} catch (ignored) { currentBuild.result = 'FAILURE' echo "KEA Deployment Tests failed" } |
a7a0d7905 Add initial Jenki... |
166 167 168 |
} } } |
a7a0d7905 Add initial Jenki... |
169 170 |
} } |
097a24e19 Fix whitespace |
171 |