Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR tester for tackle ui tests #709

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions PR_TESTER.jenkinsfile
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()
}
}
}
}