-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
136 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,15 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin | ||
- run: make -C e2e_test ci-setup | ||
- run: make -C e2e_test -j3 deploy | ||
- run: git config user.name ci | ||
- run: git config user.email [email protected] | ||
- run: make -C e2e_test setup | ||
- run: make -C e2e_test -j4 deploy | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- run: make -C e2e_test test | ||
- run: make -C e2e_test -j4 test | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | ||
- run: make -C e2e_test ci-cleanup | ||
- run: make -C e2e_test cleanup | ||
if: always() |
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 |
---|---|---|
|
@@ -3,41 +3,41 @@ KUBECONFIG := output/kubeconfig.yaml | |
export KUBECONFIG | ||
|
||
GITHUB_RUN_ID ?= 0 | ||
MAIN_BRANCH_NAME := e2e-test-$(GITHUB_RUN_ID)-main | ||
FIXTURE_BRANCH := e2e-test-$(GITHUB_RUN_ID) | ||
|
||
GITHUB_PR_NUMBER ?= 0 | ||
|
||
all: | ||
|
||
test: testcase1 testcase2 | ||
|
||
.NOTPARALLEL: testcase1 testcase2 | ||
testcase1: | ||
# create a pull request | ||
git checkout -b $(MAIN_BRANCH_NAME)-fixture1 | ||
sed -i -e 's/name: echoserver/name: echoserver-fixture1/g' helloworld/deployment/echoserver.yaml | ||
git commit -a -m "e2e-test-fixture1" | ||
git push origin $(MAIN_BRANCH_NAME)-fixture1 | ||
gh pr create --base $(MAIN_BRANCH_NAME) --title "e2e-test: sync success" --body "This is created by e2e-test of #$(GITHUB_PR_NUMBER)" | ||
gh pr merge --squash | ||
test: | ||
# wait for sync | ||
git checkout $(MAIN_BRANCH_NAME) | ||
git pull origin --ff-only $(MAIN_BRANCH_NAME) | ||
./wait-for-sync-status.sh helloworld Synced | ||
kubectl -n helloworld rollout status deployment echoserver-fixture1 | ||
|
||
testcase2: | ||
# create a pull request | ||
git checkout -b $(MAIN_BRANCH_NAME)-fixture2 | ||
sed -i -e 's/app: echoserver/app: echoserver-fixture2/g' helloworld/deployment/echoserver.yaml | ||
git commit -a -m "e2e-test-fixture2" | ||
git push origin $(MAIN_BRANCH_NAME)-fixture2 | ||
gh pr create --base $(MAIN_BRANCH_NAME) --title "e2e-test: sync failure" --body "This is created by e2e-test of #$(GITHUB_PR_NUMBER)" | ||
./wait-for-sync-status.sh test1-fixture $(FIXTURE_BRANCH)-test1-main Synced Succeeded | ||
./wait-for-sync-status.sh test2-fixture $(FIXTURE_BRANCH)-test2-main Synced Succeeded | ||
# test1 (sync success) | ||
git checkout $(FIXTURE_BRANCH)-test1-main | ||
git checkout -b $(FIXTURE_BRANCH)-test1-topic | ||
sed -i -e 's/name: echoserver/name: echoserver-test1/g' test1-fixture/deployment/echoserver.yaml | ||
git commit -a -m $(FIXTURE_BRANCH)-test1-topic | ||
git push origin $(FIXTURE_BRANCH)-test1-topic | ||
gh pr create --base $(FIXTURE_BRANCH)-test1-main --title "e2e-test: test1" --body "This is created by e2e-test of #$(GITHUB_PR_NUMBER)" | ||
gh pr merge --squash | ||
git checkout $(FIXTURE_BRANCH)-test1-main | ||
git pull origin --ff-only $(FIXTURE_BRANCH)-test1-main | ||
git branch -D $(FIXTURE_BRANCH)-test1-topic | ||
# test2 (sync failure) | ||
git checkout $(FIXTURE_BRANCH)-test2-main | ||
git checkout -b $(FIXTURE_BRANCH)-test2-topic | ||
sed -i -e 's/app: echoserver/app: echoserver-test2/g' test2-fixture/deployment/echoserver.yaml | ||
git commit -a -m $(FIXTURE_BRANCH)-test2-topic | ||
git push origin $(FIXTURE_BRANCH)-test2-topic | ||
gh pr create --base $(FIXTURE_BRANCH)-test2-main --title "e2e-test: test2" --body "This is created by e2e-test of #$(GITHUB_PR_NUMBER)" | ||
gh pr merge --squash | ||
git checkout $(FIXTURE_BRANCH)-test2-main | ||
git pull origin --ff-only $(FIXTURE_BRANCH)-test2-main | ||
git branch -D $(FIXTURE_BRANCH)-test2-topic | ||
# wait for sync | ||
git checkout $(MAIN_BRANCH_NAME) | ||
git pull origin --ff-only $(MAIN_BRANCH_NAME) | ||
./wait-for-sync-status.sh helloworld OutOfSync | ||
./wait-for-sync-status.sh test1-fixture $(FIXTURE_BRANCH)-test1-main Synced Succeeded | ||
./wait-for-sync-status.sh test2-fixture $(FIXTURE_BRANCH)-test2-main OutOfSync Failed | ||
|
||
# environment | ||
cluster: $(KUBECONFIG) | ||
|
@@ -52,11 +52,8 @@ deploy: deploy-argocd deploy-controller | |
|
||
deploy-argocd: cluster | ||
kustomize build argocd | kubectl apply -f - | ||
git branch $(MAIN_BRANCH_NAME) | ||
git push origin $(MAIN_BRANCH_NAME) | ||
kustomize build applications | sed -e "s/MAIN_BRANCH_NAME/$(MAIN_BRANCH_NAME)/g" | kubectl apply -f - | ||
kustomize build applications | sed -e "s/FIXTURE_BRANCH/$(FIXTURE_BRANCH)/g" | kubectl apply -f - | ||
kubectl -n argocd rollout status statefulsets argocd-application-controller | ||
./wait-for-sync-status.sh helloworld Synced | ||
|
||
deploy-controller: cluster build-controller | ||
kind load docker-image controller:latest --name $(CLUSTER_NAME) | ||
|
@@ -70,13 +67,20 @@ build-controller: | |
undeploy: | ||
kubectl delete namespace/argocd namespace/argocd-commenter-system | ||
|
||
# CI specific tasks | ||
ci-setup: | ||
git config user.name ci | ||
git config user.email [email protected] | ||
setup: | ||
git branch -f $(FIXTURE_BRANCH)-test1-main | ||
git branch -f $(FIXTURE_BRANCH)-test2-main | ||
git push origin -f $(FIXTURE_BRANCH)-test1-main $(FIXTURE_BRANCH)-test2-main | ||
|
||
ci-cleanup: | ||
-git push origin --delete $(MAIN_BRANCH_NAME) | ||
-git push origin --delete $(MAIN_BRANCH_NAME)-fixture1 | ||
-git push origin --delete $(MAIN_BRANCH_NAME)-fixture2 | ||
cleanup: | ||
-git branch -D \ | ||
$(FIXTURE_BRANCH)-test1-main \ | ||
$(FIXTURE_BRANCH)-test1-topic \ | ||
$(FIXTURE_BRANCH)-test2-main \ | ||
$(FIXTURE_BRANCH)-test2-topic | ||
-git push origin --delete \ | ||
$(FIXTURE_BRANCH)-test1-main \ | ||
$(FIXTURE_BRANCH)-test1-topic \ | ||
$(FIXTURE_BRANCH)-test2-main \ | ||
$(FIXTURE_BRANCH)-test2-topic | ||
-kubectl -n argocd-commenter-system logs -l control-plane=controller-manager --all-containers |
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,19 @@ | ||
# end-to-end test | ||
|
||
To run locally: | ||
|
||
```sh | ||
# set up a cluster and deploy argocd | ||
make deploy-argocd | ||
|
||
# set up main branches | ||
make setup | ||
|
||
# run the controller | ||
|
||
# create pull requests | ||
make test | ||
|
||
# clean up branches | ||
make cleanup | ||
``` |
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,2 +1,3 @@ | ||
resources: | ||
- helloworld.yaml | ||
- test1-fixture.yaml | ||
- test2-fixture.yaml |
8 changes: 4 additions & 4 deletions
8
e2e_test/applications/helloworld.yaml → e2e_test/applications/test1-fixture.yaml
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,20 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: test2-fixture | ||
namespace: argocd | ||
spec: | ||
project: default | ||
source: | ||
repoURL: https://github.com/int128/argocd-commenter | ||
targetRevision: FIXTURE_BRANCH-test2-main | ||
path: e2e_test/test2-fixture | ||
destination: | ||
server: https://kubernetes.default.svc | ||
namespace: test2-fixture | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true | ||
retry: | ||
limit: 1 # reduce test time |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,4 @@ | ||
namespace: test1-fixture | ||
resources: | ||
- namespace/test1-fixture.yaml | ||
- deployment/echoserver.yaml |
2 changes: 1 addition & 1 deletion
2
...test/helloworld/namespace/helloworld.yaml → ...est1-fixture/namespace/test1-fixture.yaml
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,4 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: helloworld | ||
name: test1-fixture |
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,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: echoserver | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: echoserver | ||
template: | ||
metadata: | ||
labels: | ||
app: echoserver | ||
spec: | ||
containers: | ||
- image: gcr.io/google_containers/echoserver:1.8 | ||
name: echoserver | ||
ports: | ||
- containerPort: 8080 |
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,4 @@ | ||
namespace: test2-fixture | ||
resources: | ||
- namespace/test2-fixture.yaml | ||
- deployment/echoserver.yaml |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: test2-fixture |
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