github.com/zhyoulun/cilium@v1.6.12/test/k8sT/PoliciesNightly.go (about) 1 // Copyright 2017-2019 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package k8sTest 16 17 import ( 18 "fmt" 19 "time" 20 21 . "github.com/cilium/cilium/test/ginkgo-ext" 22 "github.com/cilium/cilium/test/helpers" 23 "github.com/cilium/cilium/test/helpers/policygen" 24 25 . "github.com/onsi/gomega" 26 ) 27 28 var _ = Describe("NightlyPolicies", func() { 29 30 var kubectl *helpers.Kubectl 31 var timeout = 10 * time.Minute 32 33 BeforeAll(func() { 34 kubectl = helpers.CreateKubectl(helpers.K8s1VMName(), logger) 35 DeployCiliumAndDNS(kubectl) 36 }) 37 38 AfterFailed(func() { 39 kubectl.CiliumReport(helpers.KubeSystemNamespace, 40 "cilium endpoint list", 41 "cilium service list") 42 }) 43 44 JustAfterEach(func() { 45 kubectl.ValidateNoErrorsInLogs(CurrentGinkgoTestDescription().Duration) 46 }) 47 48 AfterAll(func() { 49 // Delete all pods created 50 kubectl.Exec(fmt.Sprintf( 51 "%s delete pods,svc,cnp -n %s -l test=policygen", 52 helpers.KubectlCmd, helpers.DefaultNamespace)) 53 err := kubectl.WaitCleanAllTerminatingPods(timeout) 54 Expect(err).To(BeNil(), "Cannot clean pods during timeout") 55 kubectl.CloseSSHClient() 56 }) 57 58 Context("PolicyEnforcement default", func() { 59 createTests := func() { 60 testSpecs := policygen.GeneratedTestSpec() 61 for _, test := range testSpecs { 62 func(testSpec policygen.TestSpec) { 63 It(fmt.Sprintf("%s", testSpec), func() { 64 testSpec.RunTest(kubectl) 65 }) 66 }(test) 67 } 68 } 69 createTests() 70 }) 71 })