Skip to content

Commit

Permalink
[NET-11106] Make bats testing more reproducible (#4345)
Browse files Browse the repository at this point in the history
* testing out changes to bats testing

* use pre-built image

* update ref for bats testing

* remove extra newline

* remove extra newline
  • Loading branch information
jm96441n authored Sep 20, 2024
1 parent aab4856 commit 0c37451
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ generate-external-crds: ## Generate CRDs for externally defined CRDs and copy th

.PHONY: bats-tests
bats-tests: ## Run Helm chart bats tests.
bats --jobs 4 charts/consul/test/unit
docker run -it -v $(CURDIR):/consul-k8s hashicorpdev/consul-helm-test:latest bats --jobs 4 /consul-k8s/charts/consul/test/unit -f "$(TEST_NAME)"

##@ Control Plane Targets

Expand Down
50 changes: 25 additions & 25 deletions charts/consul/test/docker/Test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,71 @@
# a script to configure kubectl, potentially install Helm, and run the tests
# manually. This image only has the dependencies pre-installed.

FROM cimg/go:1.19
FROM cimg/go:1.23.1

# change the user to root so we can install stuff
USER root

ENV BATS_VERSION "1.6.0"
ENV TERRAFORM_VERSION "0.13.5"
ENV BATS_VERSION "1.11.0"
ENV TERRAFORM_VERSION "1.9.6"

RUN apt-get update

# base packages
RUN apt-get install -y \
openssl \
python3 \
python3-pip \
jq
openssl \
python3 \
python3-pip \
jq

# yq
RUN pip3 install yq

# gcloud
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \
apt-get update -y && \
apt-get install google-cloud-sdk -y && \
apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \
apt-get update -y && \
apt-get install google-cloud-sdk -y && \
apt-get install google-cloud-sdk-gke-gcloud-auth-plugin

# terraform
RUN curl -sSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o /tmp/tf.zip \
&& unzip /tmp/tf.zip \
&& mv ./terraform /usr/local/bin/terraform
&& unzip /tmp/tf.zip \
&& mv ./terraform /usr/local/bin/terraform

# kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl

# helm
RUN curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

# bats
RUN curl -sSL https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz -o /tmp/bats.tgz \
&& tar -zxf /tmp/bats.tgz -C /tmp \
&& /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local
&& tar -zxf /tmp/bats.tgz -C /tmp \
&& /bin/bash /tmp/bats-core-${BATS_VERSION}/install.sh /usr/local

# Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

# OpenShift CLI
# https://docs.microsoft.com/en-us/azure/openshift/tutorial-connect-cluster
RUN curl -sSL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz -o /tmp/oc.tar.gz \
&& tar -zxvf /tmp/oc.tar.gz -C /tmp \
&& mv /tmp/oc /usr/local/bin/oc
&& tar -zxvf /tmp/oc.tar.gz -C /tmp \
&& mv /tmp/oc /usr/local/bin/oc

# AWS CLI
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install --bin-dir /usr/local/bin \
&& rm awscliv2.zip \
&& rm -rf ./aws
&& unzip awscliv2.zip \
&& ./aws/install --bin-dir /usr/local/bin \
&& rm awscliv2.zip \
&& rm -rf ./aws

# AWS IAM authenticator
RUN curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64 \
&& chmod +x ./aws-iam-authenticator \
&& mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator
&& chmod +x ./aws-iam-authenticator \
&& mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator

# change the user back to what circleci/golang image has
USER circleci

0 comments on commit 0c37451

Please sign in to comment.