Skip to content
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

Replace integration_tests build tag with INTEGRATION_TESTS env #24925

Merged
merged 5 commits into from
Apr 19, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Documentation/contributing/testing/ci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ example patch that shows how this can be achieved.
steps {
parallel(
"Runtime":{
- sh 'cd ${TESTDIR}; ginkgo --focus="RuntimeValidated" --tags=integration_tests'
+ sh 'cd ${TESTDIR}; ginkgo --focus="XFoooo" --tags=integration_tests'
- sh 'cd ${TESTDIR}; ginkgo --focus="RuntimeValidated"'
+ sh 'cd ${TESTDIR}; ginkgo --focus="XFoooo"'
},
"K8s-1.9":{
- sh 'cd ${TESTDIR}; K8S_VERSION=1.9 ginkgo --focus="K8sValidated" --tags=integration_tests ${FAILFAST}'
+ sh 'cd ${TESTDIR}; K8S_VERSION=1.9 ginkgo --focus="K8sFooooo" --tags=integration_tests ${FAILFAST}'
- sh 'cd ${TESTDIR}; K8S_VERSION=1.9 ginkgo --focus="K8sValidated" ${FAILFAST}'
+ sh 'cd ${TESTDIR}; K8S_VERSION=1.9 ginkgo --focus="K8sFooooo" ${FAILFAST}'
},
failFast: true
)
Expand Down
22 changes: 11 additions & 11 deletions Documentation/contributing/testing/e2e.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ To run all of the runtime tests, execute the following command from the ``test``

.. code-block:: shell-session

ginkgo --focus="Runtime" --tags=integration_tests
INTEGRATION_TESTS=true ginkgo --focus="Runtime"

Ginkgo searches for all tests in all subdirectories that are "named" beginning
with the string "Runtime" and contain any characters after it. For instance,
here is an example showing what tests will be ran using Ginkgo's dryRun option:

.. code-block:: shell-session

$ ginkgo --focus="Runtime" -dryRun --tags=integration_tests
$ INTEGRATION_TESTS=true ginkgo --focus="Runtime" -dryRun
Running Suite: runtime
======================
Random Seed: 1516125117
Expand Down Expand Up @@ -114,14 +114,14 @@ To run all of the Kubernetes tests, run the following command from the ``test``

.. code-block:: shell-session

ginkgo --focus="K8s" --tags=integration_tests
INTEGRATION_TESTS=true ginkgo --focus="K8s"

To run a specific test from the Kubernetes tests suite, run the following command
from the ``test`` directory:

.. code-block:: shell-session

ginkgo --focus="K8s.*Check iptables masquerading with random-fully" --tags=integration_tests
INTEGRATION_TESTS=true ginkgo --focus="K8s.*Check iptables masquerading with random-fully"

Similar to the Runtime test suite, Ginkgo searches for all tests in all
subdirectories that are "named" beginning with the string "K8s" and
Expand All @@ -146,7 +146,7 @@ supported version of Kubernetes, run the test suite with the following format:

.. code-block:: shell-session

K8S_VERSION=<version> ginkgo --focus="K8s" --tags=integration_tests
INTEGRATION_TESTS=true K8S_VERSION=<version> ginkgo --focus="K8s"

.. note::

Expand Down Expand Up @@ -254,7 +254,7 @@ If you want to run one specified test, there are a few options:

.. code-block:: shell-session

ginkgo --focus "Runtime.*L7" --tags=integration_tests
INTEGRATION_TESTS=true ginkgo --focus "Runtime.*L7"


This will focus on tests that contain "Runtime", followed by any
Expand Down Expand Up @@ -457,7 +457,7 @@ Example how to run ginkgo using ``dlv``:

.. code-block:: shell-session

dlv test . --build-flags="-tags=integration_tests" -- --ginkgo.focus="Runtime" -ginkgo.v=true --cilium.provision=false
dlv test . -- --ginkgo.focus="Runtime" -ginkgo.v=true --cilium.provision=false

Running End-To-End Tests In Other Environments via kubeconfig
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -493,7 +493,7 @@ An example invocation is

.. code-block:: shell-session

CNI_INTEGRATION=eks K8S_VERSION=1.16 ginkgo --focus="K8s" --tags=integration_tests -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.image="quay.io/cilium/cilium-ci" -cilium.operator-image="quay.io/cilium/operator" -cilium.operator-suffix="-ci" -cilium.passCLIEnvironment=true
INTEGRATION_TESTS=true CNI_INTEGRATION=eks K8S_VERSION=1.16 ginkgo --focus="K8s" -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.image="quay.io/cilium/cilium-ci" -cilium.operator-image="quay.io/cilium/operator" -cilium.operator-suffix="-ci" -cilium.passCLIEnvironment=true


To run tests with Kind, try
Expand Down Expand Up @@ -529,7 +529,7 @@ cluster.
export CLUSTER_ZONE=us-west2-a
export NATIVE_CIDR="$(gcloud container clusters describe $CLUSTER_NAME --zone $CLUSTER_ZONE --format 'value(clusterIpv4Cidr)')"

CNI_INTEGRATION=gke K8S_VERSION=1.17 ginkgo --focus="K8sDemo" --tags=integration_tests -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.image="quay.io/cilium/cilium-ci" -cilium.operator-image="quay.io/cilium/operator" -cilium.operator-suffix="-ci" -cilium.hubble-relay-image="quay.io/cilium/hubble-relay-ci" -cilium.passCLIEnvironment=true
INTEGRATION_TESTS=true CNI_INTEGRATION=gke K8S_VERSION=1.17 ginkgo --focus="K8sDemo" -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.image="quay.io/cilium/cilium-ci" -cilium.operator-image="quay.io/cilium/operator" -cilium.operator-suffix="-ci" -cilium.hubble-relay-image="quay.io/cilium/hubble-relay-ci" -cilium.passCLIEnvironment=true

.. note:: The kubernetes version defaults to 1.23 but can be configured with
versions between 1.16 and 1.23. Version should match the server
Expand All @@ -551,7 +551,7 @@ AKS (experimental)
.. code-block:: shell-session

export NATIVE_CIDR="10.241.0.0/16"
CNI_INTEGRATION=aks K8S_VERSION=1.17 ginkgo --focus="K8s" --tags=integration_tests -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.passCLIEnvironment=true -cilium.image="mcr.microsoft.com/oss/cilium/cilium" -cilium.tag="1.12.1" -cilium.operator-image="mcr.microsoft.com/oss/cilium/operator" -cilium.operator-suffix="" -cilium.operator-tag="1.12.1"
INTEGRATION_TESTS=true CNI_INTEGRATION=aks K8S_VERSION=1.17 ginkgo --focus="K8s" -- -cilium.provision=false -cilium.kubeconfig=`echo ~/.kube/config` -cilium.passCLIEnvironment=true -cilium.image="mcr.microsoft.com/oss/cilium/cilium" -cilium.tag="1.12.1" -cilium.operator-image="mcr.microsoft.com/oss/cilium/operator" -cilium.operator-suffix="" -cilium.operator-tag="1.12.1"

AWS EKS (experimental)
^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -636,7 +636,7 @@ To run this you can use the following command:

.. code-block:: shell-session

ginkgo --tags=integration_tests -- --cilium.provision=false --cilium.SSHConfig="cat ssh-config"
ginkgo -- --cilium.provision=false --cilium.SSHConfig="cat ssh-config"


VMs for Testing
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ generate-cov: ## Generate HTML coverage report at coverage-all.html.
$(QUIET) rm coverage.out.tmp
@rmdir ./daemon/1 ./daemon/1_backup 2> /dev/null || true

integration-tests: GO_TAGS_FLAGS+=integration_tests
integration-tests: start-kvstores ## Runs all integration tests.
integration-tests: start-kvstores ## Run Go tests including ones that are marked as integration tests.
$(QUIET) $(MAKE) $(SUBMAKEOPTS) -C test/bpf/
ifeq ($(SKIP_VET),"false")
$(MAKE) govet
endif
$(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER)
INTEGRATION_TESTS=true $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER)
$(MAKE) generate-cov
$(MAKE) stop-kvstores

