Skip to content

Commit

Permalink
Final fixes from testing
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Feb 4, 2025
1 parent d296961 commit bd37339
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
5 changes: 1 addition & 4 deletions test/endtoend/backup_restore_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 2 additions & 20 deletions test/endtoend/backup_schedule_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,14 @@ function verifyListBackupsOutputWithSchedule() {
backupCount=$(kubectl get vtb --no-headers | wc -l)
if [[ "${backupCount}" -lt 7 ]]; then
echo "Did not find at least 7 backups"
return 0
exit 1
fi

echo -e "Check for Jobs' pods"
checkPodStatusWithTimeout "example-vbsc-every-minute-(.*)0/1(.*)Completed(.*)" 3
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"
Expand All @@ -69,10 +54,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
Expand Down
38 changes: 23 additions & 15 deletions test/endtoend/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,15 @@ function takeBackup() {
echo "Backup failed"
exit 1
fi
#echo "Mounts: $(mount)"
#echo "File tree: $(ls -lR /)"
# 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
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
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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd37339

Please sign in to comment.