-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PR tester for tackle ui tests (#709)
Signed-off-by: M Sajid Mansoori <[email protected]>
- Loading branch information
1 parent
b868f5e
commit 31aa9e9
Showing
1 changed file
with
131 additions
and
0 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,131 @@ | ||
@Library('migrationqe-automation-lib') _ | ||
def getChangedFilesList() { | ||
ArrayList<String> changedFiles = new ArrayList<String>() | ||
changedFiles = sh(script:"git diff \$(git merge-base origin/main HEAD) HEAD --name-only", | ||
returnStdout:true).split('\n') | ||
return changedFiles | ||
} | ||
|
||
pipeline{ | ||
agent { | ||
label 'minikube-node' | ||
} | ||
options{ | ||
ansiColor('xterm') | ||
} | ||
environment{ | ||
REQUESTS_CA_BUNDLE="/etc/pki/tls/certs/ca-bundle.crt" | ||
username="admin" | ||
password="Dog8code" | ||
TACKLE_GIT_CREDS = credentials('tackle_git_pass') | ||
TACKLE_GIT_KEY = credentials('tackle_git_gpg_key') | ||
cypress_jira_atlassian_cloud_url="https://mta-qe-testing.atlassian.net/" | ||
cypress_jira_atlassian_cloud_email="[email protected]" | ||
cypress_jira_stage_datacenter_url="https://issues.stage.redhat.com" | ||
cypress_jira_stage_bearer_token= credentials('mta_jira_stage_token') | ||
cypress_jira_atlassian_cloud_token= credentials('mta_jira_cloud_token') | ||
cypress_jira_stage_basic_login="mta-qe" | ||
cypress_jira_stage_basic_password="Mta.qe.testing" | ||
cypress_jira_atlassian_cloud_project="mta_integration" | ||
} | ||
stages{ | ||
stage("Check if their are changed tests"){ | ||
when{ | ||
allOf{ | ||
branch pattern: '^PR-.*$', | ||
comparator: 'REGEXP'; | ||
expression{ | ||
getChangedFilesList().any { it=~ /^.*e2e\/tests\/.*test.ts$/} == true | ||
} | ||
} | ||
} | ||
steps{ | ||
script{ | ||
checkout scm | ||
env.RUN_TESTS = "true" | ||
changed_test_list = [] | ||
getChangedFilesList().each{ | ||
i -> | ||
if(i.contains("test.ts")){ | ||
changed_test_list.add(i) | ||
} | ||
} | ||
env.CHANGED_TEST_FILES = changed_test_list.join(" ") | ||
sh "echo $CHANGED_TEST_FILES" | ||
} | ||
} | ||
} | ||
stage('Install & run minikube'){ | ||
when { | ||
expression{ | ||
env.RUN_TESTS == "true" | ||
} | ||
} | ||
steps{ | ||
script{ | ||
|
||
sh """ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | ||
chmod +x minikube | ||
minikube_homedir=/usr/local/bin/ | ||
|
||
sudo install minikube /usr/local/bin | ||
|
||
minikube delete | ||
sleep 20s | ||
minikube start --driver=podman --memory=4g | ||
minikube addons enable dashboard | ||
minikube addons enable ingress | ||
minikube addons enable olm | ||
kubectl apply -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/crds.yaml | ||
kubectl apply -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml | ||
|
||
kubectl apply -f https://raw.githubusercontent.com/konveyor/tackle2-operator/main/tackle-k8s.yaml | ||
|
||
while [ \$(kubectl get crd|grep tackle|wc -l) != 2 ] | ||
do echo "Waiting for Tackle CRDs..." | ||
sleep 5s | ||
done | ||
|
||
""" | ||
|
||
echo "Applying tackle CR" | ||
tackle.applyTackleCR() //Tackle CR will be applied with using default password `Passw0rd!`. | ||
|
||
} | ||
} | ||
} | ||
stage('Run tackle ui tests'){ | ||
when { | ||
expression{ | ||
env.RUN_TESTS == "true" | ||
} | ||
} | ||
steps{ | ||
script{ | ||
env.TACKLE_URL = "http://"+sh( | ||
script : 'minikube ip', | ||
returnStdout: true | ||
).trim() | ||
|
||
ocp.pollRouteUntilReady(env.TACKLE_URL,15,30) | ||
sh "sleep 40s" //Grace period after the application is serving correctly. | ||
sh( | ||
script: "npm install", | ||
label: "Install dependencies..." | ||
) | ||
//Run the tests. | ||
sh """ | ||
npx cypress run --spec $CHANGED_TEST_FILES --env user=$username,pass=$password,tackleUrl=$TACKLE_URL,git_user=$TACKLE_GIT_CREDS_USR,git_password=$TACKLE_GIT_CREDS_PSW,git_key='$TACKLE_GIT_KEY' | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
post{ | ||
always{ | ||
script{ | ||
cleanWs() | ||
} | ||
} | ||
} | ||
} |