From 5b3161d0bf89b2bb6ece7f6cb9cd7a294d7b66df Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 13 Jun 2018 18:26:21 +0200 Subject: [PATCH] added tests --- cucumber-selenium-grid/Jenkinsfile | 24 +++ cucumber-selenium-grid/README1.md | 20 ++- .../applier/params/build-dev | 2 +- .../applier/params/deployment-dev | 8 +- .../applier/params/deployment-prod | 8 +- .../applier/params/deployment-stage | 8 +- .../applier/templates/deployment.yml | 39 +---- .../applier/templates/selenium-grid.yaml | 157 ++++++++++++++++++ 8 files changed, 218 insertions(+), 48 deletions(-) create mode 100644 cucumber-selenium-grid/applier/templates/selenium-grid.yaml diff --git a/cucumber-selenium-grid/Jenkinsfile b/cucumber-selenium-grid/Jenkinsfile index 5ecd12cb..1eebb003 100644 --- a/cucumber-selenium-grid/Jenkinsfile +++ b/cucumber-selenium-grid/Jenkinsfile @@ -119,6 +119,30 @@ pipeline { } } } + + stage ('Run integration tests') { + steps { + sh ${CONTEXT_DIR}/integration-tests + sh "/bin/bash -c 'npm install'" + sh "/bin/bash -c 'node ./node_modules/protractor/bin/protractor protractor-conf.js'" +// script { +// archive (includes: 'pkg/*.gem') +// publishHTML (target: [ +// allowMissing: false, +// alwaysLinkToLastBuild: false, +// keepAll: true, +// reportDir: 'coverage', +// reportFiles: 'index.html', +// reportName: "RCov Report" +// ]) +// } + } + + } + + + + stage('Promote from Stage to Prod') { steps { script { diff --git a/cucumber-selenium-grid/README1.md b/cucumber-selenium-grid/README1.md index c0707a2e..1a128414 100644 --- a/cucumber-selenium-grid/README1.md +++ b/cucumber-selenium-grid/README1.md @@ -2,4 +2,22 @@ oc new-project selenium oc new-app registry.access.redhat.com/rhoar-nodejs/nodejs-8~https://github.com/raffaelespazzoli/todomvc --context-dir examples/angularjs --name todomvc oc new-build --strategy=docker --name=jenkins-slave-nodejs8 -oc start-build -F jenkins-slave-protractor --from-dir=. \ No newline at end of file +oc start-build -F jenkins-slave-protractor --from-dir=. + + +setup +oc process -f applier/projects/projects.yml | oc apply -f - +oc process openshift//jenkins-ephemeral | oc apply -f- -n todomvc-build +oc new-build --strategy docker --name jenkins-slave-nodejs8 --context-dir cucumber-selenium-grid/nodejs-slave https://github.com/raffaelespazzoli/container-pipelines#selenium -n todomvc-build +oc process -f applier/templates/deployment.yml --param-file=applier/params/deployment-dev | oc apply -f- +oc process -f applier/templates/deployment.yml --param-file=applier/params/deployment-stage | oc apply -f- +oc process -f applier/templates/deployment.yml --param-file=applier/params/deployment-prod | oc apply -f- +oc process -f applier/templates/build.yml --param-file applier/params/build-dev | oc apply -f- +oc adm policy add-scc-to-user anyuid -z zalenium -n todomvc-stage +oc process -f applier/templates/selenium-grid.yaml NAMESPACE=todomvc-stage | oc apply -f - +oc adm policy add-cluster-role-to-user zalenium-role -z zalenium -n todomvc-stage + +oc delete project todomvc-build +oc delete project todomvc-dev +oc delete project todomvc-stage +oc delete project todomvc-prod \ No newline at end of file diff --git a/cucumber-selenium-grid/applier/params/build-dev b/cucumber-selenium-grid/applier/params/build-dev index 8a345355..05e6b4ed 100644 --- a/cucumber-selenium-grid/applier/params/build-dev +++ b/cucumber-selenium-grid/applier/params/build-dev @@ -1,4 +1,4 @@ -APPLICATION_NAME=todo-mvc +APPLICATION_NAME=todomvc NAMESPACE=todomvc-build SOURCE_REPOSITORY_URL=https://github.com/raffaelespazzoli/container-pipelines SOURCE_REPOSITORY_REF=selenium diff --git a/cucumber-selenium-grid/applier/params/deployment-dev b/cucumber-selenium-grid/applier/params/deployment-dev index 441eebe9..1f8581f8 100644 --- a/cucumber-selenium-grid/applier/params/deployment-dev +++ b/cucumber-selenium-grid/applier/params/deployment-dev @@ -1,5 +1,3 @@ -APPLICATION_NAME=spring-rest -NAMESPACE=basic-spring-boot-dev -SA_NAMESPACE=basic-spring-boot-build -READINESS_RESPONSE=status.:.UP -READINESS_PATH=/health +APPLICATION_NAME=todomvc +NAMESPACE=todomvc-dev +SA_NAMESPACE=todomvc-build diff --git a/cucumber-selenium-grid/applier/params/deployment-prod b/cucumber-selenium-grid/applier/params/deployment-prod index e09e4dda..8c81f60a 100644 --- a/cucumber-selenium-grid/applier/params/deployment-prod +++ b/cucumber-selenium-grid/applier/params/deployment-prod @@ -1,5 +1,3 @@ -APPLICATION_NAME=spring-rest -NAMESPACE=basic-spring-boot-prod -SA_NAMESPACE=basic-spring-boot-build -READINESS_RESPONSE=status.:.UP -READINESS_PATH=/health +APPLICATION_NAME=todomvc +NAMESPACE=todomvc-prod +SA_NAMESPACE=todomvc-build diff --git a/cucumber-selenium-grid/applier/params/deployment-stage b/cucumber-selenium-grid/applier/params/deployment-stage index d0c280ad..67b629f5 100644 --- a/cucumber-selenium-grid/applier/params/deployment-stage +++ b/cucumber-selenium-grid/applier/params/deployment-stage @@ -1,6 +1,4 @@ -APPLICATION_NAME=spring-rest -NAMESPACE=basic-spring-boot-stage +APPLICATION_NAME=todomvc +NAMESPACE=todomvc-stage SA_NAME=jenkins -SA_NAMESPACE=basic-spring-boot-build -READINESS_RESPONSE=status.:.UP -READINESS_PATH=/health +SA_NAMESPACE=todomvc-build diff --git a/cucumber-selenium-grid/applier/templates/deployment.yml b/cucumber-selenium-grid/applier/templates/deployment.yml index b981ae5c..b2bb58d4 100644 --- a/cucumber-selenium-grid/applier/templates/deployment.yml +++ b/cucumber-selenium-grid/applier/templates/deployment.yml @@ -1,14 +1,14 @@ apiVersion: v1 kind: Template labels: - template: basic-spring-boot + template: basic-nodejs metadata: annotations: - description: Application template for JWS applications built using a Jenkins Pipeline - iconClass: icon-tomcat - tags: java,spring + description: Application template for nodejs built using a Jenkins Pipeline + iconClass: icon-nodejs + tags: javascript,nodejs version: 1.2.0 - name: basic-sprint-boot + name: basic-nodejs objects: - apiVersion: v1 kind: Service @@ -67,28 +67,13 @@ objects: name: ${APPLICATION_NAME} spec: containers: - - env: - - name: JWS_ADMIN_USERNAME - value: ${JWS_ADMIN_USERNAME} - - name: JWS_ADMIN_PASSWORD - value: ${JWS_ADMIN_PASSWORD} - image: ${APPLICATION_NAME} + - image: ${APPLICATION_NAME} imagePullPolicy: Always name: ${APPLICATION_NAME} ports: - - containerPort: 8778 - name: jolokia - protocol: TCP - containerPort: 8080 name: http protocol: TCP - readinessProbe: - exec: - command: - - /bin/bash - - -c - - curl -s 'http://localhost:8080${READINESS_PATH}' - |grep -iq '${READINESS_RESPONSE}' terminationGracePeriodSeconds: 60 triggers: - imageChangeParams: @@ -106,7 +91,7 @@ objects: metadata: creationTimestamp: null labels: - template: basic-tomcat-template + template: basic-nodejs name: jenkins_edit namespace: ${NAMESPACE} roleRef: @@ -121,7 +106,7 @@ parameters: - description: The name for the application. name: APPLICATION_NAME required: true - value: jws-app + value: nodejs - description: The namespace to deploy into name: NAMESPACE required: true @@ -135,11 +120,3 @@ parameters: - description: 'Custom hostname for http service route. Leave blank for default hostname, e.g.: -.' name: HOSTNAME_HTTP -- description: 'URI to check for app health' - name: READINESS_PATH - required: true - value: '/' -- description: 'String value expected back from readiness check' - name: READINESS_RESPONSE - required: true - value: 'Hello World!' diff --git a/cucumber-selenium-grid/applier/templates/selenium-grid.yaml b/cucumber-selenium-grid/applier/templates/selenium-grid.yaml new file mode 100644 index 00000000..2759039e --- /dev/null +++ b/cucumber-selenium-grid/applier/templates/selenium-grid.yaml @@ -0,0 +1,157 @@ +apiVersion: v1 +kind: Template +labels: + template: zalenium +metadata: + annotations: + description: zalenium deployment + tags: selenium,selenium-grid,zalenium + name: zalenium +objects: +- apiVersion: v1 + kind: ClusterRole + metadata: + name: zalenium-role + namespace: ${NAMESPACE} + rules: + - verbs: ['create','list','get','delete','exec'] + resources: ['pods'] + - verbs: ['list', 'create', 'delete', 'get'] + resources: ['services'] + - verbs: ['create', 'get'] + resources: ['pod/exec'] + +- apiVersion: v1 + kind: ServiceAccount + metadata: + name: zalenium + namespace: ${NAMESPACE} + +- apiVersion: rbac.authorization.k8s.io/v1beta1 + kind: ClusterRoleBinding + metadata: + name: zalenium-role-zalenium-binding + namespace: ${NAMESPACE} + roleRef: + kind: ClusterRole + name: zalenium-role + subjects: + kind: ServiceAccount + name: zalenium + namespace: ${NAMESPACE} + +- apiVersion: v1 + kind: Service + metadata: + labels: + app: zalenium + name: zalenium + namespace: ${NAMESPACE} + spec: + ports: + - name: zalenium + port: 4444 + protocol: TCP + targetPort: 4444 + selector: + app: zalenium + role: grid + type: ClusterIP +- apiVersion: extensions/v1beta1 + kind: Deployment + metadata: + name: zalenium + namespace: ${NAMESPACE} + spec: + replicas: 1 + template: + metadata: + labels: + app: zalenium + role: grid + spec: + # Added to test manually https://github.com/zalando/zalenium/issues/246 + hostAliases: + - ip: "127.0.0.1" + hostnames: + - "foo.local" + - "bar.local" + containers: + - name: zalenium + image: dosel/zalenium:latest + args: + - start + - '--desiredContainers' + - '2' + - '--screenWidth' + - '1440' + - '--screenHeight' + - '810' + - '--seleniumImageName' + - 'elgalu/selenium' + - '--maxTestSessions' + - '4' + env: + - name: ZALENIUM_KUBERNETES_CPU_REQUEST + value: 250m + - name: ZALENIUM_KUBERNETES_CPU_LIMIT + value: 500m + - name: ZALENIUM_KUBERNETES_MEMORY_REQUEST + value: 500Mi + - name: ZALENIUM_KUBERNETES_MEMORY_LIMIT + value: 1Gi + - name: OVERRIDE_WAIT_TIME + value: 5m + resources: + requests: + cpu: 250m + memory: 400Mi + ports: + - containerPort: 4444 + protocol: TCP + volumeMounts: + - name: zalenium-data + mountPath: /home/seluser/videos + - name: zalenium-mounted + mountPath: /tmp/mounted + volumes: + - name: zalenium-data + persistentVolumeClaim: + claimName: zalenium-data + - name: zalenium-mounted + persistentVolumeClaim: + claimName: zalenium-mounted + serviceAccountName: zalenium + serviceAccount: zalenium +- apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: zalenium-mounted + namespace: ${NAMESPACE} + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi + storageClassName: local-pod +- apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: zalenium-data + namespace: ${NAMESPACE} + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi +parameters: +- description: The namespace to deploy into + name: NAMESPACE + required: true + + + + +