From 9f3ab727dca958c7158d6c48d466715e536a9a9a Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Mon, 21 Mar 2022 13:51:17 +0100 Subject: [PATCH] foo Signed-off-by: Quique Llorente --- .golangci.yml | 2 +- Makefile | 21 +- automation/check-patch.e2e-k8s.sh | 4 +- automation/check-patch.e2e-operator-k8s.sh | 2 +- automation/check-patch.unit-test.sh | 7 +- controllers/handler/handler_suite_test.go | 7 +- controllers/handler/node_controller_test.go | 2 +- ...kconfigurationenactment_controller_test.go | 2 +- ...workconfigurationpolicy_controller_test.go | 3 +- .../operator/nmstate_controller_test.go | 2 +- controllers/operator/operator_suite_test.go | 7 +- .../conditions/conditions_suite_test.go | 7 +- .../conditions/counter_test.go | 3 +- .../enactmentstatus_suite_test.go | 7 +- pkg/enactmentstatus/message_test.go | 2 +- pkg/helper/bridges_test.go | 25 ++- pkg/helper/helper_suite_test.go | 7 +- pkg/nmpolicy/generate_test.go | 2 +- pkg/nmpolicy/nmpolicy_suite_test.go | 7 +- pkg/node/node_suite_test.go | 7 +- pkg/node/nodes_test.go | 3 +- pkg/policyconditions/conditions_test.go | 3 +- .../policyconditions_suite_test.go | 7 +- pkg/selectors/labels_test.go | 3 +- pkg/selectors/selectors_suite_test.go | 7 +- pkg/state/filter_test.go | 2 +- pkg/state/state_suite_test.go | 7 +- .../conditions_test.go | 2 +- ...denetworkconfigurationpolicy_suite_test.go | 2 +- .../timestamp_test.go | 2 +- .../validation_test.go | 3 +- test/cmd/run.go | 2 +- .../handler/bonding_default_interface_test.go | 2 +- .../handler/default_bridged_network_test.go | 2 +- ...ault_bridged_network_with_nmpolicy_test.go | 2 +- .../default_ovs_bridged_network_test.go | 2 +- test/e2e/handler/dns_test.go | 2 +- .../handler/error_messages_formatting_test.go | 2 +- test/e2e/handler/examples_test.go | 2 +- test/e2e/handler/main_test.go | 30 +-- .../multiple_policies_for_same_node_test.go | 2 +- test/e2e/handler/nnce_conditions_test.go | 10 +- test/e2e/handler/nnce_desiredstate_test.go | 2 +- test/e2e/handler/nncp_cleanup_test.go | 2 +- test/e2e/handler/nncp_parallel_test.go | 2 +- test/e2e/handler/nns_dependencies_test.go | 2 +- test/e2e/handler/nns_filter_test.go | 2 +- test/e2e/handler/nns_update_timestamp_test.go | 2 +- test/e2e/handler/node_selector_test.go | 6 +- test/e2e/handler/nodes_test.go | 6 +- test/e2e/handler/rollback_test.go | 6 +- .../handler/simple_bridge_and_bond_test.go | 2 +- .../simple_ovs_bridge_and_bond_test.go | 2 +- test/e2e/handler/simple_ovs_bridge_test.go | 2 +- test/e2e/handler/simple_vlan_and_ip_test.go | 2 +- .../e2e/handler/static_addr_and_route_test.go | 2 +- test/e2e/handler/upgrade_test.go | 2 +- test/e2e/handler/user_guide_test.go | 2 +- test/e2e/handler/utils.go | 2 +- test/e2e/handler/webhook_test.go | 2 +- test/e2e/openshift.cnv.workflow.sh | 29 --- test/e2e/operator/main_test.go | 32 +-- test/e2e/operator/nmstate_install_test.go | 2 +- test/reporter/reporter.go | 39 ++-- test/reporter/reporter.go.orig | 197 ++++++++++++++++++ test/reporter/writers.go | 15 +- tools.go | 2 +- 67 files changed, 355 insertions(+), 234 deletions(-) delete mode 100755 test/e2e/openshift.cnv.workflow.sh create mode 100644 test/reporter/reporter.go.orig diff --git a/.golangci.yml b/.golangci.yml index 7b2d10f71..169c03f3d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,7 +47,7 @@ linters-settings: require-explanation: false # don't require an explanation for nolint directives require-specific: false # don't require nolint directives to be specific about which linter is being skipped stylecheck: - dot-import-whitelist: ["github.com/onsi/gomega", "github.com/onsi/ginkgo", "github.com/onsi/gomega/gstruct"] + dot-import-whitelist: ["github.com/onsi/gomega", "github.com/onsi/ginkgo/v2", "github.com/onsi/gomega/gstruct"] linters: disable-all: true diff --git a/Makefile b/Makefile index 5bd47f4f8..60922bdb3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ SHELL := /bin/bash PWD = $(shell pwd) +GO_VERSION = $(shell hack/go-version.sh) export IMAGE_REGISTRY ?= quay.io IMAGE_REPO ?= nmstate @@ -29,9 +30,9 @@ HANDLER_PULL_POLICY ?= Always OPERATOR_PULL_POLICY ?= Always export IMAGE_BUILDER ?= docker -WHAT ?= ./pkg ./controllers +WHAT ?= ./pkg/... ./controllers/... -unit_test_args ?= -r -keepGoing --randomizeAllSpecs --randomizeSuites --race --trace $(UNIT_TEST_ARGS) +unit_test_args ?= -r -keep-going --randomize-all --randomize-suites --race --trace $(UNIT_TEST_ARGS) export KUBEVIRT_PROVIDER ?= k8s-1.21 export KUBEVIRT_NUM_NODES ?= 2 # 1 control-plane, 1 worker needed for e2e tests @@ -39,7 +40,7 @@ export KUBEVIRT_NUM_SECONDARY_NICS ?= 2 export E2E_TEST_TIMEOUT ?= 80m -e2e_test_args = -v -timeout=$(E2E_TEST_TIMEOUT) -slowSpecThreshold=60 $(E2E_TEST_ARGS) +e2e_test_args = -v -timeout=$(E2E_TEST_TIMEOUT) --slow-spec-threshold=60s $(E2E_TEST_ARGS) ifeq ($(findstring k8s,$(KUBEVIRT_PROVIDER)),k8s) export PRIMARY_NIC ?= eth0 @@ -61,7 +62,7 @@ export KUBECTL ?= ./cluster/kubectl.sh KUBECTL ?= ./cluster/kubectl.sh OPERATOR_SDK ?= $(GOBIN)/operator-sdk -GINKGO = go run github.com/onsi/ginkgo/ginkgo +GINKGO = go run github.com/onsi/ginkgo/v2/ginkgo CONTROLLER_GEN = go run sigs.k8s.io/controller-tools/cmd/controller-gen OPM = go run -tags=json1 github.com/operator-framework/operator-registry/cmd/opm @@ -156,16 +157,16 @@ push-operator: operator-manager push: push-handler push-operator test/unit/api: - cd api && $(GINKGO) $(unit_test_args) ./... + cd api && $(GINKGO) --junit-report=junit-api-unit-test.xml $(unit_test_args) ./... test/unit: test/unit/api - NODE_NAME=node01 $(GINKGO) $(unit_test_args) $(WHAT) + NODE_NAME=node01 $(GINKGO) --junit-report=junit-pkg-controller-unit-test.xml $(unit_test_args) $(WHAT) test-e2e-handler: - KUBECONFIG=$(KUBECONFIG) OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) $(GINKGO) $(e2e_test_args) ./test/e2e/handler ... -- $(E2E_TEST_SUITE_ARGS) + KUBECONFIG=$(KUBECONFIG) OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) $(GINKGO) $(e2e_test_args) ./test/e2e/handler ... test-e2e-operator: manifests - KUBECONFIG=$(KUBECONFIG) OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) $(GINKGO) $(e2e_test_args) ./test/e2e/operator ... -- $(E2E_TEST_SUITE_ARGS) + KUBECONFIG=$(KUBECONFIG) OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE) $(GINKGO) $(e2e_test_args) ./test/e2e/operator ... test-e2e: test-e2e-operator test-e2e-handler @@ -198,10 +199,10 @@ release: hack/release.sh vendor-api: - cd api && go mod tidy && go mod vendor + cd api && go mod tidy -compat=$(GO_VERSION) && go mod vendor vendor: vendor-api - go mod tidy + go mod tidy -compat=$(GO_VERSION) go mod vendor # Generate bundle manifests and metadata, then validate generated files. diff --git a/automation/check-patch.e2e-k8s.sh b/automation/check-patch.e2e-k8s.sh index 6e6e87666..11a297f5e 100755 --- a/automation/check-patch.e2e-k8s.sh +++ b/automation/check-patch.e2e-k8s.sh @@ -31,9 +31,7 @@ main() { trap teardown EXIT SIGINT SIGTERM SIGSTOP make cluster-sync - export E2E_TEST_SUITE_ARGS="--junit-output=$ARTIFACTS/junit.functest.xml" - - make E2E_TEST_TIMEOUT=2h E2E_TEST_ARGS="-noColor" test-e2e-handler + make E2E_TEST_TIMEOUT=2h E2E_TEST_ARGS="--no-color --output-dir=$ARTIFACTS --junit-report=junit.functest.xml" test-e2e-handler } [[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.e2e-operator-k8s.sh b/automation/check-patch.e2e-operator-k8s.sh index 17ef9a0bb..49da8aa85 100755 --- a/automation/check-patch.e2e-operator-k8s.sh +++ b/automation/check-patch.e2e-operator-k8s.sh @@ -28,7 +28,7 @@ main() { make cluster-up trap teardown EXIT SIGINT SIGTERM SIGSTOP make cluster-sync-operator - make E2E_TEST_TIMEOUT=1h E2E_TEST_ARGS="-noColor" E2E_TEST_SUITE_ARGS="--junit-output=$ARTIFACTS/junit.functest.xml" test-e2e-operator + make E2E_TEST_TIMEOUT=1h E2E_TEST_ARGS="--no-color --output-dir=$ARTIFACTS --junit-report=junit.functest.xml" test-e2e-operator } [[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.unit-test.sh b/automation/check-patch.unit-test.sh index 6ed18dd12..0ebcb17d9 100755 --- a/automation/check-patch.unit-test.sh +++ b/automation/check-patch.unit-test.sh @@ -7,16 +7,11 @@ # yum -y install automation/check-patch.packages # automation/check-patch.e2e-k8s.sh -teardown() { - cp $(find . -name "*junit*.xml") $ARTIFACTS -} - main() { source automation/check-patch.setup.sh cd ${TMP_PROJECT_PATH} make all - trap teardown EXIT SIGINT SIGTERM SIGSTOP - make UNIT_TEST_ARGS="-noColor --compilers=2" test/unit + make UNIT_TEST_ARGS="--output-dir=$ARTIFACTS --no-color --compilers=2" test/unit } [[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/controllers/handler/handler_suite_test.go b/controllers/handler/handler_suite_test.go index 99bad4e22..dee0b45ab 100644 --- a/controllers/handler/handler_suite_test.go +++ b/controllers/handler/handler_suite_test.go @@ -20,14 +20,11 @@ package controllers import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controllers_handler_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Controllers Handler Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Controllers Handler Test Suite") } diff --git a/controllers/handler/node_controller_test.go b/controllers/handler/node_controller_test.go index 49d253bd0..241ae820f 100644 --- a/controllers/handler/node_controller_test.go +++ b/controllers/handler/node_controller_test.go @@ -23,7 +23,7 @@ import ( nmstate "github.com/nmstate/kubernetes-nmstate/pkg/helper" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/controllers/handler/nodenetworkconfigurationenactment_controller_test.go b/controllers/handler/nodenetworkconfigurationenactment_controller_test.go index e0792c31a..e6e0a8c55 100644 --- a/controllers/handler/nodenetworkconfigurationenactment_controller_test.go +++ b/controllers/handler/nodenetworkconfigurationenactment_controller_test.go @@ -20,7 +20,7 @@ package controllers import ( "context" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/handler/nodenetworkconfigurationpolicy_controller_test.go b/controllers/handler/nodenetworkconfigurationpolicy_controller_test.go index 5249d79ef..423b631f9 100644 --- a/controllers/handler/nodenetworkconfigurationpolicy_controller_test.go +++ b/controllers/handler/nodenetworkconfigurationpolicy_controller_test.go @@ -20,8 +20,7 @@ package controllers import ( "context" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/operator/nmstate_controller_test.go b/controllers/operator/nmstate_controller_test.go index 81847c164..179f6ffeb 100644 --- a/controllers/operator/nmstate_controller_test.go +++ b/controllers/operator/nmstate_controller_test.go @@ -26,7 +26,7 @@ import ( goruntime "runtime" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/controllers/operator/operator_suite_test.go b/controllers/operator/operator_suite_test.go index 62fadfa68..18987a96c 100644 --- a/controllers/operator/operator_suite_test.go +++ b/controllers/operator/operator_suite_test.go @@ -20,14 +20,11 @@ package controllers import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controllers_operator_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Controllers Operator Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Controllers Operator Test Suite") } diff --git a/pkg/enactmentstatus/conditions/conditions_suite_test.go b/pkg/enactmentstatus/conditions/conditions_suite_test.go index 2b3eedcb2..e1abf2f87 100644 --- a/pkg/enactmentstatus/conditions/conditions_suite_test.go +++ b/pkg/enactmentstatus/conditions/conditions_suite_test.go @@ -20,14 +20,11 @@ package conditions import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controller-nodenetworkconfigurationpolicy-enactmentstatus-conditions_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Enactment Status Conditions Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Enactment Status Conditions Test Suite") } diff --git a/pkg/enactmentstatus/conditions/counter_test.go b/pkg/enactmentstatus/conditions/counter_test.go index 2970c1ae2..f70013bb6 100644 --- a/pkg/enactmentstatus/conditions/counter_test.go +++ b/pkg/enactmentstatus/conditions/counter_test.go @@ -18,8 +18,7 @@ limitations under the License. package conditions import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/pkg/enactmentstatus/enactmentstatus_suite_test.go b/pkg/enactmentstatus/enactmentstatus_suite_test.go index f840919f9..387475de4 100644 --- a/pkg/enactmentstatus/enactmentstatus_suite_test.go +++ b/pkg/enactmentstatus/enactmentstatus_suite_test.go @@ -20,14 +20,11 @@ package enactmentstatus import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.enactmentstatus-enactmentstatus_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Enactment Status Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Enactment Status Test Suite") } diff --git a/pkg/enactmentstatus/message_test.go b/pkg/enactmentstatus/message_test.go index 6882e7f63..32c950a83 100644 --- a/pkg/enactmentstatus/message_test.go +++ b/pkg/enactmentstatus/message_test.go @@ -18,7 +18,7 @@ limitations under the License. package enactmentstatus import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/pkg/helper/bridges_test.go b/pkg/helper/bridges_test.go index 9d0db4efd..59bae27f0 100644 --- a/pkg/helper/bridges_test.go +++ b/pkg/helper/bridges_test.go @@ -18,8 +18,7 @@ limitations under the License. package helper import ( - . "github.com/onsi/ginkgo" - "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" @@ -467,67 +466,67 @@ var _ = Describe("testing slice intersection", func() { expectedIntersection []string } - table.DescribeTable("Slice intersection cases", + DescribeTable("Slice intersection cases", func(c intersectionCase) { result := intersectSlices(c.s1, c.s2) Expect(result).To(Equal(c.expectedIntersection)) }, - table.Entry( + Entry( "Both slices empty", intersectionCase{ s1: []string{}, s2: []string{}, expectedIntersection: []string{}, }), - table.Entry("Empty first slice", + Entry("Empty first slice", intersectionCase{ s1: []string{}, s2: []string{"foo"}, expectedIntersection: []string{}, }), - table.Entry("Empty second slice", + Entry("Empty second slice", intersectionCase{ s1: []string{"foo"}, s2: []string{}, expectedIntersection: []string{}, }), - table.Entry("No common elements", + Entry("No common elements", intersectionCase{ s1: []string{"foo"}, s2: []string{"bar"}, expectedIntersection: []string{}, }), - table.Entry("One common element with extra in first slice", + Entry("One common element with extra in first slice", intersectionCase{ s1: []string{"foo", "bar"}, s2: []string{"bar"}, expectedIntersection: []string{"bar"}, }), - table.Entry("One common element with extra in first slice", + Entry("One common element with extra in first slice", intersectionCase{ s1: []string{"bar"}, s2: []string{"bar", "foo"}, expectedIntersection: []string{"bar"}, }), - table.Entry("One common element with extra in first slice", + Entry("One common element with extra in first slice", intersectionCase{ s1: []string{"bar"}, s2: []string{"bar", "foo"}, expectedIntersection: []string{"bar"}, }), - table.Entry("Both identical with two elements", + Entry("Both identical with two elements", intersectionCase{ s1: []string{"foo", "bar"}, s2: []string{"bar", "foo"}, expectedIntersection: []string{"bar", "foo"}, }), - table.Entry("Duplicates in first slice", + Entry("Duplicates in first slice", intersectionCase{ s1: []string{"foo", "bar", "one", "two", "three", "one", "two", "three"}, s2: []string{"bar", "foo", "three", "one"}, expectedIntersection: []string{"bar", "foo", "three", "one"}, }), - table.Entry("Duplicates in second slice", + Entry("Duplicates in second slice", intersectionCase{ s1: []string{"bar", "foo", "three", "one"}, s2: []string{"foo", "bar", "one", "two", "three", "one", "two", "three"}, diff --git a/pkg/helper/helper_suite_test.go b/pkg/helper/helper_suite_test.go index ec410ae99..82155a9ce 100644 --- a/pkg/helper/helper_suite_test.go +++ b/pkg/helper/helper_suite_test.go @@ -20,14 +20,11 @@ package helper import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controller-nodenetworkconfigurationpolicy-helpers-names_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Helpers Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Helpers Test Suite") } diff --git a/pkg/nmpolicy/generate_test.go b/pkg/nmpolicy/generate_test.go index 336e2713e..6dad98cda 100644 --- a/pkg/nmpolicy/generate_test.go +++ b/pkg/nmpolicy/generate_test.go @@ -26,7 +26,7 @@ import ( nmpolicytypes "github.com/nmstate/nmpolicy/nmpolicy/types" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/pkg/nmpolicy/nmpolicy_suite_test.go b/pkg/nmpolicy/nmpolicy_suite_test.go index 3d8643188..23d1f24d1 100644 --- a/pkg/nmpolicy/nmpolicy_suite_test.go +++ b/pkg/nmpolicy/nmpolicy_suite_test.go @@ -20,14 +20,11 @@ package nmpolicy import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.nmpolicy_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "NMPolicy Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "NMPolicy Test Suite") } diff --git a/pkg/node/node_suite_test.go b/pkg/node/node_suite_test.go index 4071d34fd..5e9cbde02 100644 --- a/pkg/node/node_suite_test.go +++ b/pkg/node/node_suite_test.go @@ -20,14 +20,11 @@ package node import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controller-nodenetworkconfigurationpolicy-node-node_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Node Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Node Test Suite") } diff --git a/pkg/node/nodes_test.go b/pkg/node/nodes_test.go index 128c98fb6..7fcb6a80f 100644 --- a/pkg/node/nodes_test.go +++ b/pkg/node/nodes_test.go @@ -18,8 +18,7 @@ limitations under the License. package node import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/types" diff --git a/pkg/policyconditions/conditions_test.go b/pkg/policyconditions/conditions_test.go index 3fc9d9ffb..f7c5e9db0 100644 --- a/pkg/policyconditions/conditions_test.go +++ b/pkg/policyconditions/conditions_test.go @@ -22,8 +22,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/pkg/policyconditions/policyconditions_suite_test.go b/pkg/policyconditions/policyconditions_suite_test.go index 86359b98a..ef2bf34ff 100644 --- a/pkg/policyconditions/policyconditions_suite_test.go +++ b/pkg/policyconditions/policyconditions_suite_test.go @@ -20,11 +20,9 @@ package policyconditions import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/onsi/ginkgo/reporters" - logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" ) @@ -35,6 +33,5 @@ var _ = BeforeSuite(func() { func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controller-nodenetworkconfigurationpolicy-policyconditions-policyconditions_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Conditions Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Conditions Test Suite") } diff --git a/pkg/selectors/labels_test.go b/pkg/selectors/labels_test.go index 879597470..0ce1f85d6 100644 --- a/pkg/selectors/labels_test.go +++ b/pkg/selectors/labels_test.go @@ -18,8 +18,7 @@ limitations under the License. package selectors import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/types" diff --git a/pkg/selectors/selectors_suite_test.go b/pkg/selectors/selectors_suite_test.go index 78078632d..bc8bf9030 100644 --- a/pkg/selectors/selectors_suite_test.go +++ b/pkg/selectors/selectors_suite_test.go @@ -20,14 +20,11 @@ package selectors import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.controller-nodenetworkconfigurationpolicy-selectors-selectors_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Policy Selectors Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Policy Selectors Test Suite") } diff --git a/pkg/state/filter_test.go b/pkg/state/filter_test.go index 28a035151..87aa46ceb 100644 --- a/pkg/state/filter_test.go +++ b/pkg/state/filter_test.go @@ -18,7 +18,7 @@ limitations under the License. package state import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" networkmanager "github.com/phoracek/networkmanager-go/src" diff --git a/pkg/state/state_suite_test.go b/pkg/state/state_suite_test.go index bd9857c7d..c450243cb 100644 --- a/pkg/state/state_suite_test.go +++ b/pkg/state/state_suite_test.go @@ -20,14 +20,11 @@ package state import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "github.com/onsi/ginkgo/reporters" ) func TestUnit(t *testing.T) { RegisterFailHandler(Fail) - junitReporter := reporters.NewJUnitReporter("junit.state-state_suite_test.xml") - RunSpecsWithDefaultAndCustomReporters(t, "Helper Test Suite", []Reporter{junitReporter}) + RunSpecs(t, "Helper Test Suite") } diff --git a/pkg/webhook/nodenetworkconfigurationpolicy/conditions_test.go b/pkg/webhook/nodenetworkconfigurationpolicy/conditions_test.go index 495276acc..23eaf9857 100644 --- a/pkg/webhook/nodenetworkconfigurationpolicy/conditions_test.go +++ b/pkg/webhook/nodenetworkconfigurationpolicy/conditions_test.go @@ -22,7 +22,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/pkg/webhook/nodenetworkconfigurationpolicy/nodenetworkconfigurationpolicy_suite_test.go b/pkg/webhook/nodenetworkconfigurationpolicy/nodenetworkconfigurationpolicy_suite_test.go index 79dd965f2..621d7ede0 100644 --- a/pkg/webhook/nodenetworkconfigurationpolicy/nodenetworkconfigurationpolicy_suite_test.go +++ b/pkg/webhook/nodenetworkconfigurationpolicy/nodenetworkconfigurationpolicy_suite_test.go @@ -21,7 +21,7 @@ import ( "encoding/json" "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" jsonpatch "github.com/evanphx/json-patch" diff --git a/pkg/webhook/nodenetworkconfigurationpolicy/timestamp_test.go b/pkg/webhook/nodenetworkconfigurationpolicy/timestamp_test.go index 329ea72ed..6952a31d2 100644 --- a/pkg/webhook/nodenetworkconfigurationpolicy/timestamp_test.go +++ b/pkg/webhook/nodenetworkconfigurationpolicy/timestamp_test.go @@ -22,7 +22,7 @@ import ( "strconv" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/webhook" diff --git a/pkg/webhook/nodenetworkconfigurationpolicy/validation_test.go b/pkg/webhook/nodenetworkconfigurationpolicy/validation_test.go index b9177729c..aa2e4c97e 100644 --- a/pkg/webhook/nodenetworkconfigurationpolicy/validation_test.go +++ b/pkg/webhook/nodenetworkconfigurationpolicy/validation_test.go @@ -18,8 +18,7 @@ limitations under the License. package nodenetworkconfigurationpolicy import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/cmd/run.go b/test/cmd/run.go index 9961adc37..805e931f7 100644 --- a/test/cmd/run.go +++ b/test/cmd/run.go @@ -23,7 +23,7 @@ import ( "os/exec" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) func Run(command string, quiet bool, arguments ...string) (string, error) { diff --git a/test/e2e/handler/bonding_default_interface_test.go b/test/e2e/handler/bonding_default_interface_test.go index 6d3d5b539..c09a1f7fa 100644 --- a/test/e2e/handler/bonding_default_interface_test.go +++ b/test/e2e/handler/bonding_default_interface_test.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/default_bridged_network_test.go b/test/e2e/handler/default_bridged_network_test.go index 30d8f2d5a..20b55dce4 100644 --- a/test/e2e/handler/default_bridged_network_test.go +++ b/test/e2e/handler/default_bridged_network_test.go @@ -22,7 +22,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/test/e2e/handler/default_bridged_network_with_nmpolicy_test.go b/test/e2e/handler/default_bridged_network_with_nmpolicy_test.go index eed90dccb..f7230e190 100644 --- a/test/e2e/handler/default_bridged_network_with_nmpolicy_test.go +++ b/test/e2e/handler/default_bridged_network_with_nmpolicy_test.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/default_ovs_bridged_network_test.go b/test/e2e/handler/default_ovs_bridged_network_test.go index 1de882fd9..487342f73 100644 --- a/test/e2e/handler/default_ovs_bridged_network_test.go +++ b/test/e2e/handler/default_ovs_bridged_network_test.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/dns_test.go b/test/e2e/handler/dns_test.go index 72720b7a3..6945b15cb 100644 --- a/test/e2e/handler/dns_test.go +++ b/test/e2e/handler/dns_test.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/error_messages_formatting_test.go b/test/e2e/handler/error_messages_formatting_test.go index 40da20fce..69e921177 100644 --- a/test/e2e/handler/error_messages_formatting_test.go +++ b/test/e2e/handler/error_messages_formatting_test.go @@ -22,7 +22,7 @@ import ( nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" enactmentconditions "github.com/nmstate/kubernetes-nmstate/pkg/enactmentstatus/conditions" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/handler/examples_test.go b/test/e2e/handler/examples_test.go index c23e1fd41..9695c3d0f 100644 --- a/test/e2e/handler/examples_test.go +++ b/test/e2e/handler/examples_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) type exampleSpec struct { diff --git a/test/e2e/handler/main_test.go b/test/e2e/handler/main_test.go index 677b6e9c3..2550a0d04 100644 --- a/test/e2e/handler/main_test.go +++ b/test/e2e/handler/main_test.go @@ -24,20 +24,19 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" - ginkgoreporters "kubevirt.io/qe-tools/pkg/ginkgo-reporters" - corev1 "k8s.io/api/core/v1" - knmstatereporter "github.com/nmstate/kubernetes-nmstate/test/reporter" "sigs.k8s.io/controller-runtime/pkg/client" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" testenv "github.com/nmstate/kubernetes-nmstate/test/env" "github.com/nmstate/kubernetes-nmstate/test/environment" + knmstatereporter "github.com/nmstate/kubernetes-nmstate/test/reporter" ) var ( @@ -54,6 +53,7 @@ var ( miimonFormat string nodesInterfacesState = make(map[string][]byte) interfacesToIgnore = []string{"flannel.1", "dummy0"} + knmstateReporter *knmstatereporter.KubernetesNMStateReporter ) var _ = BeforeSuite(func() { @@ -94,6 +94,9 @@ var _ = BeforeSuite(func() { } resetDesiredStateForNodes() + + knmstateReporter = knmstatereporter.New("test_logs/e2e/handler", testenv.OperatorNamespace, nodes) + knmstateReporter.Cleanup() }) func TestE2E(t *testing.T) { @@ -101,16 +104,7 @@ func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - reporters := make([]Reporter, 0) - reporters = append(reporters, knmstatereporter.New("test_logs/e2e/handler", testenv.OperatorNamespace, nodes)) - if ginkgoreporters.Polarion.Run { - reporters = append(reporters, &ginkgoreporters.Polarion) - } - if ginkgoreporters.JunitOutput != "" { - reporters = append(reporters, ginkgoreporters.NewJunitReporter()) - } - - RunSpecsWithDefaultAndCustomReporters(t, "E2E Test Suite", reporters) + RunSpecs(t, "Handler E2E Test Suite") } var _ = BeforeEach(func() { @@ -139,6 +133,14 @@ var _ = AfterEach(func() { } }) +var _ = ReportBeforeEach(func(specReport types.SpecReport) { + knmstateReporter.ReportBeforeEach(specReport) +}) + +var _ = ReportAfterEach(func(specReport types.SpecReport) { + knmstateReporter.ReportAfterEach(specReport) +}) + func containsNode(nodes []string, node string) bool { for _, n := range nodes { if n == node { diff --git a/test/e2e/handler/multiple_policies_for_same_node_test.go b/test/e2e/handler/multiple_policies_for_same_node_test.go index 9cce47e62..0600111fe 100644 --- a/test/e2e/handler/multiple_policies_for_same_node_test.go +++ b/test/e2e/handler/multiple_policies_for_same_node_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/handler/nnce_conditions_test.go b/test/e2e/handler/nnce_conditions_test.go index 3e7f96deb..e75bd1821 100644 --- a/test/e2e/handler/nnce_conditions_test.go +++ b/test/e2e/handler/nnce_conditions_test.go @@ -22,7 +22,7 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" @@ -37,7 +37,7 @@ func invalidConfig(bridgeName string) nmstate.State { `, bridgeName)) } -var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:component]EnactmentCondition", func() { +var _ = Describe("EnactmentCondition", func() { Context("when applying valid config", func() { AfterEach(func() { By("Remove the bridge") @@ -46,7 +46,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com By("Reset desired state at all nodes") resetDesiredStateForNodes() }) - It("[test_id:3796]should go from Progressing to Available", func() { + It("should go from Progressing to Available", func() { var wg sync.WaitGroup wg.Add(len(nodes)) for i := range nodes { @@ -82,7 +82,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com resetDesiredStateForNodes() }) - It("[test_id:3795] should have Failing ConditionType set to true", func() { + It("should have Failing ConditionType set to true", func() { for _, node := range nodes { Byf("Check %s failing state is reached", node) enactmentConditionsStatusEventually(node).Should( @@ -115,7 +115,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com wg.Wait() }) - It("[test_id:3795] should have up to maxUnavailable Failing and the rest Aborted ConditionType set to true", func() { + It("should have up to maxUnavailable Failing and the rest Aborted ConditionType set to true", func() { checkEnactmentCounts := func(policy string) { failingConditions := 0 abortedConditions := 0 diff --git a/test/e2e/handler/nnce_desiredstate_test.go b/test/e2e/handler/nnce_desiredstate_test.go index 7a9840abb..8f395b843 100644 --- a/test/e2e/handler/nnce_desiredstate_test.go +++ b/test/e2e/handler/nnce_desiredstate_test.go @@ -18,7 +18,7 @@ limitations under the License. package handler import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/nncp_cleanup_test.go b/test/e2e/handler/nncp_cleanup_test.go index 14cb8529e..0a895af12 100644 --- a/test/e2e/handler/nncp_cleanup_test.go +++ b/test/e2e/handler/nncp_cleanup_test.go @@ -21,7 +21,7 @@ import ( "context" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/api/errors" diff --git a/test/e2e/handler/nncp_parallel_test.go b/test/e2e/handler/nncp_parallel_test.go index 5caee3e0c..3990bae44 100644 --- a/test/e2e/handler/nncp_parallel_test.go +++ b/test/e2e/handler/nncp_parallel_test.go @@ -20,7 +20,7 @@ package handler import ( "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/nns_dependencies_test.go b/test/e2e/handler/nns_dependencies_test.go index 5aa5c6782..4c6ffbda7 100644 --- a/test/e2e/handler/nns_dependencies_test.go +++ b/test/e2e/handler/nns_dependencies_test.go @@ -18,7 +18,7 @@ limitations under the License. package handler import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" diff --git a/test/e2e/handler/nns_filter_test.go b/test/e2e/handler/nns_filter_test.go index 8a58164ac..cbf112d3b 100644 --- a/test/e2e/handler/nns_filter_test.go +++ b/test/e2e/handler/nns_filter_test.go @@ -18,7 +18,7 @@ limitations under the License. package handler import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/nmstate/kubernetes-nmstate/pkg/state" diff --git a/test/e2e/handler/nns_update_timestamp_test.go b/test/e2e/handler/nns_update_timestamp_test.go index 43571f8ea..c33cebc94 100644 --- a/test/e2e/handler/nns_update_timestamp_test.go +++ b/test/e2e/handler/nns_update_timestamp_test.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" diff --git a/test/e2e/handler/node_selector_test.go b/test/e2e/handler/node_selector_test.go index 33a1fb2b7..3c4a02c73 100644 --- a/test/e2e/handler/node_selector_test.go +++ b/test/e2e/handler/node_selector_test.go @@ -21,7 +21,7 @@ import ( "context" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -33,7 +33,7 @@ import ( "github.com/nmstate/kubernetes-nmstate/pkg/enactment" ) -var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:component]NodeSelector", func() { +var _ = Describe("NodeSelector", func() { var ( testNodeSelector = map[string]string{"testKey": "testValue"} numberOfEnactmentsForPolicy = func(policyName string) int { @@ -58,7 +58,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com deletePolicy(bridge1) }) - It("[test_id:3813]should not update any nodes and have not enactments", func() { + It("should not update any nodes and have not enactments", func() { for _, node := range allNodes { interfacesNameForNodeEventually(node).ShouldNot(ContainElement(bridge1)) } diff --git a/test/e2e/handler/nodes_test.go b/test/e2e/handler/nodes_test.go index cd9989361..5330ffad1 100644 --- a/test/e2e/handler/nodes_test.go +++ b/test/e2e/handler/nodes_test.go @@ -20,13 +20,13 @@ package handler import ( "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/nmstate/kubernetes-nmstate/pkg/node" ) -var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:component][nns]Nodes", func() { +var _ = Describe("Nodes", func() { Context("when are up", func() { It("should have NodeNetworkState with currentState for each node", func() { for _, node := range nodes { @@ -52,7 +52,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com AfterEach(func() { deleteConnectionAndWait(nodes, expectedDummyName) }) - It("[test_id:3794]should update node network state with it", func() { + It("should update node network state with it", func() { for _, nodeName := range nodes { Eventually(func() []string { return interfacesNameForNode(nodeName) diff --git a/test/e2e/handler/rollback_test.go b/test/e2e/handler/rollback_test.go index 02f6d77b9..b3775a9c5 100644 --- a/test/e2e/handler/rollback_test.go +++ b/test/e2e/handler/rollback_test.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" @@ -107,7 +107,7 @@ func discoverNameServers(nic string) nmstate.State { `, nic)) } -var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:component]rollback", func() { +var _ = Describe("rollback", func() { // This spec is done only at first node since policy has to be different // per node (ip addresses has to be different at cluster). Context("when connectivity to default gw is lost after state configuration", func() { @@ -124,7 +124,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:cnv-qe@redhat.com][level:com By("Clean up desired state") resetDesiredStateForNodes() }) - It("[test_id:3793]should rollback to a good gw configuration", func() { + It("should rollback to a good gw configuration", func() { By("Should not be available") // Fail fast policyConditionsStatusConsistently().ShouldNot(containPolicyAvailable()) diff --git a/test/e2e/handler/simple_bridge_and_bond_test.go b/test/e2e/handler/simple_bridge_and_bond_test.go index 8af2592a5..c63fab945 100644 --- a/test/e2e/handler/simple_bridge_and_bond_test.go +++ b/test/e2e/handler/simple_bridge_and_bond_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/simple_ovs_bridge_and_bond_test.go b/test/e2e/handler/simple_ovs_bridge_and_bond_test.go index 67a82b1c7..6caa1500c 100644 --- a/test/e2e/handler/simple_ovs_bridge_and_bond_test.go +++ b/test/e2e/handler/simple_ovs_bridge_and_bond_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/simple_ovs_bridge_test.go b/test/e2e/handler/simple_ovs_bridge_test.go index 68d2341a7..6b2175da8 100644 --- a/test/e2e/handler/simple_ovs_bridge_test.go +++ b/test/e2e/handler/simple_ovs_bridge_test.go @@ -18,7 +18,7 @@ limitations under the License. package handler import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/handler/simple_vlan_and_ip_test.go b/test/e2e/handler/simple_vlan_and_ip_test.go index 266aa9ce6..2d49d4f28 100644 --- a/test/e2e/handler/simple_vlan_and_ip_test.go +++ b/test/e2e/handler/simple_vlan_and_ip_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/test/e2e/handler/static_addr_and_route_test.go b/test/e2e/handler/static_addr_and_route_test.go index 6c2730f31..de9a072c2 100644 --- a/test/e2e/handler/static_addr_and_route_test.go +++ b/test/e2e/handler/static_addr_and_route_test.go @@ -20,7 +20,7 @@ package handler import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" nmstate "github.com/nmstate/kubernetes-nmstate/api/shared" diff --git a/test/e2e/handler/upgrade_test.go b/test/e2e/handler/upgrade_test.go index 552e72c8a..07ba5cde9 100644 --- a/test/e2e/handler/upgrade_test.go +++ b/test/e2e/handler/upgrade_test.go @@ -20,7 +20,7 @@ package handler import ( "context" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/e2e/handler/user_guide_test.go b/test/e2e/handler/user_guide_test.go index cff80215b..261ff415e 100644 --- a/test/e2e/handler/user_guide_test.go +++ b/test/e2e/handler/user_guide_test.go @@ -20,7 +20,7 @@ limitations under the License. package handler import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) var _ = Describe("[user-guide] Introduction", func() { diff --git a/test/e2e/handler/utils.go b/test/e2e/handler/utils.go index 96c16adfa..60dfee1da 100644 --- a/test/e2e/handler/utils.go +++ b/test/e2e/handler/utils.go @@ -25,7 +25,7 @@ import ( "strings" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/tidwall/gjson" diff --git a/test/e2e/handler/webhook_test.go b/test/e2e/handler/webhook_test.go index b3614db4d..2cfeeb8a1 100644 --- a/test/e2e/handler/webhook_test.go +++ b/test/e2e/handler/webhook_test.go @@ -21,7 +21,7 @@ import ( "context" "strconv" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/client-go/util/retry" diff --git a/test/e2e/openshift.cnv.workflow.sh b/test/e2e/openshift.cnv.workflow.sh deleted file mode 100755 index 82b46e758..000000000 --- a/test/e2e/openshift.cnv.workflow.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -xe - -# Configure kubeconfig -export KUBECONFIG=${KUBECONFIG:-$HOME/oc4/working/auth/kubeconfig} -export KUBECTL=${KUBECTL:-oc} -export NAMESPACE=${NAMESPACE:-openshift-cnv} -export SSH=${SSH:-./ssh.sh} -export PRIMARY_NIC=${PRIMARY_NIC:-ens3} -export FIRST_SECONDARY_NIC=${FIRST_SECONDARY_NIC:-ens7} -export SECOND_SECONDARY_NIC=${SECOND_SECONDARY_NIC:-ens8} -export TIMEOUT=${TIMEOUT:-60m} - -cat << EOF > ${SSH} -#!/bin/bash -node_name=\${1} -node_ip=\$($KUBECTL get node \${node_name} --no-headers -o wide | awk '{print \$6}') -ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null core@\${node_ip} -- \${@:3} -EOF -chmod +x ${SSH} - -# Run workflow tests -focus='test_id:3796|test_id:3795|test_id:3813|test_id:3794|test_id:3793' -make test-e2e-handler \ - E2E_TEST_TIMEOUT=${TIMEOUT} \ - E2E_TEST_ARGS="$* --junit-output=junit.functest.xml -ginkgo.noColor -ginkgo.focus $focus" \ - NAMESPACE=$NAMESPACE \ - KUBECONFIG=$KUBECONFIG diff --git a/test/e2e/operator/main_test.go b/test/e2e/operator/main_test.go index 820b3d48a..dfafc6131 100644 --- a/test/e2e/operator/main_test.go +++ b/test/e2e/operator/main_test.go @@ -24,11 +24,10 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" + ginkgotypes "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" - ginkgoreporters "kubevirt.io/qe-tools/pkg/ginkgo-reporters" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -68,8 +67,9 @@ func newOperatorTestData(ns string) operatorTestData { } var ( - nodes []string - defaultOperator = newOperatorTestData("nmstate") + nodes []string + defaultOperator = newOperatorTestData("nmstate") + knmstateReporter *knmstatereporter.KubernetesNMStateReporter ) func TestE2E(t *testing.T) { @@ -77,16 +77,7 @@ func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - reporters := make([]Reporter, 0) - reporters = append(reporters, knmstatereporter.New("test_logs/e2e/operator", testenv.OperatorNamespace, nodes)) - if ginkgoreporters.Polarion.Run { - reporters = append(reporters, &ginkgoreporters.Polarion) - } - if ginkgoreporters.JunitOutput != "" { - reporters = append(reporters, ginkgoreporters.NewJunitReporter()) - } - - RunSpecsWithDefaultAndCustomReporters(t, "Operator E2E Test Suite", reporters) + RunSpecs(t, "Operator E2E Test Suite") } var _ = BeforeSuite(func() { @@ -105,12 +96,23 @@ var _ = BeforeSuite(func() { for _, node := range nodeList.Items { nodes = append(nodes, node.Name) } + + knmstateReporter = knmstatereporter.New("test_logs/e2e/handler", testenv.OperatorNamespace, nodes) + knmstateReporter.Cleanup() }) var _ = AfterSuite(func() { uninstallNMStateAndWaitForDeletion(defaultOperator) }) +var _ = ReportBeforeEach(func(specReport ginkgotypes.SpecReport) { + knmstateReporter.ReportBeforeEach(specReport) +}) + +var _ = ReportAfterEach(func(specReport ginkgotypes.SpecReport) { + knmstateReporter.ReportAfterEach(specReport) +}) + func installNMState(nmstate nmstatev1.NMState) { By(fmt.Sprintf("Creating NMState CR '%s'", nmstate.Name)) err := testenv.Client.Create(context.TODO(), &nmstate) diff --git a/test/e2e/operator/nmstate_install_test.go b/test/e2e/operator/nmstate_install_test.go index f2a78812c..ee611ad91 100644 --- a/test/e2e/operator/nmstate_install_test.go +++ b/test/e2e/operator/nmstate_install_test.go @@ -22,7 +22,7 @@ import ( "fmt" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/test/reporter/reporter.go b/test/reporter/reporter.go index be8c84fb6..30cb14a9c 100644 --- a/test/reporter/reporter.go +++ b/test/reporter/reporter.go @@ -23,12 +23,12 @@ import ( "io/ioutil" "os" "path" + "path/filepath" "strings" "sync" "time" - "github.com/onsi/ginkgo/config" - "github.com/onsi/ginkgo/types" + "github.com/onsi/ginkgo/v2/types" ) type KubernetesNMStateReporter struct { @@ -46,38 +46,26 @@ func New(artifactsDir string, namespace string, nodes []string) *KubernetesNMSta } } -func (r *KubernetesNMStateReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) { -} - -func (r *KubernetesNMStateReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) { - r.Cleanup() -} - -func (r *KubernetesNMStateReporter) SpecWillRun(specSummary *types.SpecSummary) { - if specSummary.Skipped() || specSummary.Pending() { +func (r *KubernetesNMStateReporter) ReportBeforeEach(specReport types.SpecReport) { + if specReport.State.Is(types.SpecStateSkipped) || specReport.State.Is(types.SpecStatePending) { return } r.storeStateBeforeEach() } -func (r *KubernetesNMStateReporter) SpecDidComplete(specSummary *types.SpecSummary) { - if specSummary.Skipped() || specSummary.Pending() { + +func (r *KubernetesNMStateReporter) ReportAfterEach(specReport types.SpecReport) { + if specReport.State.Is(types.SpecStateSkipped) || specReport.State.Is(types.SpecStatePending) { return } - since := time.Now().Add(-specSummary.RunTime).Add(-5 * time.Second) - name := strings.Join(specSummary.ComponentTexts[1:], " ") - passed := specSummary.Passed() + since := time.Now().Add(-specReport.RunTime).Add(-5 * time.Second) + name := strings.Join(specReport.ContainerHierarchyTexts, " ") + passed := specReport.State.Is(types.SpecStatePassed) r.dumpStateAfterEach(name, since, passed) } -func (r *KubernetesNMStateReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) { -} - -func (r *KubernetesNMStateReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) { -} - func (r *KubernetesNMStateReporter) storeStateBeforeEach() { r.previousDeviceStatus = r.deviceStatus() } @@ -156,14 +144,15 @@ func (r *KubernetesNMStateReporter) logPods(testName string, sinceTime time.Time return nil } -func (r *KubernetesNMStateReporter) OpenTestLogFile(logType string, testName string, cb func(f io.Writer), extraWriters ...io.Writer) { - err := os.MkdirAll(r.artifactsDir, 0755) +func (r *KubernetesNMStateReporter) OpenTestLogFile(logType, testName string, cb func(f io.Writer), extraWriters ...io.Writer) { + testLogDir := filepath.Join(r.artifactsDir, strings.ReplaceAll(testName, " ", "_")) + err := os.MkdirAll(testLogDir, 0755) if err != nil { fmt.Println(err) return } - name := fmt.Sprintf("%s/%s_%s.log", r.artifactsDir, testName, logType) + name := filepath.Join(testLogDir, fmt.Sprintf("%s.log", logType)) fi, err := os.OpenFile(name, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) if err != nil { fmt.Println(err) diff --git a/test/reporter/reporter.go.orig b/test/reporter/reporter.go.orig new file mode 100644 index 000000000..098f858a2 --- /dev/null +++ b/test/reporter/reporter.go.orig @@ -0,0 +1,197 @@ +/* +Copyright The Kubernetes NMState Authors. + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package reporter + +import ( + "fmt" + "io" + "io/ioutil" + "os" + "path" + "path/filepath" + "strings" + "sync" + "time" + + "github.com/onsi/ginkgo/v2/types" +) + +type KubernetesNMStateReporter struct { + artifactsDir string + namespace string + previousDeviceStatus string + nodes []string +} + +func New(artifactsDir string, namespace string, nodes []string) *KubernetesNMStateReporter { + return &KubernetesNMStateReporter{ + artifactsDir: artifactsDir, + namespace: namespace, + nodes: nodes, + } +} + +<<<<<<< HEAD +func (r *KubernetesNMStateReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) { +} + +func (r *KubernetesNMStateReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) { + r.Cleanup() +} + +func (r *KubernetesNMStateReporter) SpecWillRun(specSummary *types.SpecSummary) { + if specSummary.Skipped() || specSummary.Pending() { +======= +func (r *KubernetesNMStateReporter) ReportBeforeEach(specReport types.SpecReport) { + if specReport.State.Is(types.SpecStateSkipped) || specReport.State.Is(types.SpecStatePending) { +>>>>>>> af8ec3637 (foo) + return + } + + r.storeStateBeforeEach() +} + +func (r *KubernetesNMStateReporter) ReportAfterEach(specReport types.SpecReport) { + if specReport.State.Is(types.SpecStateSkipped) || specReport.State.Is(types.SpecStatePending) { + return + } + + since := time.Now().Add(-specReport.RunTime).Add(-5 * time.Second) + name := strings.Join(specReport.ContainerHierarchyTexts, " ") + passed := specReport.State.Is(types.SpecStatePassed) + + r.dumpStateAfterEach(name, since, passed) +} + +<<<<<<< HEAD +func (r *KubernetesNMStateReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) { +} + +func (r *KubernetesNMStateReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) { +} + +======= +>>>>>>> af8ec3637 (foo) +func (r *KubernetesNMStateReporter) storeStateBeforeEach() { + r.previousDeviceStatus = r.deviceStatus() +} + +func runAndWait(funcs ...func()) { + var wg sync.WaitGroup + wg.Add(len(funcs)) + for _, f := range funcs { + // You have to pass f to the goroutine, it's going to change + // at the next loop iteration. + go func(rf func()) { + rf() + wg.Done() + }(f) + } + wg.Wait() +} + +func (r *KubernetesNMStateReporter) dumpStateAfterEach(testName string, testStartTime time.Time, passed bool) { + if passed { + return + } + runAndWait( + func() { r.logPods(testName, testStartTime) }, + func() { r.logDeviceStatus(testName) }, + func() { r.logNetworkManager(testName, testStartTime) }, + ) +} + +func (r *KubernetesNMStateReporter) deviceStatus() string { + stringBuilder := strings.Builder{} + writeDeviceStatus(&stringBuilder, r.nodes) + return stringBuilder.String() +} + +func (r *KubernetesNMStateReporter) logDeviceStatus(testName string) { + r.OpenTestLogFile("deviceStatus", testName, func(w io.Writer) { + writeMessage(w, banner("DEVICE STATUS BEFORE TEST")) + writeMessage(w, r.previousDeviceStatus) + writeMessage(w, banner("DEVICE STATUS AFTER TEST")) + writeDeviceStatus(w, r.nodes) + }) +} + +// Cleanup cleans up the current content of the artifactsDir +func (r *KubernetesNMStateReporter) Cleanup() { + // clean up artifacts from previous run + if r.artifactsDir != "" { + _, err := os.Stat(r.artifactsDir) + if err != nil { + if os.IsNotExist(err) { + return + } else { + panic(err) + } + } + names, err := ioutil.ReadDir(r.artifactsDir) + if err != nil { + panic(err) + } + for _, entery := range names { + os.RemoveAll(path.Join([]string{r.artifactsDir, entery.Name()}...)) + } + } +} + +func (r *KubernetesNMStateReporter) logNetworkManager(testName string, sinceTime time.Time) { + r.OpenTestLogFile("NetworkManager", testName, networkManagerLogsWriter(r.nodes, sinceTime)) +} + +func (r *KubernetesNMStateReporter) logPods(testName string, sinceTime time.Time) error { + // Let's print the pods logs to the GinkgoWriter so + // we see the failure directly at prow junit output without opening files + r.OpenTestLogFile("pods", testName, podLogsWriter(r.namespace, sinceTime)) + + return nil +} + +<<<<<<< HEAD +func (r *KubernetesNMStateReporter) OpenTestLogFile(logType string, testName string, cb func(f io.Writer), extraWriters ...io.Writer) { + err := os.MkdirAll(r.artifactsDir, 0755) +======= +func (r *KubernetesNMStateReporter) OpenTestLogFile(logType, testName string, cb func(f io.Writer), extraWriters ...io.Writer) { + testLogDir := filepath.Join(r.artifactsDir, strings.ReplaceAll(testName, " ", "_")) + err := os.MkdirAll(testLogDir, 0755) +>>>>>>> af8ec3637 (foo) + if err != nil { + fmt.Println(err) + return + } + + name := filepath.Join(testLogDir, fmt.Sprintf("%s.log", logType)) + fi, err := os.OpenFile(name, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) + if err != nil { + fmt.Println(err) + return + } + defer func() { + if err := fi.Close(); err != nil { + fmt.Println(err) + } + }() + writers := []io.Writer{fi} + if len(extraWriters) > 0 { + writers = append(writers, extraWriters...) + } + cb(io.MultiWriter(writers...)) +} diff --git a/test/reporter/writers.go b/test/reporter/writers.go index 4d604f781..4808e0830 100644 --- a/test/reporter/writers.go +++ b/test/reporter/writers.go @@ -25,7 +25,7 @@ import ( "strings" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -72,10 +72,13 @@ func writeNetworkManagerLogs(writer io.Writer, nodes []string, sinceTime time.Ti for _, node := range nodes { output, err := runner.RunQuietAtNode(node, "sudo", "journalctl", "-u", "NetworkManager", "--since", fmt.Sprintf("'%ds ago'", 10+int(time.Since(sinceTime).Seconds()))) - Expect(err).ToNot(HaveOccurred()) - writeMessage(writer, banner("Journalctl for NetworkManager on node %s"), node) - writeMessage(writer, banner("\n %s"), output) - writeMessage(writer, banner("Done NetworkManager logs on node %s"), node) + if err != nil { + writeMessage(writer, banner("failed reporting NetworkManager logs at %s: %v"), node, err) + } else { + writeMessage(writer, banner("Journalctl for NetworkManager on node %s"), node) + writeMessage(writer, banner("\n %s"), output) + writeMessage(writer, banner("Done NetworkManager logs on node %s"), node) + } } } @@ -130,7 +133,7 @@ func writeString(writer io.Writer, message string) { writer.Write([]byte(message)) } -func writeMessage(writer io.Writer, message string, args ...string) { +func writeMessage(writer io.Writer, message string, args ...interface{}) { formattedMessage := message if len(args) > 0 { formattedMessage = fmt.Sprintf(formattedMessage, args) diff --git a/tools.go b/tools.go index c4a96f788..f074c0b11 100644 --- a/tools.go +++ b/tools.go @@ -4,7 +4,7 @@ package tools import ( _ "github.com/github-release/github-release" - _ "github.com/onsi/ginkgo/ginkgo" + _ "github.com/onsi/ginkgo/v2/ginkgo" _ "github.com/operator-framework/operator-registry/cmd/opm" _ "k8s.io/release/cmd/release-notes" _ "sigs.k8s.io/controller-tools/cmd/controller-gen"