Expand Down Expand Up @@ -587,8 +586,8 @@ endif
$(QUIET) contrib/scripts/check-fmt.sh
@$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh
$(QUIET) contrib/scripts/check-log-newlines.sh
@$(ECHO_CHECK) contrib/scripts/check-privileged-tests-tags.sh
$(QUIET) contrib/scripts/check-privileged-tests-tags.sh
@$(ECHO_CHECK) contrib/scripts/check-test-tags.sh
$(QUIET) contrib/scripts/check-test-tags.sh
@$(ECHO_CHECK) contrib/scripts/check-assert-deep-equals.sh
$(QUIET) contrib/scripts/check-assert-deep-equals.sh
@$(ECHO_CHECK) contrib/scripts/lock-check.sh
Expand Down
12 changes: 0 additions & 12 deletions contrib/scripts/check-privileged-tests-tags.sh

This file was deleted.

12 changes: 12 additions & 0 deletions contrib/scripts/check-test-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

g=$(grep -Elr '^//go:build.*(privileged_tests|integration_tests)' . --include \*_test.go \
--exclude-dir={.git,_build,vendor,test})

if [ -n "$g" ]; then
echo "Test file(s) containing deprecated build tag:"
echo $g
echo
echo "Use testutils.{Privileged,Integration}{Check,Test} for marking tests."
exit 1
fi
2 changes: 1 addition & 1 deletion contrib/testing/integrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gct()
HUBBLE_RELAY_IMAGE="${HUBBLE_RELAY_IMAGE:-"quay.io/cilium/hubble-relay"}" \
HUBBLE_RELAY_IMAGE_TAG="${HUBBLE_RELAY_IMAGE_TAG:-"latest"}" \
K8S_VERSION="$(kubectl version -o json | jq -r '(.serverVersion.major + "." + (.serverVersion.minor | scan("[0-9]+")))' | sed 's/"//g')" \
ginkgo -v "$FOCUS" --tags integration_tests -- \
INTEGRATION_TESTS=true ginkgo -v "$FOCUS" -- \
-cilium.provision=false \
-cilium.kubeconfig=$HOME/.kube/config \
-cilium.passCLIEnvironment=true \
Expand Down
22 changes: 20 additions & 2 deletions daemon/cmd/daemon_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package cmd

