Skip to content

Commit 54228ec

Browse files
author
ailan.gl
committed
Merge remote-tracking branch 'remotes/origin/pre-release' into 3.0.1_Final
2 parents b23247e + d0c006e commit 54228ec

File tree

8 files changed

+151
-10
lines changed

8 files changed

+151
-10
lines changed

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
language: go
22

3-
sudo: false
3+
sudo: true
44

55
go:
6-
- 1.7.x
76
- 1.8.x
8-
- 1.9.x
9-
- 1.10.x
7+
8+
branches:
9+
only:
10+
- master
11+
- pre-release
12+
13+
before_install:
14+
- sudo apt-get install -y jq
1015

1116
install:
1217
- make deps
1318
- make testdeps
1419

1520
notifications:
16-
#webhooks: https://oapi.dingtalk.com/robot/send?access_token=096ed387df243a6d60835aadeccc47165f3813bc7cb81cdd0cfeadfd28e3acc1
21+
webhooks: https://oapi.dingtalk.com/robot/send?access_token=096ed387df243a6d60835aadeccc47165f3813bc7cb81cdd0cfeadfd28e3acc1
1722
email: false
1823
on_success: change
1924
on_failure: always
2025

2126
script:
2227
- make build
23-
- go test -v -timeout 30m ./...
28+
- sudo cp out/aliyun /usr/local/bin
29+
- cd ./integration && ./test

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ deps:
1515
go get github.com/aliyun/alibaba-cloud-sdk-go/sdk
1616
go get github.com/posener/complete
1717
go get github.com/aliyun/ossutil/lib
18+
go get gopkg.in/yaml.v2
1819

19-
testdeps:
20+
testdeps: deps
2021
go get -v github.com/onsi/ginkgo/ginkgo
2122
go get -v github.com/onsi/gomega
2223
go install github.com/onsi/ginkgo/ginkgo
2324
go get gopkg.in/check.v1
2425

25-
metas:
26+
metas: deps
2627
go-bindata -o resource/metas.go -pkg resource -prefix ../aliyun-openapi-meta ../aliyun-openapi-meta/**/* ../aliyun-openapi-meta/products.json
2728

2829
clean:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Aliyun Command Line Interface
2+
[![Build Status](https://travis-ci.org/aliyun/aliyun-cli.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-cli)
23

34
[中文文档](./README_zh.md)
45

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# 阿里云命令行工具 (Aliyun Command Line Interface)
2+
[![Build Status](https://travis-ci.org/aliyun/aliyun-cli.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-cli)
23

34
阿里云命令行工具(Alibaba Cloud Command Line Interface)是开源项目,您可以从[Github](https://github.com/aliyun/aliyun-cli)上获取最新版本的CLI。
45

integration/common

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
g_var=
4+
g_error=0
5+
force="force"
6+
7+
do_command() {
8+
if [[ $2 != $force && $g_error -eq 1 ]]
9+
then
10+
g_var=
11+
return $g_error
12+
fi
13+
14+
cmd="$1 --access-key-id $ACCESS_KEY_ID --access-key-secret $ACCESS_KEY_SECRET --region cn-beijing 2>&1"
15+
16+
echo "Command<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
17+
echo $cmd
18+
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Command"
19+
20+
g_var=$(eval $cmd)
21+
22+
echo "Result<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
23+
echo $g_var
24+
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Result"
25+
26+
err=$(echo $g_var | grep -i "error")
27+
28+
if [[ $2 != $force && $err != "" ]]
29+
then
30+
g_var=
31+
g_error=1
32+
return $g_error
33+
fi
34+
35+
return 0
36+
}

integration/ecs_test

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
source common
3+
4+
5+
ecs_create_instance() {
6+
do_command "aliyun ecs CreateInstance --ImageId ubuntu_16_0402_64_20G_alibase_20171227.vhd --InstanceType ecs.xn4.small" $1
7+
}
8+
9+
ecs_start_instance() {
10+
do_command "aliyun ecs StartInstance --InstanceId $1" $2
11+
}
12+
13+
ecs_stop_instance() {
14+
do_command "aliyun ecs StopInstance --InstanceId $1" $2
15+
}
16+
17+
ecs_instance_status_wait_until() {
18+
do_command "aliyun ecs DescribeInstances --InstanceIds ['$1'] --waiter expr=Instances.Instance[0].Status to=$2 timeout=600" $3
19+
}
20+
21+
ecs_describe_instances() {
22+
do_command "aliyun ecs DescribeInstances" $1
23+
}
24+
25+
ecs_delete_instance() {
26+
do_command "aliyun ecs DeleteInstance --InstanceId $1" $2
27+
}
28+
29+
ecs_get_instance_ids() {
30+
ecs_describe_instances $force
31+
ids=$(echo $g_var | jq '.Instances.Instance[].InstanceId')
32+
err=$(echo ids | grep -i "error")
33+
if [[ $err != "" ]]
34+
then
35+
g_var=""
36+
else
37+
g_var=$ids
38+
fi
39+
}
40+
41+
ecs_clear_all_instances() {
42+
ecs_get_instance_ids
43+
44+
ids=$g_var
45+
46+
for id in ${ids[@]}; do
47+
echo "###### Try to stop instance $id ######"
48+
ecs_stop_instance $id $force
49+
done
50+
51+
for id in ${ids[@]}; do
52+
echo "###### Try to delete instance $id ######"
53+
54+
ecs_instance_status_wait_until $id Stopped $force
55+
56+
ecs_delete_instance $id $force
57+
done
58+
}
59+
60+
ecs_test() {
61+
ecs_create_instance
62+
63+
id=$(echo $g_var | jq '.InstanceId')
64+
65+
echo "###### Try to test instance $id ######"
66+
67+
ecs_instance_status_wait_until $id Stopped
68+
69+
ecs_start_instance $id
70+
71+
ecs_instance_status_wait_until $id Running
72+
73+
ecs_stop_instance $id $force
74+
75+
ecs_instance_status_wait_until $id Stopped
76+
77+
ecs_delete_instance $id
78+
79+
if [[ $g_error -eq 1 ]]
80+
then
81+
ecs_clear_all_instances
82+
fi
83+
84+
return $g_error
85+
}
86+
87+

integration/test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
source ecs_test
4+
5+
ecs_test
6+
7+
echo "test result is $g_error"
8+
9+
exit $g_error

openapi/waiter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func (a *Waiter) CallWith(invoker Invoker) (string, error) {
5757
timeout := time.Duration(time.Second * 180)
5858
if s, ok := WaiterFlag.GetFieldValue("timeout"); ok {
5959
if n, err := strconv.Atoi(s); err == nil {
60-
if n <= 0 && n > 180 {
61-
return "", fmt.Errorf("--waiter timeout=%s must between 1-180 (seconds)", s)
60+
if n <= 0 && n > 600 {
61+
return "", fmt.Errorf("--waiter timeout=%s must between 1-600 (seconds)", s)
6262
}
6363
timeout = time.Duration(time.Second * time.Duration(n))
6464
} else {

0 commit comments

Comments
 (0)