Skip to content

Commit

Permalink
Fixing so that tests can be run by providing a rancher server setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sowmyav27 authored and sangeethah committed Aug 17, 2020
1 parent 1a3dc9d commit b02aec5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
38 changes: 27 additions & 11 deletions tests/validation/tests/v3_api/Jenkinsfile_deploy_and_test
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ node {

stage('Deploy Rancher Server') {
try {
if (!env.CATTLE_TEST_URL || !env.ADMIN_TOKEN || !env.USER_TOKEN ||
(env.CATTLE_TEST_URL == "" && env.ADMIN_TOKEN == "" && env.USER_TOKEN == "")) {
// deploy rancher server
sh "docker run --name ${setupContainer} -t --env-file ${envFile} " +
"${imageName} /bin/bash -c \'pytest -v -s --junit-xml=${setupResultsOut} " +
Expand All @@ -114,7 +116,13 @@ node {
sh "docker cp ${setupContainer}:${rootPath}${testsDir}${rancherConfig} ."
load rancherConfig

} catch(err) {
}
else {
echo "User Provided Rancher Server"
RANCHER_DEPLOYED = false
}
}
catch(err) {
echo "Error: " + err
RANCHER_DEPLOYED = false
}
Expand All @@ -123,12 +131,16 @@ node {
stage('Run Validation Tests') {
try {
// run tests
def clusterName="${env.RANCHER_CLUSTER_NAME}"
if (RANCHER_DEPLOYED) {
clusterName="${env.CLUSTER_NAME}"
}
sh "docker run --name ${testContainer} -t --env-file ${envFile} " +
"${imageName} /bin/bash -c \'export CATTLE_TEST_URL=${env.CATTLE_TEST_URL} " +
"&& export ADMIN_TOKEN=${env.ADMIN_TOKEN} && export USER_TOKEN=${env.USER_TOKEN} "+
"&& export RANCHER_CLUSTER_NAME=${env.CLUSTER_NAME} " + "&& pytest -v -s --junit-xml=${testResultsOut} " +
"&& export RANCHER_CLUSTER_NAME=${clusterName} " + "&& pytest -v -s --junit-xml=${testResultsOut} " +
"${PYTEST_OPTIONS} ${testsDir}\'"
} catch(err) {
} catch(err) {
echo "Error: " + err
echo 'Test run had failures. Collecting results...'
}
Expand Down Expand Up @@ -158,17 +170,21 @@ node {

stage('Test Report') {
// copy and archive test results
sh "docker cp ${setupContainer}:${rootPath}${setupResultsOut} ."
if (RANCHER_DEPLOYED) {
sh "docker cp ${setupContainer}:${rootPath}${setupResultsOut} ."
step([$class: 'JUnitResultArchiver', testResults: "**/${setupResultsOut}"])

}
sh "docker cp ${testContainer}:${rootPath}${testResultsOut} ."
step([$class: 'JUnitResultArchiver', testResults: "**/${setupResultsOut}"])
step([$class: 'JUnitResultArchiver', testResults: "**/${testResultsOut}"])
}

sh "docker stop ${setupContainer}"
sh "docker stop ${testContainer}"

sh "docker rm -v ${setupContainer}"
sh "docker rm -v ${testContainer}"
}
if (RANCHER_DEPLOYED) {
sh "docker stop ${setupContainer}"
sh "docker rm -v ${setupContainer}"
}
sh "docker stop ${testContainer}"
sh "docker rm -v ${testContainer}"

if (env.RANCHER_DELETE_SERVER.toLowerCase() == "true" && RANCHER_DEPLOYED) {
sh "docker stop ${deleteContainer}"
Expand Down
2 changes: 1 addition & 1 deletion tests/validation/tests/v3_api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ def exec_shell_command(ip, port, cmd, password, user="root", sshKey=None):

def wait_for_ns_to_become_active(client, ns, timeout=DEFAULT_TIMEOUT):
start = time.time()
time.sleep(2)
time.sleep(10)
nss = client.list_namespace(uuid=ns.uuid).data
assert len(nss) == 1
ns = nss[0]
Expand Down

0 comments on commit b02aec5

Please sign in to comment.