Skip to content

Commit 78957ca

Browse files
authored
Fix the error of vineyardctl and add the related test. (#1991)
Fixes #1990 Signed-off-by: Ye Cao <[email protected]>
1 parent f1d9c37 commit 78957ca

File tree

6 files changed

+99
-3
lines changed

6 files changed

+99
-3
lines changed

.github/workflows/vineyard-operator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
- e2e-tests-workflow
7575
- e2e-tests-mars-examples
7676
- e2e-tests-vineyardctl
77+
- e2e-tests-vineyardctl-python-api
7778
- e2e-tests-deploy-raw-backup-and-recover
7879
- e2e-tests-three-etcd-nodes-failover
7980
- e2e-tests-five-etcd-nodes-failover
@@ -161,6 +162,7 @@ jobs:
161162
162163
- name: Generate the python and vineyardd image for tests
163164
run: |
165+
go build -a -o python/vineyard/bdist/vineyardctl k8s/cmd/main.go && \
164166
make -C k8s/test/e2e build-base-images
165167
166168
- name: unit-tests
@@ -278,6 +280,11 @@ jobs:
278280
if: ${{ matrix.job == 'e2e-tests-vineyardctl' }}
279281
run: |
280282
make -C k8s/test/e2e e2e-tests-vineyardctl
283+
284+
- name: e2e-tests-vineyardctl-python-api
285+
if: ${{ matrix.job == 'e2e-tests-vineyardctl-python-api' }}
286+
run: |
287+
make -C k8s/test/e2e e2e-tests-vineyardctl-python-api
281288
282289
- name: e2e-tests-deploy-raw-backup-and-recover
283290
if: ${{ matrix.job == 'e2e-tests-deploy-raw-backup-and-recover' }}

k8s/cmd/commands/util/usage/types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ func CobraUsage(cmd *cobra.Command) (Command, error) {
5959
c.Children = append(c.Children, childUsage)
6060
}
6161
cmd.LocalFlags().VisitAll(func(flag *pflag.Flag) {
62-
c.Flags = append(c.Flags, FlagUsage(flag))
62+
if flag.Name != "log-flush-frequency" {
63+
c.Flags = append(c.Flags, FlagUsage(flag))
64+
}
6365
})
6466
cmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
65-
c.GlobalFlags = append(c.GlobalFlags, FlagUsage(flag))
67+
if flag.Name != "log-flush-frequency" {
68+
c.GlobalFlags = append(c.GlobalFlags, FlagUsage(flag))
69+
}
6670
})
6771
return c, nil
6872
}

