github.phpd.cn/cilium/cilium@v1.6.12/test/config/config.go (about) 1 // Copyright 2017 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 config 16 17 import ( 18 "flag" 19 "time" 20 ) 21 22 // CiliumTestConfigType holds all of the configurable elements of the testsuite 23 type CiliumTestConfigType struct { 24 Reprovision bool 25 HoldEnvironment bool 26 SSHConfig string 27 ShowCommands bool 28 TestScope string 29 SkipLogGathering bool 30 Timeout time.Duration 31 } 32 33 // CiliumTestConfig holds the global configuration of commandline flags 34 // in the ginkgo-based testing environment. 35 var CiliumTestConfig = CiliumTestConfigType{} 36 37 // ParseFlags parses commandline flags relevant to testing. 38 func (c *CiliumTestConfigType) ParseFlags() { 39 flag.BoolVar(&c.Reprovision, "cilium.provision", true, 40 "Provision Vagrant boxes and Cilium before running test") 41 flag.BoolVar(&c.HoldEnvironment, "cilium.holdEnvironment", false, 42 "On failure, hold the environment in its current state") 43 flag.BoolVar(&c.SkipLogGathering, "cilium.skipLogs", false, 44 "skip gathering logs if a test fails") 45 flag.StringVar(&c.SSHConfig, "cilium.SSHConfig", "", 46 "Specify a custom command to fetch SSH configuration (eg: 'vagrant ssh-config')") 47 flag.BoolVar(&c.ShowCommands, "cilium.showCommands", false, 48 "Output which commands are ran to stdout") 49 flag.StringVar(&c.TestScope, "cilium.testScope", "", 50 "Specifies scope of test to be ran (k8s, Nightly, runtime)") 51 flag.DurationVar(&c.Timeout, "cilium.timeout", 24*time.Hour, 52 "Specifies timeout for test run") 53 }