From 66b1a7493a906cfb2ab1fe661c1f656b4e994421 Mon Sep 17 00:00:00 2001 From: frouioui Date: Sun, 2 Feb 2025 00:04:54 +0000 Subject: [PATCH 1/7] upgrade vitess dependency to latest Signed-off-by: GitHub --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6f7dc721..88c984f7 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( sigs.k8s.io/controller-runtime v0.19.0 sigs.k8s.io/controller-tools v0.16.1 sigs.k8s.io/kustomize v2.0.3+incompatible - vitess.io/vitess v0.10.3-0.20250124174950-8412fe81d4a5 + vitess.io/vitess v0.10.3-0.20250201220950-78c7470f540e ) require ( diff --git a/go.sum b/go.sum index adda5794..53ae4498 100644 --- a/go.sum +++ b/go.sum @@ -866,5 +866,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77Vzej sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= -vitess.io/vitess v0.10.3-0.20250124174950-8412fe81d4a5 h1:zA8m6IgiK7+AfaUV+1MuXasnnUnhk4OpZNc9S6GhMIg= -vitess.io/vitess v0.10.3-0.20250124174950-8412fe81d4a5/go.mod h1:kKWkRaLpz9Dox87PUiWDS3N5oHWV/eAvNRRnalnyD88= +vitess.io/vitess v0.10.3-0.20250201220950-78c7470f540e h1:SxFz1k7oiefC2bMQ+fe/gZRFb4ZGdR4J1mwFMISScBA= +vitess.io/vitess v0.10.3-0.20250201220950-78c7470f540e/go.mod h1:kKWkRaLpz9Dox87PUiWDS3N5oHWV/eAvNRRnalnyD88= From efc5db417f1dbaecb6e2fe0741d3408c2faa256f Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 3 Feb 2025 20:39:06 -0500 Subject: [PATCH 2/7] Add propagate-uid-gid option to the buildkite workflow So that we can access files created across the host and containers throughout the test. Signed-off-by: Matt Lord --- .buildkite/pipeline.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 7786149e..82e54bc8 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -23,6 +23,7 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" @@ -42,6 +43,7 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" @@ -61,6 +63,7 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" @@ -80,6 +83,7 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" @@ -99,6 +103,7 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" @@ -118,5 +123,6 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true + propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" From 41ba00d235ea3f571321be6d2876d3aa8fadf7b8 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 3 Feb 2025 21:26:13 -0500 Subject: [PATCH 3/7] Testing... Signed-off-by: Matt Lord --- .buildkite/pipeline.yml | 110 +++------------------------------------- test/endtoend/utils.sh | 28 +++++----- 2 files changed, 19 insertions(+), 119 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 82e54bc8..901ff3a9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,35 +7,18 @@ env: # Mount the docker.sock as to the docker container, so that we are able to # run docker build command and kind is spawned as a sibling container. steps: - - name: "Upgrade Test" - command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat - - wget https://golang.org/dl/$GO_VERSION_FILE - - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - - rm $GO_VERSION_FILE - - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make upgrade-test - concurrency: 1 - concurrency_group: 'vtop/upgrade-downgrade-test' - timeout_in_minutes: 60 - plugins: - - docker#v3.12.0: - image: "docker:latest" - propagate-environment: true - propagate-uid-gid: true - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - name: "Backup Restore Test" command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat doas + - export PATH=$PATH:/usr/local/go/bin:/sbin:/usr/sbin:/bin + - adduser -D -u 1001 vitess + - adduser vitess wheel + - echo 'permit nopass :wheel' > /etc/doas.d/doas.conf - wget https://golang.org/dl/$GO_VERSION_FILE - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - rm $GO_VERSION_FILE - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make backup-restore-test + - doas make backup-restore-test concurrency: 1 concurrency_group: 'vtop/backup-restore-test' timeout_in_minutes: 60 @@ -43,86 +26,5 @@ steps: - docker#v3.12.0: image: "docker:latest" propagate-environment: true - propagate-uid-gid: true - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - - name: "Backup Schedule Test" - command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat - - wget https://golang.org/dl/$GO_VERSION_FILE - - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - - rm $GO_VERSION_FILE - - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make backup-schedule-test - concurrency: 1 - concurrency_group: 'vtop/backup-schedule-test' - timeout_in_minutes: 60 - plugins: - - docker#v3.12.0: - image: "docker:latest" - propagate-environment: true - propagate-uid-gid: true - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - - name: "VTOrc and VTAdmin Test" - command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat chromium - - wget https://golang.org/dl/$GO_VERSION_FILE - - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - - rm $GO_VERSION_FILE - - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make vtorc-vtadmin-test - concurrency: 1 - concurrency_group: 'vtop/vtorc-vtadmin-test' - timeout_in_minutes: 60 - plugins: - - docker#v3.12.0: - image: "docker:latest" - propagate-environment: true - propagate-uid-gid: true - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - - name: "Unmanaged Tablet Test" - command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat chromium coreutils - - wget https://golang.org/dl/$GO_VERSION_FILE - - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - - rm $GO_VERSION_FILE - - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make unmanaged-tablet-test - concurrency: 1 - concurrency_group: 'vtop/unmanaged-tablet-test' - timeout_in_minutes: 60 - plugins: - - docker#v3.12.0: - image: "docker:latest" - propagate-environment: true - propagate-uid-gid: true - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - - name: "HPA Test" - command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat - - wget https://golang.org/dl/$GO_VERSION_FILE - - tar -C /usr/local -xzf $GO_VERSION_FILE - - export PATH=$PATH:/usr/local/go/bin:/bin - - rm $GO_VERSION_FILE - - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - make hpa-test - concurrency: 1 - concurrency_group: 'vtop/hpa-test' - timeout_in_minutes: 60 - plugins: - - docker#v3.12.0: - image: "docker:latest" - propagate-environment: true - propagate-uid-gid: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" diff --git a/test/endtoend/utils.sh b/test/endtoend/utils.sh index bf685730..b4035b44 100644 --- a/test/endtoend/utils.sh +++ b/test/endtoend/utils.sh @@ -91,23 +91,21 @@ function takeBackup() { # issue the backupShard command to vtctldclient vtctldclient BackupShard "$keyspaceShard" - for i in {1..600} ; do - out=$(kubectl get vtb --no-headers | wc -l) - echo "$out" | grep "$finalBackupCount" > /dev/null 2>&1 - if [[ $? -eq 0 ]]; then - echo "Backup created" - return 0 - fi - sleep 3 - done - echo -e "ERROR: Backup not created - $out. $backupCount backups expected." - exit 1 + if [[ $? -ne 0 ]]; then + echo "Backup failed" + exit 1 + fi + echo "Backup completed" } function verifyListBackupsOutput() { - backupCount=$(kubectl get vtb --no-headers | wc -l) - for i in {1..600} ; do - out=$(vtctldclient LegacyVtctlCommand -- ListBackups "$keyspaceShard" | wc -l) + echo "UID info: $(id)" + echo "GetBackups output: $(vtctldclient GetBackups "$keyspaceShard")" + for i in {1..10} ; do + backupCount=$(kubectl get vtb --no-headers | wc -l) + echo "Kubectl backup count is ${backupCount}" + out=$(vtctldclient GetBackups "$keyspaceShard" | wc -l) + echo "vtctldclient backup count is ${out}" echo "$out" | grep "$backupCount" > /dev/null 2>&1 if [[ $? -eq 0 ]]; then echo "ListBackupsOutputCorrect" @@ -115,7 +113,7 @@ function verifyListBackupsOutput() { fi sleep 3 done - echo -e "ERROR: ListBackups output not correct - $out. $backupCount backups expected." + echo -e "ERROR: GetBackups output not correct - $out. $backupCount backups expected." exit 1 } From d2969616aefc90d291cb4bce4c1d0d65f7d14342 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 4 Feb 2025 13:04:27 -0500 Subject: [PATCH 4/7] Testing... Signed-off-by: Matt Lord --- .buildkite/pipeline.yml | 104 +++++++++++++++++++++++++++++++++++++--- test/endtoend/utils.sh | 16 ++++++- 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 901ff3a9..7786149e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,18 +7,34 @@ env: # Mount the docker.sock as to the docker container, so that we are able to # run docker build command and kind is spawned as a sibling container. steps: + - name: "Upgrade Test" + command: + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat + - wget https://golang.org/dl/$GO_VERSION_FILE + - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin + - rm $GO_VERSION_FILE + - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 + - make upgrade-test + concurrency: 1 + concurrency_group: 'vtop/upgrade-downgrade-test' + timeout_in_minutes: 60 + plugins: + - docker#v3.12.0: + image: "docker:latest" + propagate-environment: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - name: "Backup Restore Test" command: - - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat doas - - export PATH=$PATH:/usr/local/go/bin:/sbin:/usr/sbin:/bin - - adduser -D -u 1001 vitess - - adduser vitess wheel - - echo 'permit nopass :wheel' > /etc/doas.d/doas.conf + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat - wget https://golang.org/dl/$GO_VERSION_FILE - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin - rm $GO_VERSION_FILE - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 - - doas make backup-restore-test + - make backup-restore-test concurrency: 1 concurrency_group: 'vtop/backup-restore-test' timeout_in_minutes: 60 @@ -28,3 +44,79 @@ steps: propagate-environment: true volumes: - "/var/run/docker.sock:/var/run/docker.sock" + + - name: "Backup Schedule Test" + command: + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat + - wget https://golang.org/dl/$GO_VERSION_FILE + - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin + - rm $GO_VERSION_FILE + - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 + - make backup-schedule-test + concurrency: 1 + concurrency_group: 'vtop/backup-schedule-test' + timeout_in_minutes: 60 + plugins: + - docker#v3.12.0: + image: "docker:latest" + propagate-environment: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + + - name: "VTOrc and VTAdmin Test" + command: + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat chromium + - wget https://golang.org/dl/$GO_VERSION_FILE + - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin + - rm $GO_VERSION_FILE + - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 + - make vtorc-vtadmin-test + concurrency: 1 + concurrency_group: 'vtop/vtorc-vtadmin-test' + timeout_in_minutes: 60 + plugins: + - docker#v3.12.0: + image: "docker:latest" + propagate-environment: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + + - name: "Unmanaged Tablet Test" + command: + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat chromium coreutils + - wget https://golang.org/dl/$GO_VERSION_FILE + - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin + - rm $GO_VERSION_FILE + - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 + - make unmanaged-tablet-test + concurrency: 1 + concurrency_group: 'vtop/unmanaged-tablet-test' + timeout_in_minutes: 60 + plugins: + - docker#v3.12.0: + image: "docker:latest" + propagate-environment: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + + - name: "HPA Test" + command: + - apk add g++ make bash gcompat curl mysql mysql-client libc6-compat + - wget https://golang.org/dl/$GO_VERSION_FILE + - tar -C /usr/local -xzf $GO_VERSION_FILE + - export PATH=$PATH:/usr/local/go/bin:/bin + - rm $GO_VERSION_FILE + - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 + - make hpa-test + concurrency: 1 + concurrency_group: 'vtop/hpa-test' + timeout_in_minutes: 60 + plugins: + - docker#v3.12.0: + image: "docker:latest" + propagate-environment: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" diff --git a/test/endtoend/utils.sh b/test/endtoend/utils.sh index b4035b44..46490fe5 100644 --- a/test/endtoend/utils.sh +++ b/test/endtoend/utils.sh @@ -95,12 +95,24 @@ function takeBackup() { echo "Backup failed" exit 1 fi + #echo "Mounts: $(mount)" + #echo "File tree: $(ls -lR /)" + docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup echo "Backup completed" } function verifyListBackupsOutput() { - echo "UID info: $(id)" - echo "GetBackups output: $(vtctldclient GetBackups "$keyspaceShard")" + echo "UID info: $(id)" || true + echo "Processes: $(ps aux)" || true + echo "Docker processes: $(docker ps -a)" || true + echo "Kind processes: $(docker exec -it kind -- ps aux)" || true + echo "Backup dir (/workdir/vtdataroot/backup/example) contents: $(ls -l /workdir/vtdataroot/backup/example)" || true + echo "Backup dir (./vtdataroot/backup/example) contents: $(ls -l ./vtdataroot/backup/example)" || true + echo "Backup dir (/backup) contents: $(ls -l /backup)" || true + echo "Backup dir (${BACKUP_DIR}) contents: $(ls -l ${BACKUP_DIR})" || true + echo "Backup dir (/vt/backups) contents: $(ls -l /vt/backups)" || true + echo "Backup dir (${VTDATAROOT}/backups) contents: $(ls -l ${VTDATAROOT}/backups)" || true + echo "GetBackups output: $(vtctldclient GetBackups "$keyspaceShard")" || true for i in {1..10} ; do backupCount=$(kubectl get vtb --no-headers | wc -l) echo "Kubectl backup count is ${backupCount}" From c63f62c38ce3ab8fb00c413fe6f19b06bc5da6ec Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 4 Feb 2025 17:00:53 -0500 Subject: [PATCH 5/7] Final fixes from testing Signed-off-by: Matt Lord --- test/endtoend/backup_restore_test.sh | 5 +-- test/endtoend/backup_schedule_test.sh | 39 +++++++++-------------- test/endtoend/utils.sh | 46 ++++++++++++++++----------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/test/endtoend/backup_restore_test.sh b/test/endtoend/backup_restore_test.sh index c85ccd33..53faf5d8 100755 --- a/test/endtoend/backup_restore_test.sh +++ b/test/endtoend/backup_restore_test.sh @@ -98,10 +98,7 @@ echo "Building the docker image" docker build -f build/Dockerfile.release -t vitess-operator-pr:latest . echo "Setting up the kind config" setupKindConfig -echo "Creating Kind cluster" -kind create cluster --wait 30s --name kind-${BUILDKITE_BUILD_ID} --config ./vtdataroot/config.yaml --image ${KIND_VERSION} -echo "Loading docker image into Kind cluster" -kind load docker-image vitess-operator-pr:latest --name kind-${BUILDKITE_BUILD_ID} +createKindCluster cd "$PWD/test/endtoend/operator" killall kubectl diff --git a/test/endtoend/backup_schedule_test.sh b/test/endtoend/backup_schedule_test.sh index 55c37a50..fda02b68 100755 --- a/test/endtoend/backup_schedule_test.sh +++ b/test/endtoend/backup_schedule_test.sh @@ -31,14 +31,23 @@ function verifyListBackupsOutputWithSchedule() { checkVitessBackupScheduleStatusWithTimeout "example-vbsc-every-five-minute(.*)" echo -e "Check for number of backups in the cluster" - # Sleep for 6 minutes, during this time we should have at the very minimum 7 backups. - # At least: 6 backups from the every-minute schedule, and 1 backup from the every-five-minute schedule. - sleep 360 + # Sleep for over 6 minutes, during this time we should have at the very minimum + # 7 backups. At least: 6 backups from the every-minute schedule, and 1 backup + # from the every-five-minute schedule. + for i in {1..6} ; do + # Ensure that we can view the backup files from the host. + docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup > /dev/null - backupCount=$(kubectl get vtb --no-headers | wc -l) + backupCount=$(kubectl get vtb --no-headers | wc -l) + echo "Found ${backupCount} backups" + if [[ "${backupCount}" -ge 7 ]]; then + break + fi + sleep 100 + done if [[ "${backupCount}" -lt 7 ]]; then echo "Did not find at least 7 backups" - return 0 + exit 1 fi echo -e "Check for Jobs' pods" @@ -46,21 +55,6 @@ function verifyListBackupsOutputWithSchedule() { checkPodStatusWithTimeout "example-vbsc-every-five-minute-(.*)0/1(.*)Completed(.*)" 2 } -function setupKindConfig() { - if [[ "$BUILDKITE_BUILD_ID" != "0" ]]; then - # The script is being run from buildkite, so we can't mount the current - # working directory to kind. The current directory in the docker is workdir - # So if we try and mount that, we get an error. Instead we need to mount the - # path where the code was checked out be buildkite - dockerContainerName=$(docker container ls --filter "ancestor=docker" --format '{{.Names}}') - CHECKOUT_PATH=$(docker container inspect -f '{{range .Mounts}}{{ if eq .Destination "/workdir" }}{{println .Source }}{{ end }}{{end}}' "$dockerContainerName") - BACKUP_DIR="$CHECKOUT_PATH/vtdataroot/backup" - else - BACKUP_DIR="$PWD/vtdataroot/backup" - fi - cat ./test/endtoend/kindBackupConfig.yaml | sed "s,PATH,$BACKUP_DIR,1" > ./vtdataroot/config.yaml -} - # Test setup STARTING_DIR="$PWD" echo "Make temporary directory for the test" @@ -69,10 +63,7 @@ echo "Building the docker image" docker build -f build/Dockerfile.release -t vitess-operator-pr:latest . echo "Setting up the kind config" setupKindConfig -echo "Creating Kind cluster" -kind create cluster --wait 30s --name kind-${BUILDKITE_BUILD_ID} --config ./vtdataroot/config.yaml --image ${KIND_VERSION} -echo "Loading docker image into Kind cluster" -kind load docker-image vitess-operator-pr:latest --name kind-${BUILDKITE_BUILD_ID} +createKindCluster cd "$PWD/test/endtoend/operator" killall kubectl diff --git a/test/endtoend/utils.sh b/test/endtoend/utils.sh index 46490fe5..f9e7d813 100644 --- a/test/endtoend/utils.sh +++ b/test/endtoend/utils.sh @@ -88,39 +88,25 @@ function takeBackup() { initialBackupCount=$(kubectl get vtb --no-headers | wc -l) finalBackupCount=$((initialBackupCount+1)) - # issue the backupShard command to vtctldclient + # Issue the BackupShard command to vtctldclient. vtctldclient BackupShard "$keyspaceShard" if [[ $? -ne 0 ]]; then echo "Backup failed" exit 1 fi - #echo "Mounts: $(mount)" - #echo "File tree: $(ls -lR /)" - docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup + # Ensure that we can view the backup files from the host. + docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup > /dev/null echo "Backup completed" } function verifyListBackupsOutput() { - echo "UID info: $(id)" || true - echo "Processes: $(ps aux)" || true - echo "Docker processes: $(docker ps -a)" || true - echo "Kind processes: $(docker exec -it kind -- ps aux)" || true - echo "Backup dir (/workdir/vtdataroot/backup/example) contents: $(ls -l /workdir/vtdataroot/backup/example)" || true - echo "Backup dir (./vtdataroot/backup/example) contents: $(ls -l ./vtdataroot/backup/example)" || true - echo "Backup dir (/backup) contents: $(ls -l /backup)" || true - echo "Backup dir (${BACKUP_DIR}) contents: $(ls -l ${BACKUP_DIR})" || true - echo "Backup dir (/vt/backups) contents: $(ls -l /vt/backups)" || true - echo "Backup dir (${VTDATAROOT}/backups) contents: $(ls -l ${VTDATAROOT}/backups)" || true - echo "GetBackups output: $(vtctldclient GetBackups "$keyspaceShard")" || true - for i in {1..10} ; do + for i in {1..30} ; do backupCount=$(kubectl get vtb --no-headers | wc -l) - echo "Kubectl backup count is ${backupCount}" out=$(vtctldclient GetBackups "$keyspaceShard" | wc -l) - echo "vtctldclient backup count is ${out}" echo "$out" | grep "$backupCount" > /dev/null 2>&1 if [[ $? -eq 0 ]]; then - echo "ListBackupsOutputCorrect" + echo "GetBackups output is correct" return 0 fi sleep 3 @@ -284,6 +270,28 @@ function setupKubectlAccessForCI() { fi } +function setupKindConfig() { + if [[ "$BUILDKITE_BUILD_ID" != "0" ]]; then + # The script is being run from buildkite, so we can't mount the current + # working directory to kind. The current directory in the docker is workdir + # So if we try and mount that, we get an error. Instead we need to mount the + # path where the code was checked out be buildkite + dockerContainerName=$(docker container ls --filter "ancestor=docker" --format '{{.Names}}') + CHECKOUT_PATH=$(docker container inspect -f '{{range .Mounts}}{{ if eq .Destination "/workdir" }}{{println .Source }}{{ end }}{{end}}' "$dockerContainerName") + BACKUP_DIR="$CHECKOUT_PATH/vtdataroot/backup" + else + BACKUP_DIR="$PWD/vtdataroot/backup" + fi + cat ./test/endtoend/kindBackupConfig.yaml | sed "s,PATH,$BACKUP_DIR,1" > ./vtdataroot/config.yaml +} + +function createKindCluster() { + echo "Creating Kind cluster" + kind create cluster --wait 30s --name kind-${BUILDKITE_BUILD_ID} --config ./vtdataroot/config.yaml --image ${KIND_VERSION} + echo "Loading docker image into Kind cluster" + kind load docker-image vitess-operator-pr:latest --name kind-${BUILDKITE_BUILD_ID} +} + # get_started: # $1: operator file to use # $2: initial config file to use From e3ded7693dd6569b3ba3e5030a4d37252aeebcfb Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 4 Feb 2025 19:59:31 -0500 Subject: [PATCH 6/7] Remove duplicate function Signed-off-by: Matt Lord --- test/endtoend/backup_restore_test.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/test/endtoend/backup_restore_test.sh b/test/endtoend/backup_restore_test.sh index 53faf5d8..92d567fe 100755 --- a/test/endtoend/backup_restore_test.sh +++ b/test/endtoend/backup_restore_test.sh @@ -75,21 +75,6 @@ COrder EOF } -function setupKindConfig() { - if [[ "$BUILDKITE_BUILD_ID" != "0" ]]; then - # The script is being run from buildkite, so we can't mount the current - # working directory to kind. The current directory in the docker is workdir - # So if we try and mount that, we get an error. Instead we need to mount the - # path where the code was checked out be buildkite - dockerContainerName=$(docker container ls --filter "ancestor=docker" --format '{{.Names}}') - CHECKOUT_PATH=$(docker container inspect -f '{{range .Mounts}}{{ if eq .Destination "/workdir" }}{{println .Source }}{{ end }}{{end}}' "$dockerContainerName") - BACKUP_DIR="$CHECKOUT_PATH/vtdataroot/backup" - else - BACKUP_DIR="$PWD/vtdataroot/backup" - fi - cat ./test/endtoend/kindBackupConfig.yaml | sed "s,PATH,$BACKUP_DIR,1" > ./vtdataroot/config.yaml -} - # Test setup STARTING_DIR="$PWD" echo "Make temporary directory for the test" From ed68b3460231f35ffb51283f5b66b09a52bb41c2 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 4 Feb 2025 20:01:56 -0500 Subject: [PATCH 7/7] Add another perms update Signed-off-by: Matt Lord --- test/endtoend/backup_schedule_test.sh | 1 - test/endtoend/utils.sh | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/endtoend/backup_schedule_test.sh b/test/endtoend/backup_schedule_test.sh index fda02b68..e540bf4c 100755 --- a/test/endtoend/backup_schedule_test.sh +++ b/test/endtoend/backup_schedule_test.sh @@ -37,7 +37,6 @@ function verifyListBackupsOutputWithSchedule() { for i in {1..6} ; do # Ensure that we can view the backup files from the host. docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup > /dev/null - backupCount=$(kubectl get vtb --no-headers | wc -l) echo "Found ${backupCount} backups" if [[ "${backupCount}" -ge 7 ]]; then diff --git a/test/endtoend/utils.sh b/test/endtoend/utils.sh index f9e7d813..4de6add1 100644 --- a/test/endtoend/utils.sh +++ b/test/endtoend/utils.sh @@ -102,6 +102,8 @@ function takeBackup() { function verifyListBackupsOutput() { for i in {1..30} ; do + # Ensure that we can view the backup files from the host. + docker exec -it $(docker container ls --format '{{.Names}}' | grep kind) chmod o+rwx -R /backup > /dev/null backupCount=$(kubectl get vtb --no-headers | wc -l) out=$(vtctldclient GetBackups "$keyspaceShard" | wc -l) echo "$out" | grep "$backupCount" > /dev/null 2>&1