-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from cyberark/e2e-ci-improvements
Run golang e2e tests in CI
- Loading branch information
Showing
15 changed files
with
251 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,59 @@ | ||
FROM golang:1.20-alpine | ||
MAINTAINER CyberArk Software Ltd. | ||
LABEL id="secrets-provider-for-k8s-e2e-test-runner" | ||
FROM google/cloud-sdk:437.0.0-slim | ||
|
||
WORKDIR /secrets-provider-for-k8s | ||
RUN mkdir -p /src | ||
WORKDIR /src | ||
|
||
# Install Docker client | ||
RUN apt-get update -y && \ | ||
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common wget google-cloud-sdk-gke-gcloud-auth-plugin && \ | ||
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | apt-key add - && \ | ||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" && \ | ||
apt-get update && \ | ||
apt-get install -y docker-ce && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install kubectl CLI | ||
ARG KUBECTL_CLI_URL | ||
RUN wget -O /usr/local/bin/kubectl ${KUBECTL_CLI_URL:-https://storage.googleapis.com/kubernetes-release/release/v1.7.6/bin/linux/amd64/kubectl} && \ | ||
chmod +x /usr/local/bin/kubectl | ||
|
||
# Install OpenShift oc CLI | ||
ARG OPENSHIFT_CLI_URL | ||
RUN mkdir -p ocbin && \ | ||
wget -O oc.tar.gz ${OPENSHIFT_CLI_URL:-https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/openshift-client-linux.tar.gz} && \ | ||
tar xvf oc.tar.gz -C ocbin && \ | ||
cp "$(find ./ocbin -name 'oc' -type f | tail -1)" /usr/local/bin/oc && \ | ||
rm -rf ocbin oc.tar.gz | ||
|
||
# Install Helm | ||
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \ | ||
chmod 700 get_helm.sh && \ | ||
./get_helm.sh | ||
|
||
RUN apk add -u curl \ | ||
gcc \ | ||
git \ | ||
mercurial \ | ||
musl-dev | ||
# Adds ability to perform mathematical operations with floats for testing | ||
RUN apt-get update -y && \ | ||
apt-get install -y bc | ||
|
||
# Add Golang-based E2E tests | ||
# Install necessary packages to download and install Golang | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
git | ||
|
||
# Download and install Golang | ||
ENV GOLANG_VERSION 1.20 | ||
RUN curl -L https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xz | ||
ENV PATH=$PATH:/usr/local/go/bin | ||
|
||
RUN mkdir -p /secrets-provider-for-k8s | ||
WORKDIR /secrets-provider-for-k8s | ||
|
||
COPY ./go.mod ./go.sum /secrets-provider-for-k8s/ | ||
COPY go.mod go.sum /secrets-provider-for-k8s/ | ||
|
||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT [ "go", "test", "-v", "-timeout", "3m", "-tags", "e2e", "./e2e/..." ] | ||
WORKDIR /src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
pushd $(dirname "${BASH_SOURCE[0]}") | ||
|
||
# If DEV env variable isn't set, source the bootstrap file | ||
if [[ -z "${DEV:-}" ]]; then | ||
source "../bootstrap.env" | ||
fi | ||
|
||
source "../deploy/utils.sh" | ||
|
||
set_config_directory_path | ||
|
||
../deploy/teardown_resources.sh | ||
|
||
if [ "${DEV}" = "false" ]; then | ||
announce "Creating image pull secret." | ||
if [[ "${PLATFORM}" == "kubernetes" ]]; then | ||
$cli_with_timeout delete --ignore-not-found secret $IMAGE_PULL_SECRET | ||
|
||
$cli_with_timeout create secret docker-registry dockerpullsecret \ | ||
--docker-server="${PULL_DOCKER_REGISTRY_URL}" \ | ||
--docker-username=_ \ | ||
--docker-password=_ \ | ||
--docker-email=_ | ||
elif [[ "$PLATFORM" == "openshift" ]]; then | ||
$cli_with_timeout delete --ignore-not-found secrets dockerpullsecret | ||
|
||
$cli_with_timeout create secret docker-registry $IMAGE_PULL_SECRET \ | ||
--docker-server="${PULL_DOCKER_REGISTRY_PATH}" \ | ||
--docker-username=_ \ | ||
--docker-password=$($cli_with_timeout whoami -t) \ | ||
--docker-email=_ | ||
|
||
$cli_with_timeout secrets link serviceaccount/default dockerpullsecret --for=pull | ||
fi | ||
fi | ||
|
||
echo "Create secret k8s-secret" | ||
$cli_with_timeout create -f "$CONFIG_DIR/k8s-secret.yml" | ||
|
||
wait_for_it 600 "$CONFIG_DIR/secrets-access-role.sh.yml | $cli_without_timeout apply -f -" | ||
|
||
wait_for_it 600 "$CONFIG_DIR/secrets-access-role-binding.sh.yml | $cli_without_timeout apply -f -" | ||
|
||
selector="role=follower" | ||
cert_location="/opt/conjur/etc/ssl/conjur.pem" | ||
if [ "$CONJUR_DEPLOYMENT" = "oss" ]; then | ||
selector="app=conjur-cli" | ||
cert_location="/root/conjur-server.pem" | ||
fi | ||
conjur_pod_name="$(get_pod_name "$CONJUR_NAMESPACE_NAME" "$selector")" | ||
ssl_cert=$($cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME -- cat $cert_location") | ||
|
||
export CONJUR_SSL_CERTIFICATE=$ssl_cert | ||
|
||
deploy_env | ||
|
||
popd |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.