github.com/nmstate/kubernetes-nmstate@v0.82.0/test/e2e/handler/nodes_test.go (about) 1 /* 2 Copyright The Kubernetes NMState Authors. 3 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 */ 17 18 package handler 19 20 import ( 21 "time" 22 23 . "github.com/onsi/ginkgo/v2" 24 . "github.com/onsi/gomega" 25 26 "github.com/nmstate/kubernetes-nmstate/pkg/node" 27 ) 28 29 var _ = Describe("Nodes", func() { 30 Context("when are up", func() { 31 It("should have NodeNetworkState with currentState for each node", func() { 32 for _, node := range nodes { 33 interfacesNameForNodeEventually(node).Should(ContainElement(primaryNic)) 34 } 35 }) 36 Context("and node network state is deleted", func() { 37 BeforeEach(func() { 38 deleteNodeNeworkStates() 39 }) 40 It("should recreate it with currentState", func() { 41 for _, node := range nodes { 42 interfacesNameForNodeEventually(node).Should(ContainElement(primaryNic)) 43 } 44 }) 45 }) 46 Context("and new interface is configured", func() { 47 expectedDummyName := "dummy0" 48 49 BeforeEach(func() { 50 createDummyConnectionAtNodes(expectedDummyName) 51 }) 52 AfterEach(func() { 53 deleteConnectionAndWait(nodes, expectedDummyName) 54 }) 55 It("should update node network state with it", func() { 56 for _, nodeName := range nodes { 57 Eventually(func() []string { 58 return interfacesNameForNode(nodeName) 59 }, 2*node.NetworkStateRefresh, time.Second).Should(ContainElement(expectedDummyName)) 60 } 61 }) 62 }) 63 }) 64 })