github.com/nmstate/kubernetes-nmstate@v0.82.0/test/e2e/handler/user_guide_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 // This module is meant to cover all the demos as we show them. To make it as close 19 // to the reality as possible, we use only kubectl direcly 20 package handler 21 22 import ( 23 . "github.com/onsi/ginkgo/v2" 24 25 "github.com/nmstate/kubernetes-nmstate/test/e2e/policy" 26 ) 27 28 var _ = Describe("[user-guide] Introduction", func() { 29 runConfiguration := func() { 30 kubectlAndCheck("apply", "-f", "docs/user-guide/bond0-eth1-eth2_up.yaml") 31 kubectlAndCheck("wait", "nncp", "bond0-eth1-eth2", "--for", "condition=Available", "--timeout", "4m") 32 kubectlAndCheck("apply", "-f", "docs/user-guide/bond0-eth1-eth2_absent.yaml") 33 kubectlAndCheck("wait", "nncp", "bond0-eth1-eth2", "--for", "condition=Available", "--timeout", "4m") 34 kubectlAndCheck("delete", "nncp", "bond0-eth1-eth2") 35 36 kubectlAndCheck("apply", "-f", "docs/user-guide/eth1-eth2_up.yaml") 37 kubectlAndCheck("wait", "nncp", "eth1", "eth2", "--for", "condition=Available", "--timeout", "4m") 38 kubectlAndCheck("delete", "nncp", "eth1", "eth2") 39 40 kubectlAndCheck("apply", "-f", "docs/user-guide/vlan100_node01_up.yaml") 41 kubectlAndCheck("wait", "nncp", "vlan100", "--for", "condition=Available", "--timeout", "4m") 42 } 43 44 // Policies are not deleted as a part of the tutorial, so we need additional function here 45 cleanupConfiguration := func() { 46 deletePolicy("vlan100") 47 setDesiredStateWithPolicyWithoutNodeSelector(TestPolicy, interfaceAbsent("eth1.100")) 48 policy.WaitForAvailableTestPolicy() 49 setDesiredStateWithPolicyWithoutNodeSelector(TestPolicy, resetPrimaryAndSecondaryNICs()) 50 policy.WaitForAvailableTestPolicy() 51 deletePolicy(TestPolicy) 52 } 53 54 runTroubleshooting := func() { 55 kubectlAndCheck("apply", "-f", "docs/user-guide/eth666_up.yaml") 56 kubectlAndCheck("wait", "nncp", "eth666", "--for", "condition=Degraded", "--timeout", "4m") 57 kubectlAndCheck("delete", "nncp", "eth666") 58 } 59 60 BeforeEach(func() { 61 skipIfNotKubernetes() 62 }) 63 64 Context("Configuration tutorial", func() { 65 AfterEach(func() { 66 cleanupConfiguration() 67 }) 68 69 It("should succeed executing all the commands", func() { 70 runConfiguration() 71 }) 72 }) 73 74 Context("Troubleshooting tutorial", func() { 75 It("should succeed executing all the commands", func() { 76 runTroubleshooting() 77 }) 78 }) 79 80 Context("All tutorials in a row", func() { 81 AfterEach(func() { 82 cleanupConfiguration() 83 }) 84 85 It("should succeed executing all the commands", func() { 86 runConfiguration() 87 runTroubleshooting() 88 }) 89 }) 90 })