Skip to content

Commit

Permalink
feat: use windows images from artifactory
Browse files Browse the repository at this point in the history
these images will be periodically updated

Signed-off-by: Karel Simon <[email protected]>
  • Loading branch information
ksimon1 committed Oct 22, 2024
1 parent 0ed6686 commit 637864d
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 59 deletions.
102 changes: 51 additions & 51 deletions automation/test-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,67 @@ namespace="kubevirt"
template_name="windows2k22"
username="Administrator"

if [[ $TARGET =~ windows10.* ]]; then
template_name="windows10"
workloads=("desktop")
elif [[ $TARGET =~ windows11.* ]]; then
template_name="windows11"
workloads=("desktop")
elif [[ $TARGET =~ windows2016.* ]]; then
template_name="windows2k16"
elif [[ $TARGET =~ windows2019.* ]]; then
template_name="windows2k19"
elif [[ $TARGET =~ windows2022.* ]]; then
template_name="windows2k22"
elif [[ $TARGET =~ windows2025.* ]]; then
template_name="windows2k25"
fi

dv_name="${TARGET}-datavolume-original"
version=$(oc version -o json | jq -r '.openshiftVersion | split("\\."; null)[:2]|join(".")')

oc apply -n ${namespace} -f - <<EOF
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
annotations:
cdi.kubevirt.io/storage.bind.immediate.requested: "true"
name: ${dv_name}
spec:
source:
registry:
secretRef: common-templates-container-disk-puller
url: "docker://quay.io/openshift-cnv/ci-common-templates-images:${TARGET}"
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 60Gi
EOF

oc apply -f - <<EOF
lookupPolicy:
local: false
tags:
- from:
kind: DockerImage
name: cnv-qe-artifactory.apps.ocp-virt.prod.psi.redhat.com/docker/kubevirt-common-instancetypes/${template_name}-container-disk:${version}
name: "${version}"
referencePolicy:
type: Source
---
apiVersion: v1
kind: Pod
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataImportCron
metadata:
name: winrmcli
namespace: kubevirt
annotations:
"cdi.kubevirt.io/storage.bind.immediate.requested": "true"
name: ${dv_name}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- image: quay.io/kubevirt/winrmcli
command: ["/bin/sh","-c"]
args: [ "sleep 3000"]
imagePullPolicy: Always
name: winrmcli
restartPolicy: Always
---
template:
spec:
source:
registry:
registry:
imageStream: ${dv_name}
pullMethod: node
storage:
resources:
requests:
storage: 25Gi
schedule: "46 10/12 * * *"
garbageCollect: Outdated
importsToKeep: 2
managedDataSource: ${dv_name}
EOF

sleep 30 #wait until DIC create DV

timeout=2000
hour_timeout=3600
sample=10
Expand All @@ -68,27 +86,9 @@ spec:
namespace: ${namespace}
EOF

# Make sure winrmcli pod is ready
oc wait --for=condition=Ready --timeout=${timeout}s pod/winrmcli -n $namespace

sizes=("medium" "large")
workloads=("server" "highperformance")

if [[ $TARGET =~ windows10.* ]]; then
template_name="windows10"
workloads=("desktop")
elif [[ $TARGET =~ windows11.* ]]; then
template_name="windows11"
username="Administrator11"
workloads=("desktop")
elif [[ $TARGET =~ windows2016.* ]]; then
template_name="windows2k16"
elif [[ $TARGET =~ windows2019.* ]]; then
template_name="windows2k19"
elif [[ $TARGET =~ windows2022.* ]]; then
template_name="windows2k22"
fi

delete_vm(){
vm_name=$1
set +e
Expand Down Expand Up @@ -125,7 +125,7 @@ run_vm(){

current_time=0
# run ipconfig /all command on windows vm
while [[ $(oc exec -n $namespace -i winrmcli -- ./usr/bin/winrm-cli -hostname $ipAddressVMI -port 5985 -username $username -password "Heslo123" "ipconfig /all" | grep "IPv4 Address" | wc -l ) -eq 0 ]] ; do
while [[ $(sshpass -pAdministrator ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${username}@${ipAddressVMI}" -p 33334 "echo Hello" ) ]] ; do
# VM can be stopped during test and recreated. That will change IP, so to be sure, get IP at every iteration
ipAddressVMI=$(oc get vmi $vm_name -o json -n $namespace| jq -r '.status.interfaces[0].ipAddress')
current_time=$((current_time + sample))
Expand Down
35 changes: 27 additions & 8 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ chmod +x virtctl
oc apply -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml
oc apply -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml

sample=10
current_time=0
timeout=600

# Waiting for kubevirt cr to report available
Expand All @@ -155,14 +153,17 @@ oc patch kubevirt kubevirt -n $namespace --type merge -p '{"spec":{"configuratio

key="/tmp/secrets/accessKeyId"
token="/tmp/secrets/secretKey"
caBundle="/tmp/secrets/ca-bundle"

if [ "${CLUSTERENV}" == "$ocenv" ]
then
if test -f "$key" && test -f "$token"; then
id=$(cat $key | tr -d '\n' | base64)
token=$(cat $token | tr -d '\n' | base64 | tr -d ' \n')
if test -f "$key" && test -f "$token"; then
id=$(cat ${key} | tr -d '\n')
token=$(cat ${token} | tr -d '\n')
idBase64=$(echo -n "${id}" | base64)
token64=$(echo -n "${token}" | base64)

oc apply -n $namespace -f - <<EOF
oc apply -n $namespace -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -171,10 +172,28 @@ metadata:
app: containerized-data-importer
type: Opaque
data:
accessKeyId: "${id}"
secretKey: "${token}"
accessKeyId: "${idBase64}"
secretKey: "${token64}"
EOF
if test -f "${caBundle}"; then
oc create configmap custom-ca \
--from-file=ca-bundle.crt="${caBundle}" \
-n openshift-config

oc patch proxy/cluster \
--type=merge \
--patch='{"spec":{"trustedCA":{"name":"custom-ca"}}}'

oc get secret/pull-secret -n openshift-config --template='{{index .data ".dockerconfigjson" | base64decode}}' > config.json

oc registry login --registry="cnv-qe-artifactory.apps.ocp-virt.prod.psi.redhat.com" \
--auth-basic="${id}:${token}" \
--to=config.json

oc set data secret/pull-secret -n openshift-config --from-file=.dockerconfigjson=config.json
oc wait --for=condition=Updated --timeout=900s machineconfigpool worker
fi
fi
fi
echo "Deploying CDI"
oc apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/$CDI_VERSION/cdi-operator.yaml
Expand Down

0 comments on commit 637864d

Please sign in to comment.