Skip to content

Commit

Permalink
ci: new e2e test "gitlabci-argocd"
Browse files Browse the repository at this point in the history
Signed-off-by: Bird <aflybird0@gmail.com>
  • Loading branch information
aFlyBird0 committed Jan 12, 2023
1 parent ded1004 commit 2156a5e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ env:
DOCKERHUB_TOKEN: ${{ secrets.E2E_DOCKERHUB_TOKEN }}
# for apps
IMAGE_REPO_PASSWORD: ${{ secrets.E2E_DOCKERHUB_TOKEN }}
# token for gitlab.com (of aFlyBird0 now)
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

concurrency:
group: ${{ github.workflow }}
Expand Down Expand Up @@ -72,6 +74,7 @@ jobs:
sudo mv ./kubectl /usr/local/bin/kubectl
- name: copy config files
run: cp ./test/e2e/yaml/e2e-*.yaml ./
# test 1 is git-ops with tools only
- name: test 1 - apply git-ops (tools only)
run: ./dtm apply -f e2e-tools.yaml -y
- name: test 1 - apply git-ops (tools only) again
Expand All @@ -83,21 +86,38 @@ jobs:
run: ./dtm verify -f e2e-tools.yaml
- name: test 1 - clean
run: ./dtm delete -f e2e-tools.yaml -y
# test 2 is git-ops with apps
- name: test 2 - apply (apps)
run: ./dtm apply --debug -f e2e-apps.yaml -y
- name: test 2 - apply (apps) again
run: ./dtm apply -f e2e-apps.yaml -y
- name: test 2 - check if pod is ready
run: while [[ $(kubectl get pods -l app=dtm-e2e-go -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "pod not ready yet..."; sleep 3; done
timeout-minutes: 10
- name: test 3 - check flask app can be reached
run:
- name: test 2 - check flask app can be reached
run: |
# get cluster ip of the service created by the argocd
clusterIP=$(kubectl get svc helloworld -n default -o jsonpath='{.spec.clusterIP}')
clusterIP=$(kubectl get svc dtm-e2e-go -n default -o jsonpath='{.spec.clusterIP}')
# curl flask url and check if it returns "Hello, World!", if not, echo error and exit 1
curl -s http://$clusterIP:8080 | grep "Hello, World!" || (echo "failed to access to flask app" && exit 1)
- name: test 2 - clean
run: ./dtm delete -f e2e-apps.yaml -y
# test3 is gitlabci-argocd
- name: test 3 - apply (gitlabci-argocd)
run: ./dtm apply --debug -f e2e-gitlabci-argocd.yaml -y
- name: test 3 - apply (gitlabci-argocd) again
run: ./dtm apply -f e2e-gitlabci-argocd.yaml -y
- name: test 3 - check if pod is ready
run: while [[ $(kubectl get pods -l app=dtme2egitlabciargocd -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "pod not ready yet..."; sleep 3; done
timeout-minutes: 10
- name: test 3 - check flask app can be reached
run: |
# get cluster ip of the service created by the argocd
clusterIP=$(kubectl get svc dtme2egitlabciargocd -n default -o jsonpath='{.spec.clusterIP}')
# curl flask url and check if it returns "Hello, World!", if not, echo error and exit 1
curl -s http://$clusterIP:8080 | grep "Hello, World!" || (echo "failed to access to flask app" && exit 1)
- name: test 2 - clean
run: ./dtm delete -f e2e-gitlabci-argocd.yaml -y
- name: test e2e success or not
if: failure()
run: |
Expand Down
41 changes: 41 additions & 0 deletions test/e2e/yaml/e2e-gitlabci-argocd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
config:
state:
backend: local
options:
stateFile: devstream-e2e-gitlabci-argocd.state

vars:
appName: dtme2egitlabciargocd
gitlabURL: https://gitlab.com
gitlabUsername: aFlyBird
defaultBranch: main
dockerhubUser: dtme2etest

tools:
- name: helm-installer
instanceID: argocd
apps:
- name: [[ appName ]]
spec:
language: python
framework: flask
repo:
url: [[ gitlabURL ]]/[[ gitlabUsername ]]/[[ appName ]].git
branch: [[ defaultBranch ]]
token: [[ env GITLAB_TOKEN ]] # use "GITLAB_TOKEN" env var
repoTemplate:
url: https://github.com/devstream-io/dtm-repo-scaffolding-python-flask.git
ci:
- type: template
templateName: ci-pipeline
cd:
- type: argocdapp
pipelineTemplates:
- name: ci-pipeline
type: gitlab-ci
options:
imageRepo:
user: [[ dockerhubUser ]]
password: [[ env DOCKERHUB_TOKEN]]
runner:
enable: true

0 comments on commit 2156a5e

Please sign in to comment.