Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
Signed-off-by: Quique Llorente <[email protected]>
  • Loading branch information
qinqon committed Mar 21, 2022
1 parent e67755f commit 9f3ab72
Show file tree
Hide file tree
Showing 67 changed files with 355 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,17 +30,17 @@ 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
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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions automation/check-patch.e2e-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion automation/check-patch.e2e-operator-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
7 changes: 1 addition & 6 deletions automation/check-patch.unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
7 changes: 2 additions & 5 deletions controllers/handler/handler_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion controllers/handler/node_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion controllers/operator/nmstate_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions controllers/operator/operator_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
7 changes: 2 additions & 5 deletions pkg/enactmentstatus/conditions/conditions_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
3 changes: 1 addition & 2 deletions pkg/enactmentstatus/conditions/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions pkg/enactmentstatus/enactmentstatus_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion pkg/enactmentstatus/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
package enactmentstatus

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
25 changes: 12 additions & 13 deletions pkg/helper/bridges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"},
Expand Down
7 changes: 2 additions & 5 deletions pkg/helper/helper_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion pkg/nmpolicy/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
7 changes: 2 additions & 5 deletions pkg/nmpolicy/nmpolicy_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
7 changes: 2 additions & 5 deletions pkg/node/node_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Loading

0 comments on commit 9f3ab72

Please sign in to comment.