Skip to content

Commit

Permalink
chore: test operator with e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Oct 13, 2024
1 parent 0eb262f commit 7730677
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
42 changes: 15 additions & 27 deletions .github/workflows/push-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,25 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: start minikube
id: minikube
uses: medyagh/setup-minikube@master
- uses: azure/setup-helm@v3
- uses: actions/checkout@v4
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Setup Helm
uses: azure/setup-helm@v4
- name: install atlas-operator
run: |
helm install atlas-operator charts/atlas-operator --wait \
--set image.pullPolicy=Always
- name: apply test resources
--set image.pullPolicy=Always
- name: Run e2e tests with Operator
run: |
kubectl apply -k config/integration
- name: wait for test resources
run: |
if ! kubectl wait --for=condition=ready --timeout=120s atlasschemas --all; then
kubectl describe atlasschemas
kubectl describe pods -l atlasgo.io/engine=postgres
kubectl describe pods -l atlasgo.io/engine=mysql
kubectl describe deployments
exit 1
fi
make test-e2e \
ATLAS_TOKEN=${{ secrets.ATLAS_TOKEN }} \
KIND_CLUSTER=chart-testing \
OPERATOR_E2E=true
- name: test env vars
run: |
kubectl apply -k config/integration/env
helm upgrade atlas-operator charts/atlas-operator -f ./config/integration/env/values.yaml --wait
# Find the operator pod
OPERATOR=$(kubectl get pods -o jsonpath='{.items[0].metadata.name}')
# Extract the env from the operator pod
kubectl exec $OPERATOR -- env | grep NORMAL_ENV
kubectl exec $OPERATOR -- env | grep CONFIGMAP_REF_ENV
kubectl exec $OPERATOR -- env | grep SECRET_REF_ENV
helm template atlas-operator charts/atlas-operator \
--set-json=extraEnvs='[{"name":"NORMAL_ENV","value":"value"}]' | grep NORMAL_ENV
helm-push:
name: Push to ghcr.io
needs: [helm-test]
Expand All @@ -66,8 +54,8 @@ jobs:
run:
working-directory: charts/
steps:
- uses: actions/checkout@v3
- uses: azure/setup-helm@v3
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- name: get version
id: version
run: |
Expand Down
23 changes: 14 additions & 9 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@ func TestOperator(t *testing.T) {
}
return string(output), nil
}
// Deploying the controller-manager
_, err = kind("skaffold", "run", "--wait-for-connection=true", "-p", "integration")
require.NoError(t, err)
// Installing the CRDs
_, err = kind("make", "install")
require.NoError(t, err)
t.Cleanup(func() {
_, err = kind("make", "undeploy", "ignore-not-found=true")
// Deploying the controller-manager, installing the CRDs and cleaning up
// the resources after the test, if the environment variable is set
// to run the e2e test
if os.Getenv("OPERATOR_E2E") != "" {
// Deploying the controller-manager
_, err = kind("skaffold", "run", "--wait-for-connection=true", "-p", "integration")
require.NoError(t, err)
})
// Installing the CRDs
_, err = kind("make", "install")
require.NoError(t, err)
t.Cleanup(func() {
_, err = kind("make", "undeploy", "ignore-not-found=true")
require.NoError(t, err)
})
}
// Accept the EULA and set the PID
_, err = kind("kubectl", "set", "env",
"-n", nsController, controller,
Expand Down

0 comments on commit 7730677

Please sign in to comment.