Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/kube-integration-tests-non-root-bypass.yaml
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"'
87 changes: 87 additions & 0 deletions .github/workflows/kube-integration-tests-non-root.yaml
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/') }}
Comment thread
tigrato marked this conversation as resolved.
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
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]\|$$\)')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use grep -w integration - that ends up picking the same set of package as the more complicated regex. But I'm not sure if this is future-proofing against some other package names. I notice there is an integrationv1 package that gets selected since it is within an integration package that might otherwise have been missed with grep -w.

...

Ah, I see it was copied from the integration-root target and a variation of the integration target. I wonder what the logic should be. Perhaps we should just be doing go list ./integration/... - lib/auth/integration seems to be the integration service and nothing to do with integration tests, and integrations/lib/testing/integration seems to be an integration test that make integration skips deliberately.

Any idea exactly which tests should be run here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand Down
5 changes: 5 additions & 0 deletions build.assets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ integration-root: buildbox
docker run $(DOCKERFLAGS) -t $(BUILDBOX) \
/bin/bash -c "make -C $(SRCDIR) FLAGS='-cover' integration-root"

.PHONY:integration-kube
integration-kube: buildbox
docker run $(DOCKERFLAGS) -t $(BUILDBOX) \
/bin/bash -c "make -C $(SRCDIR) FLAGS='-cover' integration-kube"

#
# Runs linters on new changes inside a build container.
#
Expand Down
6 changes: 6 additions & 0 deletions fixtures/kind/config.yaml
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

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ replace (
github.com/julienschmidt/httprouter => github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5
github.com/keys-pub/go-libfido2 => github.com/gravitational/go-libfido2 v1.5.3-0.20230202181331-c71192ef1c8a
github.com/microsoft/go-mssqldb => github.com/gravitational/go-mssqldb v0.11.1-0.20230331180905-0f76f1751cd3
// replace module github.com/moby/spdystream until https://github.com/moby/spdystream/pull/91 merges and deps are updated
// otherwise tests fail with a data race detection.
github.com/moby/spdystream => github.com/gravitational/spdystream v0.0.0-20230512133543-4e46862ca9bf
github.com/sirupsen/logrus => github.com/gravitational/logrus v1.4.4-0.20210817004754-047e20245621
github.com/vulcand/predicate => github.com/gravitational/predicate v1.3.0
// Use our internal crypto fork, to work around the issue with OpenSSH <= 7.6 mentioned here: https://github.com/golang/go/issues/53391
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ github.com/gravitational/redis/v9 v9.0.0-teleport.3 h1:Eg/j3jiNUZ558KDXOqzF682EF
github.com/gravitational/redis/v9 v9.0.0-teleport.3/go.mod h1:8et+z03j0l8N+DvsVnclzjf3Dl/pFHgRk+2Ct1qw66A=
github.com/gravitational/roundtrip v1.0.2 h1:eOCY0NEKKaB0ksJmvhO6lPMFz1pIIef+vyPBTBROQ5c=
github.com/gravitational/roundtrip v1.0.2/go.mod h1:fuI1booM2hLRA/B/m5MRAPOU6mBZNYcNycono2UuTw0=
github.com/gravitational/spdystream v0.0.0-20230512133543-4e46862ca9bf h1:aXnqDSit8L1qhI0+QdbJh+MTUFKXG7qbkZXnfr7L96A=
github.com/gravitational/spdystream v0.0.0-20230512133543-4e46862ca9bf/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
github.com/gravitational/trace v1.2.1 h1:Iaf43aqbKV5H8bdiRs1qByjEHgAfADJ0lt0JwRyu+q8=
github.com/gravitational/trace v1.2.1/go.mod h1:n0ijrq6psJY0sOI/NzLp+xdd8xl79jjwzVOFHDY6+kQ=
github.com/gravitational/ttlmap v0.0.0-20171116003245-91fd36b9004c h1:C2iWDiod8vQ3YnOiCdMP9qYeg2UifQ8KSk36r0NswSE=
Expand Down Expand Up @@ -1070,8 +1072,6 @@ github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
Loading