-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Restore Kubernetes Integration tests #25624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # This workflow is required to ensure that required Github check passes even if | ||
| # the actual "Kube Integration Tests (Non-root)" workflow skipped due to path filtering. | ||
| # Otherwise it will stay forever pending. | ||
| # | ||
| # See "Handling skipped but required checks" for more info: | ||
| # | ||
| # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks | ||
| # | ||
| # Note both workflows must have the same name. | ||
|
|
||
| name: Kube Integration Tests (Non-root) | ||
| run-name: Skip Kube Integration Tests (Non-root) - ${{ github.run_id }} - @${{ github.actor }} | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - '.github/workflows/kube-integration-tests-non-root.yaml' | ||
| - '**.go' | ||
| - 'go.mod' | ||
| - 'go.sum' | ||
| - 'build.assets/Makefile' | ||
| - 'build.assets/Dockerfile*' | ||
| - 'Makefile' | ||
| merge_group: | ||
| paths-ignore: | ||
| - '.github/workflows/kube-integration-tests-non-root.yaml' | ||
| - '**.go' | ||
| - 'go.mod' | ||
| - 'go.sum' | ||
| - 'build.assets/Makefile' | ||
| - 'build.assets/Dockerfile*' | ||
| - 'Makefile' | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Kube Integration Tests (Non-root) | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: none | ||
|
|
||
| steps: | ||
| - run: 'echo "No changes to verify"' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: Kube Integration Tests (Non-root) | ||
| run-name: Kube Integration Tests (Non-root) - ${{ github.run_id }} - @${{ github.actor }} | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - branch/* | ||
| pull_request: | ||
| paths: | ||
| - '.github/workflows/kube-integration-tests-non-root.yaml' | ||
| - '**.go' | ||
| - 'go.mod' | ||
| - 'go.sum' | ||
| - 'build.assets/Makefile' | ||
| - 'build.assets/Dockerfile*' | ||
| - 'Makefile' | ||
| merge_group: | ||
| paths: | ||
| - '.github/workflows/kube-integration-tests-non-root.yaml' | ||
| - '**.go' | ||
| - 'go.mod' | ||
| - 'go.sum' | ||
| - 'build.assets/Makefile' | ||
| - 'build.assets/Dockerfile*' | ||
| - 'Makefile' | ||
|
|
||
| env: | ||
| TEST_KUBE: true | ||
| KUBECONFIG: /home/.kube/config | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Kube Integration Tests (Non-root) | ||
| if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | ||
| runs-on: ubuntu-22.04-16core | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: read | ||
|
|
||
| container: | ||
| image: ghcr.io/gravitational/teleport-buildbox:teleport13 | ||
| env: | ||
| WEBASSETS_SKIP_BUILD: 1 | ||
| options: --cap-add=SYS_ADMIN --privileged | ||
|
|
||
| steps: | ||
| - name: Checkout Teleport | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Prepare workspace | ||
| uses: ./.github/actions/prepare-workspace | ||
|
|
||
| - name: Chown | ||
| run: | | ||
| mkdir -p $(go env GOMODCACHE) | ||
| mkdir -p $(go env GOCACHE) | ||
| chown -Rf ci:ci ${GITHUB_WORKSPACE} $(go env GOMODCACHE) $(go env GOCACHE) | ||
| continue-on-error: true | ||
|
|
||
| - name: Create KinD cluster | ||
| uses: helm/kind-action@v1.5.0 | ||
| with: | ||
| cluster_name: kind | ||
| config: fixtures/kind/config.yaml | ||
|
|
||
| # The current container where tests run isn't linked to the KinD network and | ||
| # we won't be able to access the KinD control plane without linking them. | ||
| # This step is required because our tests run in teleport-buildbox container | ||
| # and by default the KinD container network isn't exposed to it. | ||
| # Connecting the network allow us to access the control plane using DNS kind-control-plane. | ||
| # It also copies the default kubeconfig and places it in /home/.kube so ci user | ||
| # is able to access it. | ||
| - name: Link test container to KinD network | ||
| run: | | ||
| docker network connect kind $(cat /etc/hostname) | ||
| kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 | ||
| kubectl cluster-info | ||
| kubectl apply -f fixtures/ci-teleport-rbac/ci-teleport.yaml | ||
| cp -r $HOME/.kube /home/ | ||
| chown -R ci:ci /home/.kube | ||
|
|
||
| - name: Run tests | ||
| timeout-minutes: 40 | ||
| run: | | ||
| runuser -u ci -g ci make rdpclient integration-kube | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -844,6 +844,20 @@ integration: $(TEST_LOG_DIR) $(RENDER_TESTS) | |
| | tee $(TEST_LOG_DIR)/integration.json \ | ||
| | $(RENDER_TESTS) -report-by test | ||
|
|
||
| # | ||
| # Integration tests that run Kubernetes tests in order to complete successfully | ||
| # are run separately to all other integration tests. | ||
| # | ||
| INTEGRATION_KUBE_REGEX := TestKube.* | ||
| .PHONY: integration-kube | ||
| integration-kube: FLAGS ?= -v -race | ||
| integration-kube: PACKAGES = $(shell go list ./... | grep 'integration\([^s]\|$$\)') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use ... Ah, I see it was copied from the Any idea exactly which tests should be run here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thought occurred to me just now that we should probably be using build tags to determine which tests to run rather than grep. Perhaps there is a reason we do not do that already, so maybe we just stick to the current way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the issue about using build tags is that it requires special configuration on the editor in order to LSP load those files correctly and local testing becomes more difficult. |
||
| integration-kube: $(TEST_LOG_DIR) $(RENDER_TESTS) | ||
| @echo KUBECONFIG is: $(KUBECONFIG), TEST_KUBE: $(TEST_KUBE) | ||
| $(CGOFLAG) go test -json -run "$(INTEGRATION_KUBE_REGEX)" $(PACKAGES) $(FLAGS) \ | ||
| | tee $(TEST_LOG_DIR)/integration-kube.json \ | ||
| | $(RENDER_TESTS) -report-by test | ||
|
|
||
| # | ||
| # Integration tests which need to be run as root in order to complete successfully | ||
| # are run separately to all other integration tests. Need a TTY to work. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| networking: | ||
| apiServerAddress: '127.0.0.1' | ||
| apiServerPort: 6443 | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.