Skip to content

Commit

Permalink
update script for non-windows azure tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Jul 26, 2024
1 parent 2051fc4 commit 13fec51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
25 changes: 11 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export GOPATH GOBIN GO111MODULE DOCKER_CLI_EXPERIMENTAL

# Generate all combination of all OS, ARCH, and OSVERSIONS for iteration
ALL_OS = linux windows
ALL_ARCH.linux = amd64 arm64
ALL_OS_ARCH.linux = $(foreach arch, ${ALL_ARCH.linux}, linux-$(arch))
ALL_ARCH.windows = amd64
ALL_OSVERSIONS.windows := 1809 ltsc2022
ALL_OS_ARCH.windows = $(foreach arch, $(ALL_ARCH.windows), $(foreach osversion, ${ALL_OSVERSIONS.windows}, windows-${osversion}-${arch}))
ALL_OS_ARCH = $(foreach os, $(ALL_OS), ${ALL_OS_ARCH.${os}})
ALL_ARCH_linux ?= amd64 arm64
ALL_OS_ARCH_linux = $(foreach arch, ${ALL_ARCH_linux}, linux-$(arch))
ALL_ARCH_windows = amd64
ALL_OSVERSIONS_windows := 1809 ltsc2022
ALL_OS_ARCH_windows = $(foreach arch, $(ALL_ARCH_windows), $(foreach osversion, ${ALL_OSVERSIONS_windows}, windows-${osversion}-${arch}))
ALL_OS_ARCH = $(foreach os, $(ALL_OS), ${ALL_OS_ARCH_${os}})

# The current context of image building
# The architecture of the image
Expand Down Expand Up @@ -328,24 +328,24 @@ docker-buildx-builder:

.PHONY: container-all
container-all: docker-buildx-builder
for arch in $(ALL_ARCH.linux); do \
for arch in $(ALL_ARCH_linux); do \
ARCH=$${arch} $(MAKE) container-linux; \
ARCH=$${arch} $(MAKE) crd-container-linux; \
done
for osversion in $(ALL_OSVERSIONS.windows); do \
for osversion in $(ALL_OSVERSIONS_windows); do \
OSVERSION=$${osversion} $(MAKE) container-windows; \
done

.PHONY: push-manifest
push-manifest:
docker manifest create --amend $(IMAGE_TAG) $(foreach osarch, $(ALL_OS_ARCH), $(IMAGE_TAG)-${osarch})
docker manifest create --amend $(CRD_IMAGE_TAG) $(foreach osarch, $(ALL_OS_ARCH.linux), $(CRD_IMAGE_TAG)-${osarch})
docker manifest create --amend $(CRD_IMAGE_TAG) $(foreach osarch, $(ALL_OS_ARCH_linux), $(CRD_IMAGE_TAG)-${osarch})
# add "os.version" field to windows images (based on https://github.com/kubernetes/kubernetes/blob/master/build/pause/Makefile)
set -x; \
registry_prefix=$(shell (echo ${REGISTRY} | grep -Eq ".*[\/\.].*") && echo "" || echo "docker.io/"); \
manifest_image_folder=`echo "$${registry_prefix}${IMAGE_TAG}" | sed "s|/|_|g" | sed "s/:/-/"`; \
for arch in $(ALL_ARCH.windows); do \
for osversion in $(ALL_OSVERSIONS.windows); do \
for arch in $(ALL_ARCH_windows); do \
for osversion in $(ALL_OSVERSIONS_windows); do \
BASEIMAGE=mcr.microsoft.com/windows/nanoserver:$${osversion}; \
full_version=`docker manifest inspect $${BASEIMAGE} | jq -r '.manifests[0].platform["os.version"]'`; \
sed -i -r "s/(\"os\"\:\"windows\")/\0,\"os.version\":\"$${full_version}\"/" "${HOME}/.docker/manifests/$${manifest_image_folder}/$${manifest_image_folder}-windows-$${osversion}-$${arch}"; \
Expand All @@ -361,10 +361,7 @@ push-manifest:
## --------------------------------------
.PHONY: e2e-bootstrap
e2e-bootstrap: $(HELM) $(BATS) $(KIND) $(KUBECTL) $(ENVSUBST) $(YQ) #setup all required binaries and kind cluster for testing
ifndef TEST_WINDOWS
$(MAKE) setup-kind
endif
docker pull $(IMAGE_TAG) || $(MAKE) e2e-container

.PHONY: setup-kind
setup-kind: $(KIND)
Expand Down
31 changes: 18 additions & 13 deletions test/scripts/run-e2e-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ set -o pipefail
readonly CLUSTER_NAME="${CLUSTER_NAME:-sscsi-e2e-$(openssl rand -hex 2)}"
readonly KEYVAULT_NAME="secrets-store-csi-e2e"

IMAGE_VERSION=e2e-$(git rev-parse --short HEAD)
IMAGE_TAG=${REGISTRY}/driver:${IMAGE_VERSION}

parse_cred() {
grep -E -o "\b$1[[:blank:]]*=[[:blank:]]*\"[^[:space:]\"]+\"" | cut -d '"' -f 2
}
Expand Down Expand Up @@ -59,17 +62,19 @@ main() {
--node-vm-size Standard_DS3_v2 \
--enable-managed-identity \
--network-plugin azure \
--enable-oidc-issuer \
--generate-ssh-keys > /dev/null

echo "Adding windows nodepool"
# add windows nodepool
az aks nodepool add \
--resource-group "${CLUSTER_NAME}" \
--cluster-name "${CLUSTER_NAME}" \
--os-type Windows \
--name npwin \
--node-count 1 > /dev/null
--enable-oidc-issuer > /dev/null

# only add windows pool if TEST_WINDOWS is set and equal to true
if [[ "${TEST_WINDOWS:-}" == "true" ]]; then
echo "Adding windows nodepool"
# add windows nodepool
az aks nodepool add \
--resource-group "${CLUSTER_NAME}" \
--cluster-name "${CLUSTER_NAME}" \
--os-type Windows \
--name npwin \
--node-count 1 > /dev/null
fi

az aks get-credentials --resource-group "${CLUSTER_NAME}" --name "${CLUSTER_NAME}" --overwrite-existing

Expand Down Expand Up @@ -115,8 +120,8 @@ main() {
echo "Assigning managed identity permissions to get secrets from keyvault"
az keyvault set-policy --name "${KEYVAULT_NAME}" --secret-permissions get --object-id "${IDENTITY_OBJECT_ID}" > /dev/null

# build the driver image and run e2e tests
ALL_OS_ARCH=amd64 make e2e-test
docker pull "${IMAGE_TAG}" || ALL_ARCH_linux=amd64 make e2e-container
make e2e-bootstrap e2e-helm-deploy e2e-azure
}

main

0 comments on commit 13fec51

Please sign in to comment.