Skip to content

Commit

Permalink
Support labels in e2e tests (kubevirt#2860)
Browse files Browse the repository at this point in the history
This PR add the GINKGO_LABELS environment variable so we could use
labels in order filter functional tests, instead of using `Skip()`
within the test logic.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa authored Apr 3, 2024
1 parent 18d028f commit 5676158
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 18 deletions.
5 changes: 5 additions & 0 deletions hack/run-tests-in-container.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

export GINKGO_LABELS="${GINKGO_LABELS:-}"
set -exuo pipefail

INSTALLED_NAMESPACE=${INSTALLED_NAMESPACE:-"kubevirt-hyperconverged"}
Expand Down Expand Up @@ -62,12 +63,15 @@ metadata:
spec:
containers:
- name: functest
imagePullPolicy: Always
args:
- --config-file
- hack/testFiles/test_config.yaml
env:
- name: INSTALLED_NAMESPACE
value: $INSTALLED_NAMESPACE
- name: GINKGO_LABELS
value: "${GINKGO_LABELS}"
image: $FUNC_TEST_IMAGE
volumeMounts:
- mountPath: /test/output
Expand All @@ -77,6 +81,7 @@ spec:
capabilities:
add: ["NET_RAW"]
- name: copy
imagePullPolicy: Always
image: $FUNC_TEST_IMAGE
command: ["/bin/sh"]
args: [ "-c", "trap : TERM INT; sleep infinity & wait"]
Expand Down
4 changes: 3 additions & 1 deletion hack/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ fi
source ./hack/check_operator_condition.sh
printOperatorCondition

${TEST_OUT_PATH}/func-tests.test -ginkgo.v -ginkgo.junit-report="${TEST_OUT_PATH}/output/junit.xml" -installed-namespace="${INSTALLED_NAMESPACE}" -cdi-namespace="${INSTALLED_NAMESPACE}" "$@" "${KUBECONFIG_FLAG}"
GINKGO_LABELS="${GINKGO_LABELS:-}"
echo "GINKGO_LABELS=${GINKGO_LABELS}"
${TEST_OUT_PATH}/func-tests.test -ginkgo.v -ginkgo.junit-report="${TEST_OUT_PATH}/output/junit.xml" -installed-namespace="${INSTALLED_NAMESPACE}" -cdi-namespace="${INSTALLED_NAMESPACE}" --ginkgo.label-filter="${GINKGO_LABELS}" "$@" "${KUBECONFIG_FLAG}"

# wait a minute to allow all VMs to be deleted before attempting to change node placement configuration
sleep 60
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/cli_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
"kubevirt.io/client-go/kubecli"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

var _ = Describe("[rfe_id:5100][crit:medium][vendor:[email protected]][level:system]HyperConverged Cluster Operator should create ConsoleCliDownload objects", func() {
var _ = Describe("[rfe_id:5100][crit:medium][vendor:[email protected]][level:system]HyperConverged Cluster Operator should create ConsoleCliDownload objects", Label("OpenShift"), func() {
flag.Parse()

BeforeEach(func() {
Expand Down
4 changes: 2 additions & 2 deletions tests/func-tests/cluster_eviction_strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("Cluster level evictionStrategy default value", Serial, Ordered
_ = tests.UpdateHCORetry(ctx, cli, hc)
})

It("Should set spec.evictionStrategy = None by default on single worker clusters", func() {
It("Should set spec.evictionStrategy = None by default on single worker clusters", Label("MULTI_NODE_ONLY"), func() {
if !singleworkerCluster {
Skip("Skipping single worker cluster test having more than one worker node")
}
Expand All @@ -55,7 +55,7 @@ var _ = Describe("Cluster level evictionStrategy default value", Serial, Ordered
Expect(hco.Spec.EvictionStrategy).To(Equal(&noneEvictionStrategy))
})

It("Should set spec.evictionStrategy = LiveMigrate by default with multiple worker node", func() {
It("Should set spec.evictionStrategy = LiveMigrate by default with multiple worker node", Label("SINGLE_NODE_ONLY"), func() {
if singleworkerCluster {
Skip("Skipping not single worker cluster test having a single worker node")
}
Expand Down
4 changes: 2 additions & 2 deletions tests/func-tests/console_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"

"time"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -22,14 +21,15 @@ import (
"kubevirt.io/kubevirt/tests/flags"

hcoutil "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

const (
openshiftConsoleNamespace = "openshift-console"
)

var _ = Describe("kubevirt console plugin", func() {
var _ = Describe("kubevirt console plugin", Label("OpenShift"), func() {
var (
cli kubecli.KubevirtClient
ctx context.Context
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
"kubevirt.io/client-go/kubecli"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

var _ = Describe("[rfe_id:5108][crit:medium][vendor:[email protected]][level:system]Dashboard configmaps", func() {
var _ = Describe("[rfe_id:5108][crit:medium][vendor:[email protected]][level:system]Dashboard configmaps", Label("OpenShift"), func() {
flag.Parse()

BeforeEach(func() {
Expand Down
3 changes: 2 additions & 1 deletion tests/func-tests/golden_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"kubevirt.io/ssp-operator/api/v1beta2"

hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

Expand Down Expand Up @@ -64,7 +65,7 @@ var (
}
)

var _ = Describe("golden image test", Label("data-import-cron"), Serial, Ordered, func() {
var _ = Describe("golden image test", Label("data-import-cron"), Serial, Ordered, Label("OpenShift"), func() {
var (
cli kubecli.KubevirtClient
ctx context.Context
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
"kubevirt.io/client-go/kubecli"
"kubevirt.io/kubevirt/tests/flags"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

var runbookClient = http.DefaultClient
Expand All @@ -36,7 +37,7 @@ const (
criticalImpact
)

var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring", Serial, Ordered, func() {
var _ = Describe("[crit:high][vendor:[email protected]][level:system]Monitoring", Serial, Ordered, Label("OpenShift"), func() {
flag.Parse()

var err error
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/mtq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
mtqv1alpha1 "kubevirt.io/managed-tenant-quota/staging/src/kubevirt.io/managed-tenant-quota-api/pkg/apis/core/v1alpha1"

hcoutil "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

Expand Down Expand Up @@ -54,7 +55,7 @@ var _ = Describe("Test MTQ", Label("MTQ"), Serial, Ordered, func() {
})

When("set the EnableManagedTenantQuota FG", func() {
It("should create the MTQ CR and all the pods", func() {
It("should create the MTQ CR and all the pods", Label("MULTI_NODE_ONLY"), func() {

if singleWorkerCluster {
Skip("Don't test MTQ on single node")
Expand Down Expand Up @@ -89,7 +90,7 @@ var _ = Describe("Test MTQ", Label("MTQ"), Serial, Ordered, func() {
Should(Succeed())
})

It("should reject setting of the FG in SNO", func() {
It("should reject setting of the FG in SNO", Label("SINGLE_NODE_ONLY"), func() {
if !singleWorkerCluster {
Skip("this test is not relevant for highly available clusters")
}
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/node_placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (

networkaddonsv1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
"kubevirt.io/client-go/kubecli"
sdkapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
"kubevirt.io/kubevirt/tests/flags"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

const (
Expand All @@ -26,7 +27,7 @@ const (
workloads = "workloads"
)

var _ = Describe("[rfe_id:4356][crit:medium][vendor:[email protected]][level:system]Node Placement", Ordered, Serial, func() {
var _ = Describe("[rfe_id:4356][crit:medium][vendor:[email protected]][level:system]Node Placement", Ordered, Serial, Label("MULTI_NODE_ONLY"), func() {
ctx := context.TODO()
tests.FlagParse()
hco := &hcov1beta1.HyperConverged{}
Expand Down
5 changes: 3 additions & 2 deletions tests/func-tests/quickstart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
"kubevirt.io/client-go/kubecli"

tests "github.com/kubevirt/hyperconverged-cluster-operator/tests/func-tests"
)

var _ = Describe("[rfe_id:5882][crit:high][vendor:[email protected]][level:system]ConsoleQuickStart objects", func() {
var _ = Describe("[rfe_id:5882][crit:high][vendor:[email protected]][level:system]ConsoleQuickStart objects", Label("OpenShift"), func() {
flag.Parse()

BeforeEach(func() {
Expand Down

0 comments on commit 5676158

Please sign in to comment.