Skip to content

Commit

Permalink
PR to add e2e tests of linked bundle and profile update (#305)
Browse files Browse the repository at this point in the history
* e2e linked updates

* code formatting

* Added comments for better understanding

Co-authored-by: Jayanth Reddy <jaya@platform9.com>
  • Loading branch information
jayanth-tjvrr and Jayanth Reddy authored Nov 15, 2022
1 parent f34e92e commit a508bd2
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ test-e2e:
./testing/e2e_setup.sh
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 00-deploy
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 01-update
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 02-delete
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 03-manage --kind-context arlon-e2e-testbed --timeout 300
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 02-linkedupdate
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 03-linkedbundleupdate
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 04-linkedprofileupdate
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 05-delete
kubectl kuttl test --start-kind=false ./testing/e2e/ --test 06-manage --kind-context arlon-e2e-testbed --timeout 300

e2e-teardown:
./testing/e2e_setup_teardown.sh
9 changes: 9 additions & 0 deletions testing/e2e/02-linkedupdate/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 60
---
apiVersion: v1
kind: Secret
metadata:
namespace: arlon
name: guestbook
4 changes: 4 additions & 0 deletions testing/e2e/02-linkedupdate/00-bundlecreate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: arlon bundle create guestbook --tags test,guestbook --desc "Guestbook pod" --repo-path bundles/guestbook
8 changes: 8 additions & 0 deletions testing/e2e/02-linkedupdate/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: core.arlon.io/v1
kind: Profile
metadata:
namespace: arlon
name: dynamic-2
spec:
bundles:
- guestbook
4 changes: 4 additions & 0 deletions testing/e2e/02-linkedupdate/01-profilecreate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: arlon profile create dynamic-2 --repo-base-path profiles --bundles guestbook --desc "dynamic test 2" --tags examples
4 changes: 4 additions & 0 deletions testing/e2e/02-linkedupdate/02-ngupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: ../../e2e_linked_prereq.sh
25 changes: 25 additions & 0 deletions testing/e2e/03-linkedbundleupdate/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: guestbook-ui
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 3
revisionHistoryLimit: 3
selector:
matchLabels:
app: guestbook-ui
template:
metadata:
labels:
app: guestbook-ui
status:
availableReplicas: 3
readyReplicas: 3
replicas: 3
updatedReplicas: 3
4 changes: 4 additions & 0 deletions testing/e2e/03-linkedbundleupdate/00-bundleupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: ../../e2e_linked_update.sh
12 changes: 12 additions & 0 deletions testing/e2e/04-linkedprofileupdate/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ec2-cluster-xenial
namespace: argocd
status:
health:
status: Healthy
4 changes: 4 additions & 0 deletions testing/e2e/04-linkedprofileupdate/00-profileupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: arlon profile update dynamic-2 --bundles xenial
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: TestStep
commands:
- command: arlon cluster delete ec2-cluster
- command: arlon bundle delete xenial
- command: arlon profile delete dynamic-1
- command: arlon profile delete dynamic-2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions testing/e2e_linked_prereq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
arlon cluster ngupdate ec2-cluster --profile dynamic-2
clusterctl get kubeconfig ec2-cluster-capi-quickstart -n ec2-cluster > arlon-eks.kubeconfig #Generated the kubeconfig for ec2-cluster
cp arlon-eks.kubeconfig /home/runner/work/arlon/arlon/kubeconfig #placing the ec2-cluster config file in $KUBECONFIG
cp ~/.kube/config ~/.kube/temp.config #Swapping the ec2-cluster config with ~/.kube/config for assert.yaml
cp arlon-eks.kubeconfig ~/.kube/config
31 changes: 31 additions & 0 deletions testing/e2e_linked_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
if [ -z "${GIT_USER}" ]; then
echo "Set the GIT_USER env variable"
exit
fi

if [ -z "${GIT_PASSWORD}" ]; then
echo "Set the GIT_PASSWORD env variable"
exit
fi
dir=$(pwd)
export git_server_port=8188
export GIT_CLONE_ROOT=/tmp/arlon-testbed-git-clone
export workspace_repo_url="http://localhost:${git_server_port}/${GIT_USER}/myrepo.git"
export workspace_repo="${GIT_CLONE_ROOT}/myrepo"
#updating guestbook bundle replicas to 3 from 1
cd ${workspace_repo}
git pull
cd bundles/guestbook
sed -i -e "7s/replicas: 1/replicas: 3/g" guestbook.yaml
git add guestbook.yaml
git commit -m "added 3 replica line"
git push "http://${GIT_USER}:${GIT_PASSWORD}@localhost:${git_server_port}/${GIT_USER}/myrepo.git"
cd ${dir}

cp ~/.kube/temp.config ~/.kube/config #Placing back the ~/.kube/config back in it's place
rm -rf /home/runner/work/arlon/arlon/kubeconfig #Removing ec2-cluster config at $KUBECONFIG





16 changes: 14 additions & 2 deletions testing/e2e_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ if [ ! -d "${workspace_repo}" ]; then
else
echo git repo already cloned
fi

echo printing the current directory
ls
pushd ${workspace_repo}
if ! test -f README.md; then
echo adding README.md and creating main branch
Expand Down Expand Up @@ -313,7 +314,7 @@ if ! which kubectl-kuttl &>/dev/null; then
mv kubectl-kuttl "${HOME}/.local/bin/kubectl-kuttl"
fi

# not needed for us...
# not needed for us...
#clusterawsadm bootstrap iam create-cloudformation-stack

export AWS_B64ENCODED_CREDENTIALS=$(clusterawsadm bootstrap credentials encode-as-profile)
Expand Down Expand Up @@ -349,6 +350,17 @@ if ! arlon bundle list | grep xenial >/dev/null; then
popd
fi

if ! arlon bundle list | grep guestbook >/dev/null; then
echo "Adding guestbook manifests"
pushd ${workspace_repo}
mkdir -p bundles/guestbook
cp "${arlon_repo}/examples/bundles/guestbook.yaml" bundles/guestbook
git add bundles/guestbook
git commit -m "add guestbook bundle"
git push "http://${GIT_USER}:${GIT_PASSWORD}@localhost:${git_server_port}/${GIT_USER}/myrepo.git"
popd
fi

echo adding basecluster directory
mkdir -p ${baseclusterdir}
mv "${arlon_repo}/testing/${manifestfile}" "${baseclusterdir}/${manifestfile}"
Expand Down

0 comments on commit a508bd2

Please sign in to comment.