k8s/cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func init() {
6363

6464
flags.ApplyGlobalFlags(cmd)
6565

66+
if cmd.Flags().Lookup("log-flush-frequency") != nil {
67+
if err := cmd.Flags().MarkHidden("log-flush-frequency"); err != nil {
68+
log.Fatal(err, "Failed to mark hidden flag")
69+
}
70+
}
6671
// disable completion command
6772
cmd.CompletionOptions.DisableDefaultCmd = true
6873

k8s/test/e2e/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,16 @@ e2e-tests-vineyardctl: prepare-e2e-test build-local-cluster load-vineyardd-image
384384
@make delete-local-cluster
385385
.PHONY: e2e-tests-vineyardctl
386386

387+
############# vineyardctl python api testing ################################################
388+
389+
e2e-tests-vineyardctl-python-api: prepare-e2e-test build-local-cluster load-vineyardd-image load-vineyard-python-dev-image
390+
@make -C ${E2E_DIR} install-vineyard-operator
391+
@echo "Running vineyardctl python api e2e test..."
392+
@cd ${ROOT_DIR} && ${GOBIN}/e2e run --config=${E2E_DIR}/vineyardctl-python-api/e2e.yaml
393+
@echo "vineyardctl python api e2e test passed."
394+
@make delete-local-cluster
395+
.PHONY: e2e-tests-vineyardctl-python-api
396+
387397
############# backup and recover testing ################################################
388398

389399
e2e-tests-deploy-raw-backup-and-recover: prepare-e2e-test build-local-cluster load-vineyardd-image

k8s/test/e2e/etcd-failover/three-etcd-nodes-failover-e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ setup:
3232
kubectl delete pod vineyardd-$(shuf -i 0-2 -n 1) -n default --force
3333
kubectl rollout status statefulset/vineyardd
3434
# wait for the instance quit messages to be propagated
35-
sleep 120
35+
sleep 180
3636
kubectl rollout status statefulset/vineyardd
3737
done
3838
- name: install consumer
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2020-2023 Alibaba Group Holding Limited.
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+
16+
setup:
17+
env: kind
18+
kubeconfig: /tmp/e2e-k8s.config
19+
steps:
20+
- name: download all workflow images into kind cluster
21+
command: |
22+
make -C k8s/test/e2e publish-workflow-images REGISTRY=localhost:5001
23+
- name: install vineyardd
24+
command: |
25+
docker run --net=host -v /tmp/e2e-k8s.config:/root/.kube/config:ro localhost:5001/vineyard-python-dev:latest \
26+
"python -c \"import vineyard; vineyard.deploy.vineyardctl.deploy.vineyardd(vineyardd_image='localhost:5001/vineyardd:latest', kubeconfig='/root/.kube/config')\""
27+
- name: install job1
28+
command: |
29+
kubectl create namespace vineyard-job
30+
kubectl apply -f k8s/test/e2e/workflow-demo/workflow-job1.yaml
31+
wait:
32+
- namespace: vineyard-job
33+
resource: job/v6d-workflow-demo-job1
34+
for: condition=Complete
35+
- name: install job2
36+
command: |
37+
kubectl apply -f k8s/test/e2e/workflow-demo/workflow-job2.yaml
38+
wait:
39+
- namespace: vineyard-job
40+
resource: job/v6d-workflow-demo-job2
41+
for: condition=Complete
42+
timeout: 20m
43+
44+
cleanup:
45+
# always never success failure
46+
on: never
47+
48+
verify:
49+
# verify with retry strategy
50+
retry:
51+
# max retry count
52+
count: 10
53+
# the interval between two attempts, e.g. 10s, 1m.
54+
interval: 10s
55+
cases:
56+
- query: |
57+
kubectl get pod -l app=v6d-workflow-demo-job2 -n vineyard-job -oname | \
58+
awk -F '/' '{print $2}' | \
59+
head -n 1 | \
60+
xargs kubectl logs -n vineyard-job | \
61+
yq e '{"sum": .}' - | \
62+
yq e 'to_entries' -
63+
expected: ../verify/values.yaml
64+
# test the job can only be scheduled on the nodes with the vineyardd
65+
- query: |
66+
export job1_nodes=$(kubectl get pod -l app=v6d-workflow-demo-job1 -nvineyard-job -o=custom-columns=NODE:.spec.nodeName | awk 'NR != 1' | sort | tr '\n' ' ')
67+
export job2_nodes=$(kubectl get pod -l app=v6d-workflow-demo-job2 -nvineyard-job -o=custom-columns=NODE:.spec.nodeName | awk 'NR != 1' | sort | tr '\n' ' ')
68+
export vineyardd_nodes=$(kubectl get pod -l app.kubernetes.io/instance=vineyardd -n vineyard-system -o=custom-columns=NODE:.spec.nodeName | awk 'NR != 1' | sort | tr '\n' ' ')
69+
if [[ $job1_nodes = $vineyardd_nodes ]] && [[ $job2_nodes = $vineyardd_nodes ]]; then echo '{"AllJobInVineyarddNodes":"true"}' | yq e 'to_entries' -; fi
70+
expected: ../verify/nodes.yaml

0 commit comments

Comments
 (0)