diff --git a/Makefile b/Makefile index 583e7d58a8..d5618a1daa 100644 --- a/Makefile +++ b/Makefile @@ -493,9 +493,12 @@ fmt format: $(GOFUMPT) ## run gofumpt on $FMT_PKG (default "cni cns npm") COVER_PKG ?= . # run all tests +# COVER_FILTER omits folders with all files tagged with one of 'unit', '!ignore_uncovered', or '!ignore_autogenerated' .PHONY: test-all test-all: - go test -tags "unit" -coverpkg=$(COVER_PKG)/... -v -race -covermode atomic -coverprofile coverage.out $(COVER_PKG)/... + @$(eval COVER_FILTER=`go list --tags ignore_uncovered,ignore_autogenerated $(COVER_PKG)/... | tr '\n' ','`) + @echo Test coverpkg: $(COVER_FILTER) + go test -tags "unit" -coverpkg=$(COVER_FILTER) -v -race -covermode atomic -failfast -coverprofile=coverage.out $(COVER_PKG)/... # run all tests diff --git a/cns/fakes/cnsfake.go b/cns/fakes/cnsfake.go index 41c0404218..1c86d1cd2b 100644 --- a/cns/fakes/cnsfake.go +++ b/cns/fakes/cnsfake.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package fakes import ( diff --git a/cns/fakes/imdsclientfake.go b/cns/fakes/imdsclientfake.go index 70d51db81c..68f1eda639 100644 --- a/cns/fakes/imdsclientfake.go +++ b/cns/fakes/imdsclientfake.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Copyright 2017 Microsoft. All rights reserved. // MIT License diff --git a/cns/fakes/ipampoolmonitorfake.go b/cns/fakes/ipampoolmonitorfake.go index 8fec88155b..adde22342a 100644 --- a/cns/fakes/ipampoolmonitorfake.go +++ b/cns/fakes/ipampoolmonitorfake.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package fakes import ( diff --git a/cns/fakes/nmagentclientfake.go b/cns/fakes/nmagentclientfake.go index 5bfa9b523e..751159f44b 100644 --- a/cns/fakes/nmagentclientfake.go +++ b/cns/fakes/nmagentclientfake.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Copyright 2020 Microsoft. All rights reserved. // MIT License diff --git a/cns/fakes/requestcontrollerfake.go b/cns/fakes/requestcontrollerfake.go index daa2fd853a..bacc369dfb 100644 --- a/cns/fakes/requestcontrollerfake.go +++ b/cns/fakes/requestcontrollerfake.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package fakes import ( diff --git a/crd/multitenantnetworkcontainer/api/v1alpha1/groupversion_info.go b/crd/multitenantnetworkcontainer/api/v1alpha1/groupversion_info.go index 7d203c0a43..7c5416b523 100644 --- a/crd/multitenantnetworkcontainer/api/v1alpha1/groupversion_info.go +++ b/crd/multitenantnetworkcontainer/api/v1alpha1/groupversion_info.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Package v1alpha1 contains API Schema definitions for the networking v1alpha1 API group // +kubebuilder:object:generate=true // +groupName=networking.azure.com diff --git a/crd/multitenantnetworkcontainer/api/v1alpha1/multitenantnetworkcontainer_types.go b/crd/multitenantnetworkcontainer/api/v1alpha1/multitenantnetworkcontainer_types.go index 49eb64a37a..3f53fafc66 100644 --- a/crd/multitenantnetworkcontainer/api/v1alpha1/multitenantnetworkcontainer_types.go +++ b/crd/multitenantnetworkcontainer/api/v1alpha1/multitenantnetworkcontainer_types.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package v1alpha1 import ( diff --git a/crd/multitenantnetworkcontainer/api/v1alpha1/zz_generated.deepcopy.go b/crd/multitenantnetworkcontainer/api/v1alpha1/zz_generated.deepcopy.go index 6613aa64c9..8990e68324 100644 --- a/crd/multitenantnetworkcontainer/api/v1alpha1/zz_generated.deepcopy.go +++ b/crd/multitenantnetworkcontainer/api/v1alpha1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Code generated by controller-gen. DO NOT EDIT. diff --git a/crd/multitenantnetworkcontainer/manifests/networking.azure.com_multitenantnetworkcontainers.yaml b/crd/multitenantnetworkcontainer/manifests/networking.azure.com_multitenantnetworkcontainers.yaml index 43329fcbde..055cacd462 100644 --- a/crd/multitenantnetworkcontainer/manifests/networking.azure.com_multitenantnetworkcontainers.yaml +++ b/crd/multitenantnetworkcontainer/manifests/networking.azure.com_multitenantnetworkcontainers.yaml @@ -1,10 +1,10 @@ --- -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.3.0 + controller-gen.kubebuilder.io/version: v0.6.2 creationTimestamp: null name: multitenantnetworkcontainers.networking.azure.com spec: @@ -15,86 +15,85 @@ spec: plural: multitenantnetworkcontainers singular: multitenantnetworkcontainer scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: MultiTenantNetworkContainer is the Schema for the MultiTenantnetworkcontainers - API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: MultiTenantNetworkContainerSpec defines the desired state of - MultiTenantNetworkContainer - properties: - interfaceName: - description: InterfaceName - the interface name for consuming Pod - type: string - network: - description: Network - customer VNet GUID - type: string - node: - description: Node - kubernetes node name - type: string - reservationID: - description: ReservationID - reservation ID for allocating IP - type: string - subnet: - description: Subnet - customer subnet name - type: string - uuid: - description: UUID - network container UUID - type: string - type: object - status: - description: MultiTenantNetworkContainerStatus defines the observed state - of MultiTenantNetworkContainer - properties: - gateway: - description: The gateway IP address - type: string - ip: - description: The IP address - type: string - ipSubnet: - description: The subnet CIDR - type: string - multiTenantInfo: - description: MultiTenantInfo holds the encap type and id - properties: - encapType: - description: EncapType is type of encapsulation - type: string - id: - description: ID of encapsulation, can be vlanid, vxlanid, gre-key, - etc depending on EncapType - format: int64 - type: integer - type: object - primaryInterfaceIdentifier: - description: The primary interface identifier - type: string - state: - description: The state of network container - type: string - type: object - type: object - version: v1alpha1 versions: - name: v1alpha1 + schema: + openAPIV3Schema: + description: MultiTenantNetworkContainer is the Schema for the MultiTenantnetworkcontainers + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: MultiTenantNetworkContainerSpec defines the desired state + of MultiTenantNetworkContainer + properties: + interfaceName: + description: InterfaceName - the interface name for consuming Pod + type: string + network: + description: Network - customer VNet GUID + type: string + node: + description: Node - kubernetes node name + type: string + reservationID: + description: ReservationID - reservation ID for allocating IP + type: string + subnet: + description: Subnet - customer subnet name + type: string + uuid: + description: UUID - network container UUID + type: string + type: object + status: + description: MultiTenantNetworkContainerStatus defines the observed state + of MultiTenantNetworkContainer + properties: + gateway: + description: The gateway IP address + type: string + ip: + description: The IP address + type: string + ipSubnet: + description: The subnet CIDR + type: string + multiTenantInfo: + description: MultiTenantInfo holds the encap type and id + properties: + encapType: + description: EncapType is type of encapsulation + type: string + id: + description: ID of encapsulation, can be vlanid, vxlanid, gre-key, + etc depending on EncapType + format: int64 + type: integer + type: object + primaryInterfaceIdentifier: + description: The primary interface identifier + type: string + state: + description: The state of network container + type: string + type: object + type: object served: true storage: true + subresources: + status: {} status: acceptedNames: kind: "" diff --git a/crd/nodenetworkconfig/api/v1alpha/groupversion_info.go b/crd/nodenetworkconfig/api/v1alpha/groupversion_info.go index 0fa88609d8..ecf249a821 100644 --- a/crd/nodenetworkconfig/api/v1alpha/groupversion_info.go +++ b/crd/nodenetworkconfig/api/v1alpha/groupversion_info.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Package v1alpha contains API Schema definitions for the acn v1alpha API group // +kubebuilder:object:generate=true // +groupName=acn.azure.com diff --git a/crd/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go b/crd/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go index 727e14e0cf..6c89aff4df 100644 --- a/crd/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go +++ b/crd/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package v1alpha import ( diff --git a/npm/metrics/promutil/test-util.go b/npm/metrics/promutil/test-util.go index 64a33197af..1644b5eac5 100644 --- a/npm/metrics/promutil/test-util.go +++ b/npm/metrics/promutil/test-util.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package promutil import "testing" @@ -12,7 +15,7 @@ func NotifyIfErrors(t *testing.T, errors ...error) { } } if !allGood { - t.Errorf("Encountered these errors while getting metric values: ") + t.Errorf("Encountered these errors while getting Prometheus metric values: ") for _, err := range errors { if err != nil { t.Errorf("%v", err) diff --git a/test/nnsmockserver/nnsmockserver.go b/test/nnsmockserver/nnsmockserver.go index ddb95c70e0..e373041c60 100644 --- a/test/nnsmockserver/nnsmockserver.go +++ b/test/nnsmockserver/nnsmockserver.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package nnsmockserver import ( diff --git a/test/utils/utils.go b/test/utils/utils.go index 684770716d..8909abd8d7 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package testingutils import ( diff --git a/testutils/netapi_mock.go b/testutils/netapi_mock.go index bf3515ebfe..3e93e452dd 100644 --- a/testutils/netapi_mock.go +++ b/testutils/netapi_mock.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package testutils type NetApiMock struct { diff --git a/testutils/store_mock.go b/testutils/store_mock.go index 03bc60ac09..c626907c0a 100644 --- a/testutils/store_mock.go +++ b/testutils/store_mock.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package testutils import ( diff --git a/tools/acncli/api/constants.go b/tools/acncli/api/constants.go index 881733ff6d..731e1f34d9 100644 --- a/tools/acncli/api/constants.go +++ b/tools/acncli/api/constants.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package api import ( diff --git a/tools/acncli/cmd/cni/cni.go b/tools/acncli/cmd/cni/cni.go index 0f5bd7f68f..9b5782b44a 100644 --- a/tools/acncli/cmd/cni/cni.go +++ b/tools/acncli/cmd/cni/cni.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cni import ( diff --git a/tools/acncli/cmd/cni/install.go b/tools/acncli/cmd/cni/install.go index 46583269a4..caa26be718 100644 --- a/tools/acncli/cmd/cni/install.go +++ b/tools/acncli/cmd/cni/install.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cni import ( diff --git a/tools/acncli/cmd/cni/logs.go b/tools/acncli/cmd/cni/logs.go index 2f0e05ba4c..3f0573d4ff 100644 --- a/tools/acncli/cmd/cni/logs.go +++ b/tools/acncli/cmd/cni/logs.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cni import ( diff --git a/tools/acncli/cmd/cni/manager.go b/tools/acncli/cmd/cni/manager.go index 9ca58fe54c..06289d9322 100644 --- a/tools/acncli/cmd/cni/manager.go +++ b/tools/acncli/cmd/cni/manager.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cni import ( diff --git a/tools/acncli/cmd/install.go b/tools/acncli/cmd/install.go index a4543a112e..88c75de92d 100644 --- a/tools/acncli/cmd/install.go +++ b/tools/acncli/cmd/install.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cmd import ( diff --git a/tools/acncli/cmd/logs.go b/tools/acncli/cmd/logs.go index 35f0caaa81..d56153504d 100644 --- a/tools/acncli/cmd/logs.go +++ b/tools/acncli/cmd/logs.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cmd import ( diff --git a/tools/acncli/cmd/manager.go b/tools/acncli/cmd/manager.go index 879b683c02..08717b70dd 100644 --- a/tools/acncli/cmd/manager.go +++ b/tools/acncli/cmd/manager.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cmd import ( diff --git a/tools/acncli/cmd/npm/get/manager.go b/tools/acncli/cmd/npm/get/manager.go index d5dfac10cc..c6fc78b6ac 100644 --- a/tools/acncli/cmd/npm/get/manager.go +++ b/tools/acncli/cmd/npm/get/manager.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package get import ( diff --git a/tools/acncli/cmd/npm/npm.go b/tools/acncli/cmd/npm/npm.go index ea10ae1c1e..67f69f6f9c 100644 --- a/tools/acncli/cmd/npm/npm.go +++ b/tools/acncli/cmd/npm/npm.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package npm import ( diff --git a/tools/acncli/cmd/root.go b/tools/acncli/cmd/root.go index 6b53c531df..ee653de695 100644 --- a/tools/acncli/cmd/root.go +++ b/tools/acncli/cmd/root.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package cmd import ( diff --git a/tools/acncli/installer/conflist.go b/tools/acncli/installer/conflist.go index 058cb18232..5de17c0245 100644 --- a/tools/acncli/installer/conflist.go +++ b/tools/acncli/installer/conflist.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package installer import ( diff --git a/tools/acncli/installer/install.go b/tools/acncli/installer/install.go index 9de2554f3c..c562373461 100644 --- a/tools/acncli/installer/install.go +++ b/tools/acncli/installer/install.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package installer import ( diff --git a/tools/acncli/installer/utils.go b/tools/acncli/installer/utils.go index 88b66db2ee..e871a5643d 100644 --- a/tools/acncli/installer/utils.go +++ b/tools/acncli/installer/utils.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package installer import ( diff --git a/tools/acncli/main.go b/tools/acncli/main.go index 6460023fa2..72336fb49a 100644 --- a/tools/acncli/main.go +++ b/tools/acncli/main.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + package main import (