volcano.sh/volcano@v1.9.0/test/e2e/vcctl/vcctl.go (about) 1 /* 2 Copyright 2021 The Volcano Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package vcctl 18 19 import ( 20 "os" 21 "strings" 22 23 . "github.com/onsi/ginkgo/v2" 24 . "github.com/onsi/gomega" 25 ) 26 27 var _ = Describe("Test Help option of vcctl cli", func() { 28 29 It("Command: vcctl --help", func() { 30 var output = ` 31 Usage: 32 vcctl [command] 33 34 Available Commands: 35 help Help about any command 36 job vcctl command line operation job 37 queue Queue Operations 38 version Print the version information 39 40 Flags: 41 -h, --help help for vcctl 42 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 43 44 Use "vcctl [command] --help" for more information about a command. 45 46 ` 47 command := []string{"--help"} 48 cmdOutput := RunCliCommandWithoutKubeConfig(command) 49 exist := strings.Contains(output, cmdOutput) 50 Expect(exist).Should(Equal(true)) 51 }) 52 53 It("Command: vcctl job --help", func() { 54 var output = ` 55 vcctl command line operation job 56 57 Usage: 58 vcctl job [command] 59 60 Available Commands: 61 delete delete a job 62 list list job information 63 resume resume a job 64 run run job by parameters from the command line 65 suspend abort a job 66 view show job information 67 68 Flags: 69 -h, --help help for job 70 71 Global Flags: 72 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 73 74 Use "vcctl job [command] --help" for more information about a command. 75 76 ` 77 command := []string{"job", "--help"} 78 cmdOutput := RunCliCommandWithoutKubeConfig(command) 79 exist := strings.Contains(output, cmdOutput) 80 Expect(exist).Should(Equal(true)) 81 }) 82 83 It("Command: vcctl job list --help", func() { 84 kubeConfig := os.Getenv("KUBECONFIG") 85 var output = ` 86 list job information 87 88 Usage: 89 vcctl job list [flags] 90 91 Flags: 92 --all-namespaces list jobs in all namespaces 93 -h, --help help for list 94 -k, --kubeconfig string (optional) absolute path to the kubeconfig file (default "` + kubeConfig + `") 95 -s, --master string the address of apiserver 96 -n, --namespace string the namespace of job (default "default") 97 -S, --scheduler string list job with specified scheduler name 98 --selector string fuzzy matching jobName 99 100 Global Flags: 101 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 102 103 ` 104 command := []string{"job", "list", "--help"} 105 cmdOutput := RunCliCommandWithoutKubeConfig(command) 106 exist := strings.Contains(output, cmdOutput) 107 Expect(exist).Should(Equal(true)) 108 }) 109 110 It("Command: vcctl job suspend -n {$JobName} --help", func() { 111 kubeConfig := os.Getenv("KUBECONFIG") 112 var output = ` 113 abort a job 114 115 Usage: 116 vcctl job suspend [flags] 117 118 Flags: 119 -h, --help help for suspend 120 -k, --kubeconfig string (optional) absolute path to the kubeconfig file (default "` + kubeConfig + `") 121 -s, --master string the address of apiserver 122 -N, --name string the name of job 123 -n, --namespace string the namespace of job (default "default") 124 125 Global Flags: 126 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 127 128 ` 129 command := []string{"job", "suspend", "-n", "job1", "--help"} 130 cmdOutput := RunCliCommandWithoutKubeConfig(command) 131 exist := strings.Contains(output, cmdOutput) 132 Expect(exist).Should(Equal(true)) 133 }) 134 135 It("vcctl job resume -n {$JobName} --help", func() { 136 kubeConfig := os.Getenv("KUBECONFIG") 137 var output = ` 138 resume a job 139 140 Usage: 141 vcctl job resume [flags] 142 143 Flags: 144 -h, --help help for resume 145 -k, --kubeconfig string (optional) absolute path to the kubeconfig file (default "` + kubeConfig + `") 146 -s, --master string the address of apiserver 147 -N, --name string the name of job 148 -n, --namespace string the namespace of job (default "default") 149 150 Global Flags: 151 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 152 153 ` 154 command := []string{"job", "resume", "-n", "job1", "--help"} 155 cmdOutput := RunCliCommandWithoutKubeConfig(command) 156 exist := strings.Contains(output, cmdOutput) 157 Expect(exist).Should(Equal(true)) 158 }) 159 160 It("vcctl job run --help", func() { 161 kubeConfig := os.Getenv("KUBECONFIG") 162 var output = ` 163 run job by parameters from the command line 164 165 Usage: 166 vcctl job run [flags] 167 168 Flags: 169 -f, --filename string the yaml file of job 170 -h, --help help for run 171 -i, --image string the container image of job (default "busybox") 172 -k, --kubeconfig string (optional) absolute path to the kubeconfig file (default "` + kubeConfig + `") 173 -L, --limits string the resource limit of the task (default "cpu=1000m,memory=100Mi") 174 -s, --master string the address of apiserver 175 -m, --min int the minimal available tasks of job (default 1) 176 -N, --name string the name of job 177 -n, --namespace string the namespace of job (default "default") 178 -r, --replicas int the total tasks of job (default 1) 179 -R, --requests string the resource request of the task (default "cpu=1000m,memory=100Mi") 180 -S, --scheduler string the scheduler for this job (default "volcano") 181 182 Global Flags: 183 --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s) 184 185 ` 186 command := []string{"job", "run", "--help"} 187 cmdOutput := RunCliCommandWithoutKubeConfig(command) 188 exist := strings.Contains(output, cmdOutput) 189 Expect(exist).Should(Equal(true)) 190 }) 191 192 })