image: docker:latest services: - docker:dind stages: - package - smoke-curl - kubernetes - swagger - docker-hub - testDockerHub variables: CI_VERSION: '1.0.${CI_JOB_ID}' KUBECONFIG: /etc/deploy/config PROJECT_NAME: smoke-master SMKTEST_PROJECT_NAME: 'SmokeMaster' SMKTEST_ENVIRONMENT: 'master' SMKTEST_NAMESPACE: 'edutelling-develop' SMKTEST_MODE_AUTO: 'true' SMOKE_COLLECTOR: $SMOKE_COLLECTOR # Template for use kubernetes. .smoke-test-kubernetes: &smoke-test-kubernetes image: registry.gitlab.com/phdactivities/smoke-master:master stage: kubernetes before_script: # Create cluster remote configuration file. - echo $KUBERNETES_TOKEN | base64 -d > /etc/deploy/config variables: SMKTEST_CONTEXT: 'kubernetes' # Template for use kubernetes. .smoke-test-kubernetes-prod: &smoke-test-kubernetes-prod image: registry.gitlab.com/phdactivities/smoke-master:production stage: kubernetes before_script: # Create cluster remote configuration file. - echo $KUBERNETES_TOKEN | base64 -d > /etc/deploy/config variables: SMKTEST_CONTEXT: 'kubernetes' # Template for use Curl or swagger smoke test. .smoke-test-curl: &smoke-test-curl image: registry.gitlab.com/phdactivities/smoke-master:master stage: smoke-curl variables: SMKTEST_CONTEXT: 'remote-server' docker-build: image: name: gcr.io/kaniko-project/executor:debug-v0.19.0 entrypoint: [''] stage: package script: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --context . --dockerfile Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG --cache only: - master - production curlGoogle: <<: *smoke-test-curl variables: SMKTEST_CONTEXT: 'remote-server' script: - create-smktest --assert-curl="curl www.google.com" - create-smktest --assert-curl="curl www.google.comasdad" only: - master allow_failure: true #If fail using waring signal checkLogin: <<: *smoke-test-curl variables: SMKTEST_ASSERT_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' script: - create-smktest --context=remote-server only: - master # ------------------------------------------------------ # EXAMPLE USING KUBERNETES: ---------------------------- # ------------------------------------------------------>>>> # Example how connect one remote cluster. remoteAccess: <<: *smoke-test-curl script: # Create cluster remote configuration file. - echo $KUBERNETES_TOKEN | base64 -d > /etc/deploy/config - kubectl get pods --namespace=edutelling-develop only: - master # Example how connect one remote cluster podsActive: <<: *smoke-test-kubernetes script: - create-smktest --check-pods-running=true only: - master # Example how connect one remote cluster ingressPods: <<: *smoke-test-kubernetes script: - echo $SMOKE_COLLECTOR - create-smktest --check-ingress=true only: - master # Example how connect one remote cluster conditionsCluster: <<: *smoke-test-kubernetes script: - create-smktest --check-cluster=true only: - master logsPods: <<: *smoke-test-kubernetes script: - create-smktest --check-pods-logs=true only: - master volumeSpace: <<: *smoke-test-kubernetes script: - create-smktest --check-volumes=true only: - master networks: <<: *smoke-test-kubernetes script: - create-smktest --check-networks-from-service=edutelling-api only: - master dependencies: <<: *smoke-test-kubernetes variables: SMKTEST_CONTEXT: 'kubernetes' SMKTEST_PROJECT_NAME: smoke-test SMKTEST_ENVIRONMENT: develop SMKTEST_NAMESPACE: edutelling-develop SMKTEST_CURL_LOGIN: curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept:application/json" -H "Content-Type:application/json" -d "{ \"email\":\"formazione@edutelling.it\", \"password\":\"Passw0rd\", \"stayLogged\":false }" SMKTEST_CURL_DEPENDENCIES: curl 'https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/user' -H 'authority:edutelling-api-develop.openshift.techgap.it' -H 'sec-ch-ua:" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' -H 'accept:application/json, text/plain, */*' -H 'authorization:Bearer $SMKTEST_CURL_LOGIN' -H 'accept-language:it' -H 'sec-ch-ua-mobile:?0' -H 'user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36' -H 'origin:https://edutelling-app-develop.openshift.techgap.it' -H 'sec-fetch-site:same-site' -H 'sec-fetch-mode:cors' -H 'sec-fetch-dest:empty' -H 'referer:https://edutelling-app-develop.openshift.techgap.it/' -H 'if-none-match:W/"837-HakEFZEWDaF6n7swn4jHVp/2fX0"' --compressed SMKTEST_CHECK_DEPENDENCIES_FROM_SERVICE: edutelling-api script: - create-smktest --assert-number-of-dependencies-exited=1 only: - master allow_failure: true #If fail using waring signal # ------------------------------------------------<<<< # ------------------------------------------------------ # EXAMPLE USING SWAGGER PUBLIC: ------------------------------- # ------------------------------------------------------>>>> pubAPetStore: <<: *smoke-test-kubernetes stage: swagger script: - create-smktest --check-swagger-public-apis="https://petstore.swagger.io/v2/swagger.json" only: - master allow_failure: true #If fail using waring signal pubAEdutelling: <<: *smoke-test-kubernetes stage: swagger script: - create-smktest --check-swagger-public-apis="https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/" only: - master allow_failure: true #If fail using waring signal pubATrust: <<: *smoke-test-kubernetes stage: swagger script: - create-smktest --check-swagger-public-apis="https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/" only: - master allow_failure: true #If fail using waring signal pubAPOT: <<: *smoke-test-kubernetes stage: swagger script: - create-smktest --check-swagger-public-apis="https://pot-uat.paxitalia.com:8443/api/v2/api-docs" only: - master allow_failure: true #If fail using waring signal # ------------------------------------------------------ # EXAMPLE USING SWAGGER WITH AUTH: ------------------------------- # ------------------------------------------------------>>>> authAEdutelling: <<: *smoke-test-kubernetes stage: swagger variables: SMKTEST_CONTEXT: 'remote-server' SMKTEST_SWAGGER_LOGIN_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_SWAGGER_APIS: https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/ script: - create-smktest only: - master allow_failure: true #If fail using waring signal authATrust: <<: *smoke-test-kubernetes stage: swagger variables: SMKTEST_CONTEXT: 'remote-server' SMKTEST_SWAGGER_LOGIN_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_SWAGGER_APIS: https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/ script: - echo $GITLAB_USER_EMAIL - echo $GITLAB_USER_ID - echo $CI_PROJECT_URL - echo $CI_PROJECT_TITLE - echo $CI_PROJECT_NAME - echo $CI_PROJECT_ID - echo $CI_PIPELINE_ID - echo $CI_COMMIT_TAG - echo $CI_COMMIT_REF_NAME - echo $CI_COMMIT_SHA - echo $CI_COMMIT_MESSAGE - echo $CI_COMMIT_TITLE - create-smktest only: - master allow_failure: true #If fail using waring signal # ------------------------------------------------<<<< allSmokeTest: <<: *smoke-test-kubernetes-prod stage: swagger variables: # Config params: ------- SMKTEST_CONTEXT: 'kubernetes' SMKTEST_PROJECT_NAME: 'edutelling-develop' SMKTEST_ENVIRONMENT: 'develop' SMKTEST_NAMESPACE: 'edutelling-develop' # Apply Test. SMKTEST_CHECK_IF_ALL_PODS_ARE_ACTIVE: 'true' SMKTEST_CHECK_INGRESS: 'true' SMKTEST_CHECK_CONDITIONS: 'true' SMKTEST_CHECK_LOGS: 'true' SMKTEST_CHECK_VOLUME: 'true' # SMKTEST_CURL_LOGIN: curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept:application/json" -H "Content-Type:application/json" -d "{ \"email\":\"formazione@edutelling.it\", \"password\":\"Passw0rd\", \"stayLogged\":false }" SMKTEST_CURL_DEPENDENCIES: curl 'https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/user' -H 'authority:edutelling-api-develop.openshift.techgap.it' -H 'sec-ch-ua:" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' -H 'accept:application/json, text/plain, */*' -H 'authorization:Bearer $SMKTEST_CURL_LOGIN' -H 'accept-language:it' -H 'sec-ch-ua-mobile:?0' -H 'user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36' -H 'origin:https://edutelling-app-develop.openshift.techgap.it' -H 'sec-fetch-site:same-site' -H 'sec-fetch-mode:cors' -H 'sec-fetch-dest:empty' -H 'referer:https://edutelling-app-develop.openshift.techgap.it/' -H 'if-none-match:W/"837-HakEFZEWDaF6n7swn4jHVp/2fX0"' --compressed SMKTEST_ASSERT_NUMBER_OF_DEPENDENCIES_EXITED: 2 SMKTEST_ASSERT_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_NETWORK_FROM_SERVICE: 'edutelling-api' SMKTEST_CHECK_SWAGGER_PUBLIC_APIS: 'https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/' SMKTEST_SWAGGER_LOGIN_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_SWAGGER_APIS: https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/ script: - create-smktest only: - production # allow_failure: true #If fail using waring signal pushDockerHub: image: docker:latest stage: docker-hub services: - docker:dind before_script: - echo $DOCKER_USER - echo $DOCKER_TOKEN - docker login -u $DOCKER_USER -p $DOCKER_TOKEN script: - docker build --pull -t "smktesting/smoke-master:$CI_VERSION" . - docker push "smktesting/smoke-master:$CI_VERSION" - docker build --pull -t "smktesting/smoke-master:latest" . - docker push "smktesting/smoke-master:latest" only: - production checkDockerImage: image: smktesting/smoke-master:latest stage: testDockerHub variables: # Config params: ------- SMKTEST_CONTEXT: 'kubernetes' SMKTEST_PROJECT_NAME: 'edutelling-develop' SMKTEST_ENVIRONMENT: 'develop' SMKTEST_NAMESPACE: 'edutelling-develop' # Apply Test. SMKTEST_CHECK_IF_ALL_PODS_ARE_ACTIVE: 'true' SMKTEST_CHECK_INGRESS: 'true' SMKTEST_CHECK_CONDITIONS: 'true' SMKTEST_CHECK_LOGS: 'true' SMKTEST_CHECK_VOLUME: 'true' # SMKTEST_CURL_LOGIN: curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept:application/json" -H "Content-Type:application/json" -d "{ \"email\":\"formazione@edutelling.it\", \"password\":\"Passw0rd\", \"stayLogged\":false }" SMKTEST_CURL_DEPENDENCIES: curl 'https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/user' -H 'authority:edutelling-api-develop.openshift.techgap.it' -H 'sec-ch-ua:" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' -H 'accept:application/json, text/plain, */*' -H 'authorization:Bearer $SMKTEST_CURL_LOGIN' -H 'accept-language:it' -H 'sec-ch-ua-mobile:?0' -H 'user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36' -H 'origin:https://edutelling-app-develop.openshift.techgap.it' -H 'sec-fetch-site:same-site' -H 'sec-fetch-mode:cors' -H 'sec-fetch-dest:empty' -H 'referer:https://edutelling-app-develop.openshift.techgap.it/' -H 'if-none-match:W/"837-HakEFZEWDaF6n7swn4jHVp/2fX0"' --compressed SMKTEST_ASSERT_NUMBER_OF_DEPENDENCIES_EXITED: 2 SMKTEST_ASSERT_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_NETWORK_FROM_SERVICE: 'edutelling-api' SMKTEST_CHECK_SWAGGER_PUBLIC_APIS: 'https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/' SMKTEST_SWAGGER_LOGIN_CURL: 'curl -X POST "https://edutelling-api-develop.openshift.techgap.it/api/v1/auth/authentication" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"formazione@edutelling.it\", \"password\": \"Passw0rd\", \"stayLogged\": false }"' SMKTEST_CHECK_SWAGGER_APIS: https://edutelling-api-develop.openshift.techgap.it/api/v1/api-docs/ before_script: # Create cluster remote configuration file. - echo $KUBERNETES_TOKEN | base64 -d > /etc/deploy/config script: - create-smktest only: - production