Skip to content

Commit

Permalink
Add e2e tests for Timoni module
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Sep 23, 2023
1 parent e816d1b commit 5add05d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 9 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ permissions:

jobs:
kind-helm:
strategy:
matrix:
helm-version:
- v3.11.0
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Kubernetes
uses: helm/kind-action@v1.5.0
uses: helm/kind-action@v1.8.0
with:
version: v0.17.0
version: v0.20.0
cluster_name: kind
- name: Build container image
run: |
Expand All @@ -31,7 +27,7 @@ jobs:
- name: Setup Helm
uses: azure/setup-helm@v3
with:
version: ${{ matrix.helm-version }}
version: v3.12.3
- name: Deploy
run: ./test/deploy.sh
- name: Run integration tests
Expand All @@ -40,3 +36,41 @@ jobs:
if: failure()
run: |
kubectl logs -l app=podinfo || true
kind-timoni:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
PODINFO_IMAGE_URL: "test/podinfo"
PODINFO_MODULE_URL: "oci://localhost:5000/podinfo"
PODINFO_VERSION: "0.0.0-devel"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Timoni
uses: stefanprodan/timoni/actions/setup@main
- name: Setup Kubernetes
uses: helm/[email protected]
with:
version: v0.20.0
cluster_name: kind
- name: Build container
run: |
docker build -t ${PODINFO_IMAGE_URL}:${PODINFO_VERSION} --build-arg "REVISION=${GITHUB_SHA}" -f Dockerfile.xx .
kind load docker-image ${PODINFO_IMAGE_URL}:${PODINFO_VERSION}
- name: Build module
run: |
timoni mod push ./timoni/podinfo ${PODINFO_MODULE_URL} -v ${PODINFO_VERSION}
- name: Apply bundle
run: |
timoni bundle apply -f ./timoni/bundles/test.podinfo.cue --runtime-from-env
- name: Verify image
run: |
kubectl -n podinfo get pods -oyaml | grep ${PODINFO_IMAGE_URL}
- name: Debug failure
if: failure()
run: |
kubectl -n podinfo get all || true
66 changes: 66 additions & 0 deletions timoni/bundles/test.podinfo.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
bundle: {
apiVersion: "v1alpha1"
name: "podinfo"

_modURL: "oci://ghcr.io/stefanprodan/modules/podinfo" @timoni(runtime:string:PODINFO_MODULE_URL)
_imgURL: "ghcr.io/stefanprodan/modules/podinfo" @timoni(runtime:string:PODINFO_IMAGE_URL)
_imgTag: "latest" @timoni(runtime:string:PODINFO_VERSION)

instances: {
backend: {
module: url: _modURL
namespace: "podinfo"
values: {
image: {
repository: _imgURL
tag: _imgTag
}
resources: requests: {
cpu: "100m"
memory: "128Mi"
}
autoscaling: {
enabled: true
minReplicas: 1
maxReplicas: 10
cpu: 90
}
}
}
frontend: {
module: url: _modURL
namespace: "podinfo"
values: {
image: {
repository: _imgURL
tag: _imgTag
}
ui: backend: "http://backend.podinfo.svc.cluster.local/echo"
replicas: 2
podSecurityContext: {
runAsUser: 100
runAsGroup: 101
fsGroup: 101
}
securityContext: {
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities: drop: ["ALL"]
seccompProfile: type: "RuntimeDefault"
}
ingress: {
enabled: true
className: "nginx"
host: "podinfo.local"
tls: true
annotations: {
"nginx.ingress.kubernetes.io/ssl-redirect": "false"
"nginx.ingress.kubernetes.io/force-ssl-redirect": "false"
"cert-manager.io/cluster-issuer": "self-signed"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion timoni/podinfo/test_values.cue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ values: {
annotations: "cert-manager.io/cluster-issuer": "letsencrypt"
}

monitoring: enabled: true
monitoring: enabled: false

_mcpu: 100
_mem: 128
Expand Down

0 comments on commit 5add05d

Please sign in to comment.