Skip to content

Commit

Permalink
Add smoke tests (#68)
Browse files Browse the repository at this point in the history
Resolves #43 

Just a quick smoke test to make sure the example code works, and that we
don't totally break the synthesis pod lifecycle code (that can't be
easily integration tested).

Co-authored-by: Jordan Olshevski <[email protected]>
  • Loading branch information
jveski and Jordan Olshevski authored Mar 8, 2024
1 parent 398a5e0 commit 03253c5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/smoke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Smoke Tests
on:
push:
workflow_dispatch:
schedule:
- cron: 0 0 * * *

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Create Kind cluster
uses: helm/kind-action@v1

- name: Run tests
timeout-minutes: 5
run: ./hack/smoke-test.sh
11 changes: 8 additions & 3 deletions cmd/eno-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ func main() {
}
}

// TODO: Handle case where resource slices are already deleted but comp still references them

func run() error {
ctx := ctrl.SetupSignalHandler()
var (
debugLogging bool
synconf = &synthesis.Config{}

mgrOpts = &manager.Options{
Rest: ctrl.GetConfigOrDie(),
}
)
flag.Float64Var(&synconf.SliceCreationQPS, "slice-creation-qps", 5, "Max QPS for writing synthesized resources into resource slices")
flag.BoolVar(&debugLogging, "debug", true, "Enable debug logging")
mgrOpts.Bind(flag.CommandLine)
flag.Parse()

zapCfg := zap.NewProductionConfig()
Expand All @@ -43,9 +50,7 @@ func run() error {
}
logger := zapr.NewLogger(zl)

mgr, err := manager.New(logger, &manager.Options{
Rest: ctrl.GetConfigOrDie(),
})
mgr, err := manager.New(logger, mgrOpts)
if err != nil {
return fmt.Errorf("constructing manager: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
"kind":"ConfigMap",
"metadata":{
"name":"some-config",
"namespace": "default",
"namespace": "default"
}
}
]
Expand Down
39 changes: 39 additions & 0 deletions hack/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Wait for apiserver to be ready
while true; do
kubectl api-resources
if [[ $? -eq 0 ]]; then
break
else
sleep 1
fi
done

# Start Eno
kubectl apply -f api/v1/config/crd
go run ./cmd/eno-controller --health-probe-addr=:0 --metrics-addr=:0 &
go run ./cmd/eno-reconciler --health-probe-addr=:0 --metrics-addr=:0 &

# Apply example
kubectl apply -f ./examples/simple.yaml

# Wait for the composition to be reconciled
while true; do
json=$(kubectl get composition test-comp -o=json)
echo "${json}"

# TODO: Check for readiness once supported
echo $json | jq --exit-status '.status.currentState.synthesized'
if [[ $? -eq 0 ]]; then
break
else
sleep 1
fi
done

# Delete the example and wait for cleanup
kubectl delete composition test-comp --wait=true --timeout=1m

# Clean up controller background jobs
kill $(jobs -p)

0 comments on commit 03253c5

Please sign in to comment.