Commit 97fe60fba2637749a1d9e8b921fe9a6965255a0c

Authored by George Vlahavas
1 parent de6d35b8e2

Remove deployment from tests

The instance is already up and running on a permanent basis now.

Showing 1 changed file with 41 additions and 105 deletions

kea_testing.groovy View file @ 97fe60f
... ... @@ -10,78 +10,17 @@
10 10 agent any
11 11  
12 12 environment {
13   - // Keep as is the following two lines
14   - PRIVATE_REGISTRY = "https://registry.curex-project.eu:443/curex-local/"
15   - ARTIFACTORY_URL = "registry.curex-project.eu:443/curex-local/"
16   -
17   - HOST_IP = "116.203.166.220"
18   - DEPLOYMENT_HOST = "${HOST_IP}:2376"
19   - DEPLOYMENT_HOST_CREDENTIALS = "vm2-creds"
20 13  
21   - // KEA specific
22   - APP_NAME = "KEA"
23   - APP_ENV = "production"
24   - APP_DEBUG = "true"
25   - APP_URL = "http://${HOST_IP}"
  14 + APP_URL = "https://kea.curex-project.eu"
  15 + KEYCLOAK_URL = "https://keycloak-curex.gnubila.fr/auth/realms/Integration/protocol/openid-connect/token"
  16 + USER = credentials('keycloak-test-user')
  17 + PASSWORD = credentials('keycloak-test-password')
  18 + CLIENT_ID = "KEA"
26 19  
27   - KIBANA_PORT = "5611"
28   - GRAFANA_PORT = "3001"
29   -
30   - LOG_CHANNEL = "stack"
31   -
32   - DB_CONNECTION = "pgsql"
33   - DB_HOST = "timescaledb"
34   - DB_PORT = "5432"
35   - DB_DATABASE = "kea"
36   - DB_USERNAME = "postgres"
37   - DB_PASSWORD = "postgres"
38   -
39   - BROADCAST_DRIVER = "log"
40   - CACHE_DRIVER = "file"
41   - QUEUE_CONNECTION = "sync"
42   - SESSION_DRIVER = "file"
43   - SESSION_LIFETIME = "120"
44   -
45   - JWT_TTL = "1440"
46   -
47   - ELASTICSEARCH_HOST = "elasticsearch"
48   - ELASTICSEARCH_PORT = "9200"
49   - ELASTICSEARCH_SCHEME = "http"
50   -
51   - MQTT_HOST = "mosquitto"
52   - MQTT_PORT = "1883"
53   - MQTT_DEBUG = "false"
54   - MQTT_QOS = "0"
55   - MQTT_RETAIN = "0"
56   -
57   - MLTD_HOST = "mltd"
58   - MLTD_PORT = "5000"
59   - OD_HOST = "od"
60   - OD_PORT = "9091"
61 20 }
62 21  
63 22 stages {
64   -
65   - stage('Checkout the source code') {
66   - steps {
67   - checkout scm
68   - }
69   - }
70 23  
71   -
72   - stage('Deploy Docker containers in DEV server') {
73   - steps {
74   - script {
75   - docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") {
76   - docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') {
77   - echo 'Deploying the specified Docker containers in DEV server'
78   - sh 'sh deploy.sh'
79   - }
80   - }
81   - }
82   - }
83   - }
84   -
85 24 stage('Run tests') {
86 25 steps {
87 26 script {
88 27  
89 28  
90 29  
91 30  
92 31  
93 32  
94 33  
95 34  
96 35  
97 36  
98 37  
99 38  
... ... @@ -91,53 +30,65 @@
91 30 /* Here do your tests */
92 31 sleep 90
93 32 try {
  33 + // Get Keycloak auth token
  34 + 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)
  35 +
94 36 String testName = "KEA_F001"
95   - String url = "$APP_URL:13880"
96   - String responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  37 + String url = "$APP_URL"
  38 + 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)
97 39 if (responseCode != '200') {
98 40 error("$testName: Returned status code = $responseCode when calling $url")
99 41 }
  42 +
100 43 testName = "KEA_F002"
101   - url = "$APP_URL:13880/components/od"
102   - responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  44 + url = "$APP_URL/components/od"
  45 + 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)
103 46 if (responseCode != '200') {
104 47 error("$testName: Returned status code = $responseCode when calling $url")
105 48 }
  49 +
106 50 testName = "KEA_F003"
107   - url = "$APP_URL:13880/components/mltd"
108   - responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  51 + url = "$APP_URL/components/mltd"
  52 + 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)
109 53 if (responseCode != '200') {
110 54 error("$testName: Returned status code = $responseCode when calling $url")
111 55 }
  56 +
  57 + testName = "KEA_F004"
  58 + url = "$APP_URL/api/config"
  59 + 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)
  60 + if (responseCode != '200') {
  61 + error("$testName: Returned status code = $responseCode when calling $url")
  62 + }
  63 +
  64 + testName = "KEA_F005"
  65 + url = "$APP_URL/api/capec"
  66 + 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)
  67 + if (responseCode != '200') {
  68 + error("$testName: Returned status code = $responseCode when calling $url")
  69 + }
  70 +
112 71 testName = "KEA_F006"
113   - url = "$APP_URL:3001"
114   - responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  72 + url = "https://kea-grafana.vlahavas.com"
  73 + 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)
115 74 if (responseCode != '200') {
116 75 error("$testName: Returned status code = $responseCode when calling $url")
117 76 }
  77 +
118 78 testName = "KEA_F007"
119   - url = "$APP_URL:5611"
120   - responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  79 + url = "https://kea-kibana.vlahavas.com/app/kibana"
  80 + 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)
121 81 if (responseCode != '200') {
122 82 error("$testName: Returned status code = $responseCode when calling $url")
123 83 }
  84 +
124 85 testName = "KEA_F008"
125   - url = "$APP_URL:13880/components/ceptd"
126   - responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true)
  86 + url = "$APP_URL/components/ceptd"
  87 + 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)
127 88 if (responseCode != '200') {
128 89 error("$testName: Returned status code = $responseCode when calling $url")
129 90 }
130   - testName = "KEA_F004"
131   - url = "mqtt://${HOST_IP}:1883/test"
132   - responseCode = sh(label: testName, script: "sleep 2 ; curl -d 1 $url & OUT=`curl -m 4 -s $url` ; echo $OUT", returnStdout: true)
133   - if (responseCode != 'test1') {
134   - error("$testName: Returned status code = $responseCode when running MQTT test on $url")
135   - }
136   - testName = "KEA_F005"
137   - responseCode = sh(label: testName, script: "docker exec -ti kea_timescaledb psql -l -U postgres | grep -q kea ; echo \$?", returnStdout: true)
138   - if (responseCode != '0') {
139   - error("$testName: Returned status code = $responseCode when looking for presense of kea DB")
140   - }
  91 +
141 92 } catch (ignored) {
142 93 currentBuild.result = 'FAILURE'
143 94 echo "KEA Deployment Tests failed"
... ... @@ -146,21 +97,6 @@
146 97 }
147 98 }
148 99  
149   -
150   - stage('Stop and remove the Docker containers in DEV server') {
151   - steps {
152   - script {
153   - docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") {
154   - docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') {
155   -
156   - //echo 'Stop and remove the specified Docker containers from the DEV server'
157   - sh 'sh delete.sh'
158   -
159   - }
160   - }
161   - }
162   - }
163   - }
164 100 }
165 101 }