github.com/oam-dev/kubevela@v1.9.11/cmd/core/main_e2e_test.go (about) 1 /* 2 Copyright 2021 The KubeVela Authors. 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 16 package main 17 18 import ( 19 "fmt" 20 "os" 21 "os/signal" 22 "strings" 23 "syscall" 24 "testing" 25 ) 26 27 func TestE2EMain(t *testing.T) { 28 fmt.Println("this is e2e test") 29 var ( 30 args []string 31 run bool 32 ) 33 34 for _, arg := range os.Args { 35 switch { 36 case strings.HasPrefix(arg, "__DEVEL__E2E"): 37 run = true 38 case strings.HasPrefix(arg, "-test"): 39 default: 40 args = append(args, arg) 41 } 42 } 43 44 if !run { 45 return 46 } 47 48 waitCh := make(chan int, 1) 49 50 //args=append(args, "leader-election-namespace='someNS'") 51 os.Args = args 52 go func() { 53 main() 54 close(waitCh) 55 }() 56 57 signalCh := make(chan os.Signal, 1) 58 signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP) 59 select { 60 case <-signalCh: 61 case <-waitCh: 62 } 63 fmt.Println("exit test e2e main") 64 }