Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration test cases FW #3508

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SERVER_MODE_EA_ONLY=EA_ONLY
include $(ENV_FILE)
export

build: clean wire test-all
build: clean wire
$(ENVVAR) GOOS=$(GOOS) go build -o devtron \
-ldflags="-X 'github.com/devtron-labs/devtron/util.GitCommit=${GIT_COMMIT}' \
-X 'github.com/devtron-labs/devtron/util.BuildTime=${BUILD_TIME}' \
Expand Down
60 changes: 45 additions & 15 deletions tests/integrationTesting/create-test-env.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
# shellcheck disable=SC2155
apk update && apk add wget && apk add curl && apk add vim && apk add bash && apk add git && apk add yq
#export TEST_BRANCH=$(echo $TEST_BRANCH | awk -F '/' '{print $NF}')
export LATEST_HASH=`git log --pretty=format:'%H' -n 1`
export TEST_BRANCH=`git name-rev --name-only "$LATEST_HASH" | awk -F '/' '{print $NF}'`
apk update && apk add wget && apk add curl && apk add vim && apk add bash && apk add git && apk add yq && apk add gcc && apk add musl-dev && apk add make
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
###### check docker is running or not ?? ####

k3d cluster create it-cluster
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
MACHINE_OS='linux'
MACHINE_ARCH='amd64'
#export MACHINE_OS='darwin'
#export MACHINE_ARCH='arm64'
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/$MACHINE_OS/$MACHINE_ARCH/kubectl"
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
wget https://raw.githubusercontent.com/devtron-labs/devtron/main/tests/integrationTesting/postgresql-secret.yaml -O postgresql-secret.yaml
kubectl apply -f postgresql-secret.yaml
wget https://raw.githubusercontent.com/devtron-labs/devtron/main/tests/integrationTesting/postgresql.yaml -O postgresql.yaml
kubectl apply -f postgresql.yaml
wget https://raw.githubusercontent.com/devtron-labs/devtron/main/tests/integrationTesting/migrator.yaml -O migrator.yaml
yq '(select(.metadata.name == "postgresql-migrate-devtron") | .spec.template.spec.containers[0].env[0].value) = env(TEST_BRANCH)' migrator.yaml -i
yq '(select(.metadata.name == "postgresql-migrate-devtron") | .spec.template.spec.containers[0].env[9].value) = env(LATEST_HASH)' migrator.yaml -i
kubectl apply -f migrator.yaml
kubectl create ns devtroncd
kubectl create ns devtron-cd
kubectl create ns devtron-ci
kubectl -n devtroncd apply -f $PWD/tests/integrationTesting/postgresql-secret.yaml
kubectl -ndevtroncd apply -f $PWD/tests/integrationTesting/postgresql.yaml
yq '(select(.metadata.name == "postgresql-migrate-devtron") | .spec.template.spec.containers[0].env[0].value) = env(TEST_BRANCH)' $PWD/tests/integrationTesting/migrator.yaml -i
yq '(select(.metadata.name == "postgresql-migrate-devtron") | .spec.template.spec.containers[0].env[9].value) = env(LATEST_HASH)' $PWD/tests/integrationTesting/migrator.yaml -i
kubectl -ndevtroncd apply -f $PWD/tests/integrationTesting/migrator.yaml
# shellcheck disable=SC2046
while [ ! $(kubectl -n devtroncd get $(kubectl -n devtroncd get job -l job=postgresql-migrate-devtron -o name) -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
while [ ! $(kubectl -n devtroncd get job postgresql-migrate-devtron -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
echo "devtron postgres migration completed"
# shellcheck disable=SC2046
while [ ! $(kubectl -n devtroncd get $(kubectl -n devtroncd get job -l job=postgresql-migrate-casbin -o name) -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
while [ ! $(kubectl -n devtroncd get job postgresql-migrate-casbin -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
echo "casbin postgres migration completed"
# shellcheck disable=SC2046
while [ ! $(kubectl -n devtroncd get $(kubectl -n devtroncd get job -l job=postgresql-migrate-lens -o name) -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
while [ ! $(kubectl -n devtroncd get job postgresql-migrate-lens -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
echo "lens postgres migration completed"
# shellcheck disable=SC2046
while [ ! $(kubectl -n devtroncd get $(kubectl -n devtroncd get job -l job=postgresql-migrate-gitsensor -o name) -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
exit #to get out of container
while [ ! $(kubectl -n devtroncd get job postgresql-migrate-gitsensor -o jsonpath="{.status.succeeded}") ]; do sleep 10; done
echo "git-sensor postgres migration completed"
#exit #to get out of container

###### Installing Helm #####
echo "Installing Helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh


###### Installing Argo Dependencies #####
echo "Installing Argo Workflow CRDS"
kubectl create ns argo
cd $PWD/charts/devtron # Make sure path is set correctly
helm dependency up
helm template devtron . --set installer.modules={cicd} -s templates/workflow.yaml >./argo_wf.yaml
kubectl apply -f ./argo_wf.yaml
while [ ! $(kubectl -n argo get deployment workflow-controller -o jsonpath="{.status.readyReplicas}") ]; do sleep 10; done
cd $PWD
33 changes: 1 addition & 32 deletions tests/integrationTesting/migrator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ metadata:
spec:
template:
spec:
serviceAccountName: devtron
containers:
- name: postgresql-migrate-casbin
image: quay.io/devtron/migrator:71748de9-149-11112
Expand Down Expand Up @@ -71,10 +70,6 @@ spec:
envFrom:
- secretRef:
name: postgresql-migrator
resources:
requests:
cpu: 0.5
memory: 500Mi
restartPolicy: OnFailure
backoffLimit: 20
activeDeadlineSeconds: 1500
Expand Down Expand Up @@ -190,30 +185,4 @@ spec:
name: postgresql-postgresql-init-scripts
restartPolicy: OnFailure
backoffLimit: 20
activeDeadlineSeconds: 1500
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: app-sync-cronjob
spec:
schedule: "0 19 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: chart-sync
image: quay.io/devtron/chart-sync:07ac8fd7-150-11120
env:
- name: PG_ADDR
value: postgresql-postgresql
- name: PG_DATABASE
value: orchestrator
- name: PG_USER
value: postgres
envFrom:
- secretRef:
name: devtron-secret
restartPolicy: Never
backoffLimit: 4
activeDeadlineSeconds: 1500
10 changes: 6 additions & 4 deletions tests/integrationTesting/run-integration-test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
git clone https://github.com/devtron-labs/devtron.git
cd devtron || exit
git checkout $TEST_BRANCH
go test ./tests/integrationTesting
wget https://go.dev/dl/go1.18.10.linux-amd64.tar.gz -O go1.18.10.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.10.tar.gz
export GOPATH='/usr/local/go'
export PATH=$PATH:$GOPATH/bin
#go test ./pkg/pipeline
go test -v ./pkg/pipeline -run TestExecuteWorkflow
exit #to get out of container