-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolate envtest tests to local processes, rather than requiring a clu…
…ster (#319) * Run tests with phony K8s API, not existing cluster This commit changes the envtest (Kubernetes API harness) setup to use a fake Kubernetes API rather than the (presumed) existing cluster. This insulates the tests from coincidences -- for example, data that's required for the test and happens to be present in the test author's cluster, but nowhere else. It also ensures the code under test is the code in the working directory, and not the code as it was when last deployed to the cluster. * Remove cluster setup from github workflow * Reduce individual task timeout The timeout for uses of `Eventually` is 10 minutes, but a whole test case times out after 10 minutes -- so any failures will 1. take 10 minutes, and 2. tend to trigger the more opaque whole test case timeout, where you get a process dump rather than a test failure mentioning the line number. This commit reduces the timeout for indvidual `Eventually` calls to 1 minute -- if this turns out to be optimistic in specific cases, some can be increased (or it can be taken as a signal that the test should be reconsidered). * Distinguish between k8s and Pulumi op timeouts Generally we expect Pulumi stacks to take O(minute) to run; but Kubernetes API operations should be near instanteneous, so if they are going to fail, they can fail quickly. Note that deleting Stack objects is a Kubernetes API operation, but will wait for the controller to run a finalizer, which is a stack operation -- so these ops get a stack-proportioned timeout. * Avoid a goroutine leak by ensuring pipes closed The func runCmd uses io.Pipe for both stderr and stdout of the command it runs, so writes on either can be echoed to the log as they happen; and two goroutines for doing that echoing. In process dumps, it's apparent that these goroutines leak -- they are blocked on Scan, which is presumably waiting for an EOF. This commit replaces the explicit pipe plumbing with `Command.StdoutPipe()` and `Command.StderrPipe()`. The Command machinery knows to close the readers when the process has finished writing, so Scan no longer blocks indefinitely. It's also not necessary to start _two_ new goroutines, since we already have one -- that in which we're running. * Avoid deletion with foreground policy in test Foreground propagation propagation relies on a finalizer, which interacts with the operator's finalizer in such a way that prevents deletion indefinitely and for tests to time out (I'm not sure exactly why to be honest, that's just what I observe). It shouldn't be necessary, since the test code in question goes on to wait for the deletion to have taken effect anyway. * Changelog entry for goroutine leak fix Signed-off-by: Michael Bridgen <[email protected]>
- Loading branch information
Showing
17 changed files
with
81 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,15 +44,6 @@ jobs: | |
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19.x | ||
- name: Install Ginkgo testing framework | ||
run: | | ||
# Do the install from outside the code tree to avoid messing with go.sum | ||
cd /tmp; go install github.com/onsi/ginkgo/[email protected] | ||
- name: Setup gcloud CLI for GKE testing cluster | ||
uses: google-github-actions/setup-gcloud@v0 | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
export_default_credentials: true | ||
- name: Configure AWS credentials to use in AWS Stack tests | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
|
@@ -72,15 +63,14 @@ jobs: | |
- name: Tests | ||
run: | | ||
# Create GKE test cluster to install CRDs and use with the test operator. | ||
scripts/ci-cluster-create.sh | ||
scripts/ci-infra-create.sh | ||
# Source the env variables created in the script above | ||
cat ~/.envfile | ||
. ~/.envfile | ||
# Run tests | ||
make codegen install-crds | ||
make test | ||
- name: Cleanup | ||
if: ${{ always() }} | ||
run: | | ||
scripts/ci-cluster-destroy.sh | ||
scripts/ci-infra-destroy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,6 @@ jobs: | |
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.19.x" | ||
- name: Install Ginkgo testing framework | ||
run: | | ||
# Do the install from outside the code tree to avoid messing with go.sum | ||
cd /tmp; go install github.com/onsi/ginkgo/[email protected] | ||
- name: Setup gcloud CLI for GKE testing cluster | ||
uses: google-github-actions/setup-gcloud@v0 | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
export_default_credentials: true | ||
- name: Configure AWS credentials to use in AWS Stack tests | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
|
@@ -44,25 +35,24 @@ jobs: | |
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }} | ||
- name: Install Pulumi CLI | ||
uses: pulumi/setup-pulumi@v2 | ||
- name: Set env variables | ||
- name: Set env variables and path | ||
run: | | ||
echo '$HOME/.pulumi/bin' >> $GITHUB_PATH | ||
echo "STACK=ci-cluster-$(head /dev/urandom | LC_CTYPE=C tr -dc '[:lower:]' | head -c5)" >> $GITHUB_ENV | ||
- name: Tests | ||
run: | | ||
# Create GKE test cluster to install CRDs and use with the test operator. | ||
scripts/ci-cluster-create.sh | ||
scripts/ci-infra-create.sh | ||
# Source the env variables created in the script above | ||
cat ~/.envfile | ||
. ~/.envfile | ||
# Run tests | ||
make codegen install-crds | ||
make test | ||
- name: Cleanup | ||
if: ${{ always() }} | ||
run: | | ||
scripts/ci-cluster-destroy.sh | ||
scripts/ci-infra-destroy.sh | ||
release: | ||
needs: [operator-int-tests] | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,15 +56,6 @@ jobs: | |
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19.x | ||
- name: Install Ginkgo testing framework | ||
run: | | ||
# Do the install from outside the code tree to avoid messing with go.sum | ||
cd /tmp; go install github.com/onsi/ginkgo/[email protected] | ||
- name: Setup gcloud CLI for GKE testing cluster | ||
uses: google-github-actions/setup-gcloud@v0 | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
export_default_credentials: true | ||
- name: Configure AWS credentials to use in AWS Stack tests | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
|
@@ -84,14 +75,14 @@ jobs: | |
- name: Tests | ||
run: | | ||
# Create GKE test cluster to install CRDs and use with the test operator. | ||
scripts/ci-cluster-create.sh | ||
scripts/ci-infra-create.sh | ||
# Source the env variables created in the script above | ||
cat ~/.envfile | ||
. ~/.envfile | ||
# Run tests | ||
make codegen install-crds | ||
make test | ||
- name: Cleanup | ||
if: ${{ always() }} | ||
run: | | ||
scripts/ci-cluster-destroy.sh | ||
scripts/ci-infra-destroy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.