-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
242 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!groovy | ||
|
||
// https://github.com/feedhenry/fh-pipeline-library | ||
@Library('fh-pipeline-library') _ | ||
|
||
def repositoryName = "unifiedpush-apb" | ||
def projectName = "test-${repositoryName}-${currentBuild.number}-${currentBuild.startTimeInMillis}" | ||
|
||
stage('Trust') { | ||
enforceTrustedApproval('aerogear') | ||
} | ||
|
||
node ("ocp-slave") { | ||
stage('Cleanup') { | ||
deleteDir() | ||
} | ||
stage('Cloning the repo') { | ||
checkout scm | ||
} | ||
|
||
try { | ||
|
||
stage('Create OpenShift project') { | ||
sh script: "oc new-project ${projectName}" | ||
} | ||
stage('Build APB') { | ||
try { | ||
timeout(5) { | ||
sh script: """ | ||
oc new-build --name ${repositoryName} --binary | ||
oc start-build ${repositoryName} --from-dir=. | ||
sleep 10 | ||
oc logs -f bc/${repositoryName} | ||
""" | ||
} | ||
} catch (Exception e) { | ||
error "Build timed out" | ||
} | ||
|
||
} | ||
|
||
stage('Add admin policy to serviceaccount "default"') { | ||
sh script: "oc policy add-role-to-user admin --serviceaccount=default" | ||
} | ||
|
||
stage('Test APB') { | ||
try { | ||
timeout(15) { | ||
sh script: """ | ||
oc run testing-pod \ | ||
--image=docker-registry.default.svc:5000/${projectName}/${repositoryName} \ | ||
--restart=Never \ | ||
--env POD_NAME=testing-pod \ | ||
--env POD_NAMESPACE=${projectName} \ | ||
--command -- \ | ||
entrypoint.sh test --extra-vars '{\"namespace\": \"${projectName}\"}' | ||
sleep 10 | ||
oc logs --pod-running-timeout=20s -f pod/testing-pod | ||
# Check if the status of testing-pod is error | ||
if [ \$(oc get pods | grep testing-pod | awk '{print \$3}') == "Error" ] ; then exit 1 ; fi | ||
""" | ||
} | ||
} catch (Exception e) { | ||
error "Pod didn't finish in time." | ||
} | ||
} | ||
stage('Delete OpenShift project') { | ||
sh script: "oc delete project ${projectName}" | ||
} | ||
} catch (Exception e) { | ||
try { | ||
timeout(15) { | ||
input message: 'The test failed. Click on "Approve" to delete the project. Otherwise it will be deleted after 15 minutes' | ||
} | ||
} catch (Exception e2) { | ||
println("Waiting for a user input exceeded its time limit. Deleting the project now.") | ||
} | ||
|
||
sh script: "oc delete project ${projectName}" | ||
error "Error when running the test: ${e}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Test unifiedpush-apb | ||
hosts: localhost | ||
gather_facts: false | ||
connection: local | ||
vars_files: | ||
- /opt/ansible/vars/main.yml | ||
|
||
roles: | ||
- role: ansible.kubernetes-modules | ||
install_python_requirements: no | ||
- role: ansibleplaybookbundle.asb-modules | ||
post_tasks: | ||
- name: Load default variables for testing | ||
include_vars: test_defaults.yml | ||
- name: create project for namespace | ||
openshift_v1_project: | ||
name: '{{ namespace }}' | ||
- name: Run the provision role. | ||
include_role: | ||
name: provision-unifiedpush-apb | ||
- name: Run the test role. | ||
include_role: | ||
name: test-provision-unifiedpush-apb | ||
- name: Run the deprovision role. | ||
include_role: | ||
name: deprovision-unifiedpush-apb | ||
- name: Run the deprovision test role. | ||
include_role: | ||
name: test-deprovision-unifiedpush-apb |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
|
||
# Instead of testing that the deployment config is removed, we test that the pods | ||
# are cleaned up afterwards | ||
- name: Check that all pods have been removed | ||
shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig in ({{ postgres_deploymentconfig_name }}, {{ ups_deploymentconfig_name }})" 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"No resources found." not in result.stdout' | ||
until: '"No resources found." in result.stdout' | ||
|
||
- name: Check that the ups route has been removed | ||
shell: oc get route --namespace={{ namespace }} {{ ups_route_name }} 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"not found" not in result.stdout' | ||
until: '"not found" in result.stdout' | ||
|
||
- name: Check that all services have been removed | ||
shell: oc get service --namespace={{ namespace }} {{ item }} 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"not found" not in result.stdout' | ||
until: '"not found" in result.stdout' | ||
with_items: | ||
- '{{ postgres_service_name}}' | ||
- '{{ ups_service_name}}' | ||
- '{{ ups_proxy_service_name}}' | ||
|
||
- name: Check that all secrets have been removed | ||
shell: oc get secret --namespace={{ namespace }} {{ ups_secret_name }} 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"not found" not in result.stdout' | ||
until: '"not found" in result.stdout' | ||
|
||
- name: Check that all persistent volume claims have been removed | ||
shell: oc get pvc --namespace={{ namespace }} {{ postgres_pvc_name }} 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"not found" not in result.stdout' | ||
until: '"not found" in result.stdout' | ||
|
||
- name: Check that the service account has been removed | ||
shell: oc get serviceaccount --namespace={{ namespace }} {{ proxy_serviceaccount_name }} 2>&1 | ||
register: result | ||
retries: 50 | ||
delay: 10 | ||
failed_when: | ||
- '"not found" not in result.stdout' | ||
until: '"not found" in result.stdout' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- name: Check that the unifiedpush login webpage is accessible | ||
uri: | ||
url: "https://{{ ups_route.route.spec.host }}" | ||
return_content: yes | ||
validate_certs: no | ||
register: webpage | ||
retries: 10 | ||
delay: 20 | ||
failed_when: | ||
- webpage.status == 403 | ||
- '"Log in with OpenShift" not in webpage.content' | ||
until: '"Log in with OpenShift" in webpage.content' | ||
|
||
- name: "Check that new application was created for the namespace {{ namespace }}" | ||
uri: | ||
method: GET | ||
url: "http://{{ unifiedpush_service.service.spec.cluster_ip }}/rest/applications" | ||
return_content: yes | ||
validate_certs: no | ||
register: applications | ||
failed_when: applications.json[0].name != "{{ namespace }}" |
Oops, something went wrong.