import (
Expand Down Expand Up @@ -39,6 +37,7 @@ import (
"github.com/cilium/cilium/pkg/policy"
"github.com/cilium/cilium/pkg/promise"
"github.com/cilium/cilium/pkg/proxy"
"github.com/cilium/cilium/pkg/testutils"
"github.com/cilium/cilium/pkg/types"
)

Expand Down Expand Up @@ -81,6 +80,12 @@ func setupTestDirectories() {
}

func TestMain(m *testing.M) {
if !testutils.IntegrationTests() {
// Immediately run the test suite without manipulating the environment
// if integration tests are not requested.
os.Exit(m.Run())
}

proxy.DefaultDNSProxy = fqdnproxy.MockFQDNProxy{}

// Set up all configuration options which are global to the entire test
Expand Down Expand Up @@ -108,6 +113,7 @@ func TestMain(m *testing.M) {
option.Config.KubeProxyReplacement = option.KubeProxyReplacementDisabled

time.Local = time.UTC

os.Exit(m.Run())
}

Expand All @@ -120,6 +126,8 @@ func (epSync *dummyEpSyncher) DeleteK8sCiliumEndpointSync(e *endpoint.Endpoint)
}

func (ds *DaemonSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)

// Register metrics once before running the suite
_, ds.collectors = metrics.CreateConfiguration([]string{"cilium_endpoint_state"})
metrics.MustRegister(ds.collectors...)
Expand Down Expand Up @@ -216,6 +224,8 @@ type DaemonEtcdSuite struct {
var _ = Suite(&DaemonEtcdSuite{})

func (e *DaemonEtcdSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)

kvstore.SetupDummy("etcd")
e.DaemonSuite.kvstoreInit = true
}
Expand All @@ -235,6 +245,8 @@ type DaemonConsulSuite struct {
var _ = Suite(&DaemonConsulSuite{})

func (e *DaemonConsulSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)

kvstore.SetupDummy("consul")
e.DaemonSuite.kvstoreInit = true
}
Expand Down Expand Up @@ -305,3 +317,9 @@ func (ds *DaemonSuite) GetDNSRules(epID uint16) restore.DNSRules {

func (ds *DaemonSuite) RemoveRestoredDNSRules(epID uint16) {
}

func (ds *DaemonSuite) TestMemoryMap(c *C) {
pid := os.Getpid()
m := memoryMap(pid)
c.Assert(m, Not(Equals), "")
}
18 changes: 0 additions & 18 deletions daemon/cmd/debuginfo_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions daemon/cmd/endpoint_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package cmd

import (
Expand Down
5 changes: 3 additions & 2 deletions daemon/cmd/fqdn_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package cmd

import (
Expand Down Expand Up @@ -38,6 +36,7 @@ import (
"github.com/cilium/cilium/pkg/policy/api"
"github.com/cilium/cilium/pkg/proxy/accesslog"
"github.com/cilium/cilium/pkg/proxy/logger"
"github.com/cilium/cilium/pkg/testutils"
testidentity "github.com/cilium/cilium/pkg/testutils/identity"
)

Expand All @@ -48,6 +47,8 @@ type DaemonFQDNSuite struct {
var _ = Suite(&DaemonFQDNSuite{})

func (ds *DaemonFQDNSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)

re.InitRegexCompileLRU(defaults.FQDNRegexCompileLRUSize)
}

Expand Down
2 changes: 0 additions & 2 deletions daemon/cmd/ipcache_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package cmd

import (
Expand Down
2 changes: 0 additions & 2 deletions daemon/cmd/policy_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package cmd

import (
Expand Down
2 changes: 1 addition & 1 deletion jenkinsfiles/ginkgo-kernel.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pipeline {
}
steps {
sh 'env'
sh 'cd ${TESTDIR}; HOME=${GOPATH} ginkgo --focus="${FOCUS}" --tags=integration_tests -v --failFast=${FAILFAST} -- -cilium.provision=false -cilium.timeout=${GINKGO_TIMEOUT} -cilium.kubeconfig=${TESTDIR}/vagrant-kubeconfig -cilium.passCLIEnvironment=true -cilium.runQuarantined=${RUN_QUARANTINED} -cilium.image=${CILIUM_IMAGE} -cilium.tag=${CILIUM_TAG} -cilium.operator-image=${CILIUM_OPERATOR_IMAGE} -cilium.operator-tag=${CILIUM_OPERATOR_TAG} -cilium.hubble-relay-image=${HUBBLE_RELAY_IMAGE} -cilium.hubble-relay-tag=${HUBBLE_RELAY_TAG} -cilium.operator-suffix="-ci"'
sh 'cd ${TESTDIR}; HOME=${GOPATH} INTEGRATION_TESTS=true ginkgo --focus="${FOCUS}" -v --failFast=${FAILFAST} -- -cilium.provision=false -cilium.timeout=${GINKGO_TIMEOUT} -cilium.kubeconfig=${TESTDIR}/vagrant-kubeconfig -cilium.passCLIEnvironment=true -cilium.runQuarantined=${RUN_QUARANTINED} -cilium.image=${CILIUM_IMAGE} -cilium.tag=${CILIUM_TAG} -cilium.operator-image=${CILIUM_OPERATOR_IMAGE} -cilium.operator-tag=${CILIUM_OPERATOR_TAG} -cilium.hubble-relay-image=${HUBBLE_RELAY_IMAGE} -cilium.hubble-relay-tag=${HUBBLE_RELAY_TAG} -cilium.operator-suffix="-ci"'
}
post {
always {
Expand Down
2 changes: 1 addition & 1 deletion jenkinsfiles/ginkgo-runtime-kernel.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pipeline {
TESTDIR="${GOPATH}/${PROJ_PATH}/test"
}
steps {
sh 'cd ${TESTDIR}; ginkgo --focus="$(python3 get-gh-comment-info.py "${ghprbCommentBody}" | sed "s/^$/Runtime/" | sed "s/K8s.*/NoTests/")" --tags=integration_tests -v --failFast=${FAILFAST} -- -cilium.provision=false -cilium.timeout=${GINKGO_TIMEOUT} -cilium.runQuarantined=${RUN_QUARANTINED}'
sh 'cd ${TESTDIR}; INTEGRATION_TESTS=true ginkgo --focus="$(python3 get-gh-comment-info.py "${ghprbCommentBody}" | sed "s/^$/Runtime/" | sed "s/K8s.*/NoTests/")" -v --failFast=${FAILFAST} -- -cilium.provision=false -cilium.timeout=${GINKGO_TIMEOUT} -cilium.runQuarantined=${RUN_QUARANTINED}'
}
post {
always {
Expand Down
6 changes: 4 additions & 2 deletions pkg/clustermesh/clustermesh_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package clustermesh

import (
Expand Down Expand Up @@ -36,6 +34,10 @@ type ClusterMeshTestSuite struct{}

var _ = Suite(&ClusterMeshTestSuite{})

func (s *ClusterMeshTestSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)
}

var (
nodes = map[string]*testNode{}
nodesMutex lock.RWMutex
Expand Down
2 changes: 0 additions & 2 deletions pkg/clustermesh/config_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package clustermesh

import (
Expand Down
10 changes: 5 additions & 5 deletions pkg/clustermesh/services_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

//go:build integration_tests

package clustermesh

import (
Expand Down Expand Up @@ -49,9 +47,11 @@ type ClusterMeshServicesTestSuite struct {
randomName string
}

var (
_ = Suite(&ClusterMeshServicesTestSuite{})
)
var _ = Suite(&ClusterMeshServicesTestSuite{})

func (s *ClusterMeshServicesTestSuite) SetUpSuite(c *C) {
testutils.IntegrationCheck(c)
}

func (s *ClusterMeshServicesTestSuite) SetUpTest(c *C) {
kvstore.SetupDummy("etcd")
Expand Down