Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 2 additions & 6 deletions actions/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/rancher/shepherd/extensions/cloudcredentials"
"github.com/rancher/shepherd/extensions/cloudcredentials/vsphere"
"github.com/rancher/shepherd/extensions/harvester"
"github.com/rancher/tests/actions/clusters"
"github.com/rancher/tests/actions/provisioninginput"
"github.com/rancher/tests/actions/secrets"
Expand Down Expand Up @@ -108,13 +107,10 @@ func CreateCloudProviderAddOns(client *rancher.Client, clustersConfig *clusters.
}

case provisioninginput.HarvesterProviderName.String():
kubeconfig, err := harvester.GetHarvesterSAKubeconfig(client, additionalData["clusterName"].(string))
if err != nil {
return clustersConfig, err
}


data := map[string][]byte{
"credential": kubeconfig,
"credential": []byte(credentials.HarvesterCredentialConfig.KubeconfigContent),
}

annotations := map[string]string{
Expand Down
102 changes: 67 additions & 35 deletions validation/pipeline/tfp/Jenkinsfile.harvester.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,9 @@ node("harvester-vpn-1") {
]) {
withEnv(paramsMap) {
stage('Setup Harvester Environment') {
sh returnStdout: true, script: 'wget -qO ./jq https://github.com/jqlang/jq/releases/latest/download/jq-linux-amd64'
sh returnStdout: true, script: 'chmod a+x ./jq'
sh returnStdout: true, script: 'sudo cp jq /usr/local/bin/'
sh returnStdout: true, script: 'wget -qO yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64'
sh returnStdout: true, script: 'chmod a+x yq'
sh returnStdout: true, script: 'sudo cp yq /usr/local/bin/'
sh returnStdout: true, script: 'wget -qO ./kubectl "https://dl.k8s.io/release/\$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"'
sh returnStdout: true, script: 'chmod a+x ./kubectl'
sh returnStdout: true, script: 'sudo cp kubectl /usr/local/bin/'
// TODO: don't think I need this
dir(".ssh") {
def decoded = new String(env.AWS_SSH_PEM_KEY.decodeBase64())
writeFile file: AWS_SSH_KEY_NAME, text: decoded
Expand All @@ -95,11 +88,15 @@ node("harvester-vpn-1") {
export inode="${EXISTING_HARVESTER_IP}"
if [[ -z "$EXISTING_HARVESTER_IP" ]]; then
export KUBECONFIG=seeder.yaml
export inode=$(./kubectl get -n tink-system inventories/$HARVESTER_INVENTORY_NODE -o jsonpath='{.status.pxeBootConfig.address}')
./kubectl delete clusters.metal/$HARVESTER_CLUSTER_NAME -n tink-system || true
sleep 300
while ping -c 1 "$HOST" >/dev/null 2>&1; do
sleep 5
done
sleep 180

./kubectl apply -f node_manifest.yaml

export inode=""
while [[ -z "$inode" ]]; do
export inode=$(./kubectl get -n tink-system inventories/$HARVESTER_INVENTORY_NODE -o jsonpath='{.status.pxeBootConfig.address}')
sleep 2
Expand Down Expand Up @@ -183,8 +180,12 @@ node("harvester-vpn-1") {
echo $jsonOutput

token=$(echo $jsonOutput | jq -cr .token)
userID=$(echo $jsonOutput | jq -cr .userId)

jsonOutput=$(curl --insecure -X GET -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" "https://$inode/v3/users?me=true")

echo $jsonOutput

userID=$(echo $jsonOutput | jq -cr .data[0].id)

jsonData=$( jq -n --arg password "password1234" '{"newPassword" : $password}')

Expand Down Expand Up @@ -219,6 +220,10 @@ node("harvester-vpn-1") {
sh returnStdout: true, script: "echo 'finished'"

config = sh(script: "cat ${filename}", returnStdout: true).trim()

sh '''#!/bin/bash
cat config.yml
'''
}
stage("Parallel Checkout") {
parallel(
Expand Down Expand Up @@ -266,6 +271,9 @@ node("harvester-vpn-1") {
returnStdout: true
).trim()

dir("infra-repo/ansible/k3s/default/roles/k3s_install/tasks/") {
writeFile file: "k3s_registry.yaml", text: env.INTERNAL_MIRROR_CONFIG
}
if (!exists) {
sh "ln -s test-repo tests"
sh "ln -s infra-repo qa-infra-automation"
Expand Down Expand Up @@ -319,8 +327,8 @@ node("harvester-vpn-1") {
docker cp config.yml ${testContainer}-dev:/root/go/src/github.com/rancher/qa-infra-automation/config.yml
docker cp harvester.yaml ${testContainer}-dev:/root/go/src/github.com/rancher/qa-infra-automation/tofu/harvester/modules/local.yaml
"""

}

stage('Install Rancher') {
dir("infra-repo") {
try {
Expand Down Expand Up @@ -361,7 +369,6 @@ node("harvester-vpn-1") {
'
"""


env.CATTLE_TEST_CONFIG ="/root/go/src/github.com/rancher/qa-infra-automation/config.yml"
} catch (err) {
sh "docker stop ${testContainer} || true; docker rm ${testContainer}"
Expand Down Expand Up @@ -425,7 +432,6 @@ echo "}\\n" >> "${tfvars_filepath}"

# echo "\\nEOF\\n}\\n" >> "${tfvars_filepath}"
"""

// run the test with tofu
sh """

Expand All @@ -437,40 +443,66 @@ echo "}\\n" >> "${tfvars_filepath}"
. /root/playbook.env
. ./validation/pipeline/scripts/register_downstream_cluster.sh
'

docker cp ${testContainer}-ds:/root/go/src/github.com/rancher/qa-infra-automation/config.yml mid_config.yml

docker stop ${testContainer}-ds || true; docker rm ${testContainer}-ds
sleep 90
"""
}
}
}
stage('Run Validation Tests') {

if (env.CONNECT_HARVESTER_AND_RANCHER == "true") {
try {
sh """
docker run -v ${validationVolume}:/root --name ${golangTestContainer} -t ${imageName}${TOFU_VERSION}${HARVESTER_PROVIDER_VERSION}${RANCHER2_PROVIDER_VERSION}-${commitIDTest}:${commitIDInfra} sh -c "cp \$CATTLE_TEST_CONFIG . && export CATTLE_TEST_CONFIG=/root/go/src/github.com/rancher/tests/config.yml && /root/go/bin/gotestsum --format standard-verbose --packages=${golangTestDir} --junitfile ${testResultsOut} -- -tags=${TAGS} ${GO_TEST_CASE} -timeout=${timeout} -v ;"
"""

jobs = [:]
dir("infra-repo") {
def mainRancherConfigPath = "mid_config.yml"

sh "yq e '.rancher.cleanup = true' -i ${mainRancherConfigPath}"


def configYaml = readFile(file: "${mainRancherConfigPath}")

def goProvisioningParams = [
string(name: 'TIMEOUT', value: timeout),
text(name: 'CONFIG', value: configYaml),
string(name: 'REPO', value: "${env.TEST_REPO}"),
string(name: 'BRANCH', value: "${testBranch}"),
// string(name: 'QASE_TEST_RUN_ID', value: "${testRunID}"),
string(name: 'TEST_PACKAGE', value: "${env.GO_TEST_PACKAGE}"),
string(name: 'GOTEST_TESTCASE', value: "${env.GO_TEST_CASE}"),
string(name: 'TAGS', value: "${env.TAGS}"),
]
def individualJob = "go-freeform-job-harvester"
jobs["test-pit"] = { build job: individualJob, parameters: goProvisioningParams }
parallel jobs
}

} catch (err) {
echo "${err} Test had failures.."
}

sh "docker cp ${golangTestContainer}:/root/go/src/github.com/rancher/tests/config.yml final_config.yml"

def r_host = sh (
script: "yq '.rancher.host' final_config.yml",
returnStdout: true
).trim()

def r_pass = sh (
script: "yq '.rancher.adminPassword' final_config.yml",
returnStdout: true
).trim()

def h_host = sh (
script: "yq '.harvester.host' final_config.yml",
returnStdout: true
).trim()

currentBuild.description = "https://${r_host}\\n${r_pass}\\nhttps://${h_host}\\n"
dir("infra-repo") {
def r_host = sh (
script: "yq '.rancher.host' mid_config.yml",
returnStdout: true
).trim()

def r_pass = sh (
script: "yq '.rancher.adminPassword' mid_config.yml",
returnStdout: true
).trim()

def h_host = sh (
script: "yq '.harvester.host' mid_config.yml",
returnStdout: true
).trim()

currentBuild.description = "https://${r_host}<br>${r_pass}<br>https://${h_host}"
}


sh """
docker stop ${golangTestContainer} || true
Expand Down