Skip to content

Commit

Permalink
Fix test conditions
Browse files Browse the repository at this point in the history
Now when a failing NNCP is applied, we accept NNCEs in two
states: aborted and failed.

Signed-off-by: Radim Hrazdil <[email protected]>
  • Loading branch information
Radim Hrazdil committed Mar 25, 2021
1 parent bffe21e commit 4e4f9c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
6 changes: 3 additions & 3 deletions test/e2e/handler/nnce_conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:[email protected]][level:com
wg.Wait()
})

It("[test_id:3795] should have one Failing the rest Aborted ConditionType set to true", func() {
It("[test_id:3795] should have up to maxUnavailable Failing and the rest Aborted ConditionType set to true", func() {
checkEnactmentCounts := func(policy string) {
failingConditions := 0
abortedConditions := 0
Expand All @@ -210,8 +210,8 @@ var _ = Describe("[rfe_id:3503][crit:medium][vendor:[email protected]][level:com
abortedConditions++
}
}
Expect(failingConditions).To(Equal(1), "one node only should have failing enactment")
Expect(abortedConditions).To(Equal(len(nodes)-1), "other nodes should have aborted enactment")
Expect(failingConditions).To(BeNumerically("<=", maxUnavailableNodes()), "one node only should have failing enactment")
Expect(abortedConditions).To(Equal(len(nodes)-failingConditions), "other nodes should have aborted enactment")
}

By("Check policy is at degraded state")
Expand Down
18 changes: 3 additions & 15 deletions test/e2e/handler/nncp_parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"

nmstatev1beta1 "github.com/nmstate/kubernetes-nmstate/api/v1beta1"

nmstate "github.com/nmstate/kubernetes-nmstate/api/shared"
"github.com/nmstate/kubernetes-nmstate/pkg/node"
corev1 "k8s.io/api/core/v1"
)

func enactmentsInProgress(policy string) int {
Expand All @@ -28,17 +23,10 @@ func enactmentsInProgress(policy string) int {
return progressingEnactments
}

func maxUnavailableNodes() int {
m, _ := node.ScaledMaxUnavailableNodeCount(len(nodes), intstr.FromString(node.DEFAULT_MAXUNAVAILABLE))
return m
}

var _ = Describe("NNCP with maxUnavailable", func() {
policy := &nmstatev1beta1.NodeNetworkConfigurationPolicy{}
policy.Name = TestPolicy
duration := 15 * time.Second
interval := 500 * time.Millisecond
Context("when applying a policy to matching nodes", func() {
duration := 10 * time.Second
interval := 1 * time.Second
BeforeEach(func() {
By("Create a policy")
updateDesiredState(linuxBrUp(bridge1))
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/handler/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,8 @@ func skipIfNotKubernetes() {
Skip("Tutorials use interface naming that is available only on Kubernetes providers")
}
}

func maxUnavailableNodes() int {
m, _ := nmstatenode.ScaledMaxUnavailableNodeCount(len(nodes), intstr.FromString(nmstatenode.DEFAULT_MAXUNAVAILABLE))
return m
}

0 comments on commit 4e4f9c9

Please sign in to comment.