Skip to content

Commit

Permalink
Add e2e test for CRDs+CRs reconciliation using cert-manager
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Sep 13, 2021
1 parent 4224f13 commit 8791fc7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
echo -e "${RESULT}\n\ndoes not equal\n\n${EXPECTED}"
exit 1
fi
kubectl delete -f config/testdata/status-defaults
- name: Deploy controllers
run: |
make dev-deploy IMG=test/kustomize-controller:latest
Expand All @@ -80,6 +81,11 @@ jobs:
kubectl -n impersonation wait kustomizations/podinfo --for=condition=ready --timeout=4m
kubectl -n impersonation delete kustomizations/podinfo
until kubectl -n impersonation get deploy/podinfo 2>&1 | grep NotFound ; do sleep 2; done
- name: Run CRDs + CRs tests
run: |
kubectl -n kustomize-system apply -f ./config/testdata/crds-crs
kubectl -n kustomize-system wait kustomizations/certs --for=condition=ready --timeout=4m
kubectl -n kustomizer-cert-test wait issuers/my-ca-issuer --for=condition=ready --timeout=1m
- name: Logs
run: |
kubectl -n kustomize-system logs deploy/source-controller
Expand Down
31 changes: 31 additions & 0 deletions config/testdata/crds-crs/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: certs
spec:
interval: 15m
url: https://github.com/stefanprodan/kustomizer
ref:
tag: "v1.1.0"
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: certs
spec:
interval: 10m
path: "./testdata/certs"
prune: true
sourceRef:
kind: GitRepository
name: certs
healthChecks:
- apiVersion: apps/v1
kind: Deployment
name: cert-manager
namespace: cert-manager
- apiVersion: apps/v1
kind: Deployment
name: cert-manager-webhook
namespace: cert-manager
timeout: 2m
9 changes: 6 additions & 3 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,12 @@ func (r *KustomizationReconciler) apply(ctx context.Context, manager *ssa.Resour
var stageTwo []*unstructured.Unstructured

for _, u := range objects {
if manager.IsClusterDefinition(u.GetKind()) {
switch u.GetKind() {
case "CustomResourceDefinition":
stageOne = append(stageOne, u)
} else {
case "Namespace":
stageOne = append(stageOne, u)
default:
stageTwo = append(stageTwo, u)
}
}
Expand Down Expand Up @@ -647,7 +650,7 @@ func (r *KustomizationReconciler) apply(ctx context.Context, manager *ssa.Resour
if len(stageTwo) > 0 {
changeSet, err := manager.ApplyAll(ctx, stageTwo, kustomization.Spec.Force)
if err != nil {
return false, err
return false, fmt.Errorf("%w\n%s", err, changeSetLog.String())
}

if changeSet != nil && len(changeSet.Entries) > 0 {
Expand Down

0 comments on commit 8791fc7

Please sign in to comment.