Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit b1bf7af

Browse files
committed
[integration-test] support run test case in container
1 parent 3108626 commit b1bf7af

File tree

5 files changed

+64
-174
lines changed

5 files changed

+64
-174
lines changed

Dockerfile.centos

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM centos:7.2.1511
1+
FROM centos:7.3.1611
22

33
#REF: integration-cli/README.md
44

@@ -12,8 +12,8 @@ RUN yum install -y\
1212

1313

1414
## Install Go
15-
ENV GO_VERSION 1.5.3
16-
RUN wget http://golangtc.com/static/go/1.5.3/go1.5.3.linux-amd64.tar.gz
15+
ENV GO_VERSION 1.7.4
16+
RUN wget http://golangtc.com/static/go/${GO_VERSION}/go${GO_VERSION}.linux-amd64.tar.gz
1717
#RUN wget http://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
1818
RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local
1919

@@ -66,3 +66,4 @@ RUN git config --global color.ui true; \
6666
git config --global alias.cm '!sh -c "br_name=`git symbolic-ref HEAD|sed s#refs/heads/##`; git commit -em \"[\${br_name}] \""'; \
6767
git config --global alias.lg "log --graph --pretty=format:'[%ci] %Cgreen(%cr) %Cred%h%Creset -%x09%C(yellow)%Creset %C(cyan)[%an]%Creset %x09 %s%Creset' --abbrev-commit --date=short"; \
6868
git config --global push.default current
69+

hack/generate-hyper-conf.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ EOF
1919
#show config for hyper cli
2020
echo "Current hyper config: ~/.hyper/config.json"
2121
echo "----------------------------------------------------------------------------------------------"
22-
cat ~/.hyper/config.json
22+
cat ~/.hyper/config.json \
23+
| sed 's/"secretkey":.*/"secretkey": "******************************"/g' \
24+
| sed 's/"auth":.*/"auth": "******************************"/g'
2325
echo "----------------------------------------------------------------------------------------------"
2426

2527
#show example
2628
cat <<EOF
2729
2830
Run in container(example):
29-
./build-hyperserve-client.sh # build hyper cli
31+
./build.sh # build hyper cli
3032
-----------------------------------------------------------
3133
hypercli info | grep "ID" # get tennat id
3234
hypercli pull busybox # pull image

integration-cli/README.md

Lines changed: 21 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,16 @@ Integration test for hyper cli
1515
- [hyper only](#hyper-only)
1616
- [both](#both)
1717
- [docker only](#docker-only)
18-
- [Prepare](#prepare)
19-
- [clone hypercli repo](#clone-hypercli-repo)
20-
- [build docker image](#build-docker-image)
21-
- [make hyper cli in container](#make-hyper-cli-in-container)
22-
- [common info in container](#common-info-in-container)
2318
- [Run test case](#run-test-case)
24-
- [enter container](#enter-container)
25-
- [run test in container](#run-test-in-container)
26-
- [(optional)test connection to apirouter service](#optionaltest-connection-to-apirouter-service)
27-
- [prepare test case](#prepare-test-case)
28-
- [adjust test case code](#adjust-test-case-code)
29-
- [start test](#start-test)
30-
- [Check test result](#check-test-result)
31-
- [if test case passed](#if-test-case-passed)
32-
- [if find issues](#if-find-issues)
33-
- [if test case will be supported in the future](#if-test-case-will-be-supported-in-the-future)
34-
- [After issues fixed](#after-issues-fixed)
35-
36-
- [Run test on localhost](#run-test-on-localhost)
19+
- [clone hypercli repo](#clone-hypercli-repo)
20+
- [run test in docker container](#run-test-in-docker-container)
21+
- [build docker image](#build-docker-image)
22+
- [make hyper cli](#make-hyper-cli)
23+
- [enter container](#enter-container)
24+
- [run test in container](#run-test-in-container)
25+
- [Run test on localhost](#run-test-on-localhost)
26+
- [prepare](#prepare)
27+
- [run test case](#run-test-case)
3728

3829
<!-- /TOC -->
3930

@@ -168,16 +159,16 @@ push save tag top unpause
168159
update wait
169160
```
170161

171-
172-
173-
# Prepare
162+
# Run test case
174163

175164
## clone hypercli repo
176165
```
177-
$ git clone https://github.com/hyperhq/hypercli.git -b integration-test
166+
$ git clone https://github.com/hyperhq/hypercli.git
178167
```
179168

180-
## build docker image
169+
## run test in docker container
170+
171+
### build docker image
181172

182173
> build docker image in host OS
183174
> Use `CentOS` as test env
@@ -187,7 +178,7 @@ $ git clone https://github.com/hyperhq/hypercli.git -b integration-test
187178
$ ./util.sh build
188179
```
189180

190-
## make hyper cli in container
181+
### make hyper cli
191182

192183
> build hyper cli binary from source code
193184
@@ -196,25 +187,7 @@ $ ./util.sh build
196187
$ ./util.sh make
197188
```
198189

199-
## common info in container
200-
201-
- work dir : `/go/src/github.com/hyperhq/hypercli`
202-
- hyper config : `/root/.hyper/config.json`
203-
- hyper cli binary: `/usr/bin/hyper` -> `/go/src/github.com/hyperhq/hypercli/hyper/hyper`
204-
- hyper cli alias : `hypercli` => `hyper -H ${DOCKER_HOST}`
205-
- test case dir : `/go/src/github.com/hyperhq/hypercli/integration-cli`
206-
```
207-
integration-cli
208-
├── skip => test cases to be ignored
209-
├── todo => test cases to be tested
210-
├── issue => test cases have issue/bug
211-
└── passed => test cases have passed
212-
```
213-
214-
215-
# Run test case
216-
217-
## enter container
190+
### enter container
218191

219192
> update `ACCESS_KEY` and `SECRET_KEY` in `integration-cli/util.conf`
220193
@@ -223,82 +196,14 @@ integration-cli
223196
$ ./util.sh enter
224197
```
225198

226-
## run test in container
227-
228-
### (optional)test connection to apirouter service
229-
```
230-
// run in any dir in container
231-
$ hypercli version
232-
$ hypercli info | grep "ID" #tenant id
233-
$ hypercli pull busybox
234-
$ hypercli images
235-
```
236-
237-
### prepare test case
238-
239-
- **test new case**: move test case from `integration-cli/todo` to `integration-cli`
240-
- **test issue case after fixed**: move test case from `integration-cli/issue` to `integration-cli`
241-
242-
### adjust test case code
243-
244-
- add `printTestCaseName(); defer printTestDuration(time.Now())` in function start with `Test`
245-
- hyper cli source will be mapped in to the container, so the test case code can be modified out of container
246-
199+
### run test in container
247200
```
248-
//example:
249-
func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
250-
printTestCaseName(); defer printTestDuration(time.Now()) <<<<<<======
251-
out, _ := dockerCmd(c, "version")
252-
253-
//test result will be output like:
254-
[2016-04-26 03:21:52] github.com/hyperhq/hypercli/integration-cli.(*DockerSuite).TestVersionEnsureSucceeds - 1.952121 sec
255-
```
256-
257-
### start test
258-
259-
```
260-
// run in dir hypercli/integration-cli in container
261-
$ go test
262-
```
263-
264-
# Check test result
265-
266-
> Check the `passed` number of `go test` result
267-
268-
```
269-
...
270-
INFO: Testing against a remote daemon
271-
...
272-
OK: ? passed, ? skipped
273-
PASS
274-
ok github.com/hyperhq/hypercli/integration-cli ?s
201+
$ ./util.sh test all
275202
```
276203

277-
## if test case passed
278-
279-
- move the test case to `integration-cli/passed` dir
280-
- continue next test case
281-
282-
## if find issues
283-
284-
- move the test case to `integration-cli/issue` dir
285-
- please create a new issue here: https://github.com/hyperhq/hypercli/issues
286-
- continue next test case
287-
288-
## if test case will be supported in the future
289-
290-
- move the test case to `integration-cli/future` dir
291-
- continue next test case
292-
293-
# After issues fixed
294-
295-
- move the test case from `integration-cli/issue` to `integration-cli` dir
296-
- go to [start test](#start-test)
297-
298-
299-
# Run test on localhost
204+
## Run test on localhost
300205

301-
## prepare
206+
### prepare
302207

303208
```
304209
// ensure hyperhq and docker dir
@@ -325,12 +230,11 @@ $ ./util.sh
325230
326231
// config util.conf
327232
$ vi util.conf
328-
HYPER_CONFIG=<$HOME/.hyper>
329233
ACCESS_KEY="<hyper access key>"
330234
SECRET_KEY="<hyper secret key>"
331235
```
332236

333-
## run test case
237+
### run test case
334238

335239
```
336240
// run all test cases

integration-cli/util.conf.template

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export GOPATH="$(pwd)/vendor:$GOPATH"
2+
export HYPER_CONFIG="$HOME/.hyper"
3+
export IMAGE_DIR="/tmp/image"
4+
export LOCAL_DOCKER_HOST="unix:///var/run/docker.sock"
5+
export DOCKER_REMOTE_DAEMON=1
6+
7+
#########################################
8+
#packet env
9+
#########################################
10+
#export HYPER_HOST="tcp://147.75.195.39:6443" #packet
11+
export HYPER_HOST="tcp://us-west-1.hyper.sh:443" #zenlayer
12+
13+
#Hyper Credentials
14+
export ACCESS_KEY="xxxxxx"
15+
export SECRET_KEY="xxxxxx"
16+
17+
#########################################
18+
## AWS Credentials(option)
19+
#########################################
20+
export AWS_ACCESS_KEY="xxxxxx"
21+
export AWS_SECRET_KEY="xxxxxx"
22+
23+
#########################################
24+
##MONGODB(option)
25+
#########################################
26+
export MONGODB_URL="xxxxxx"
27+
28+
##For test load image from basic auth url
29+
export URL_WITH_BASIC_AUTH="http://xxxxxx:xxxxxx@test.hyper.sh/ubuntu.tar.gz"

integration-cli/util.sh

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -34,62 +34,15 @@ cd ${WORKDIR}
3434
#############################################################################
3535
# ensure util.conf
3636
if [ ! -s ${WORKDIR}/util.conf ];then
37-
cat > ${WORKDIR}/util.conf <<EOF
38-
export GOPATH=\$(pwd)/vendor:\$(pwd)/../vendor:$GOPATH
39-
export HYPER_CONFIG=\$HOME/.hyperpkt1
40-
export IMAGE_DIR=/tmp/image
41-
export LOCAL_DOCKER_HOST="unix:///var/run/docker.sock"
42-
43-
#########################################
44-
export DOCKER_REMOTE_DAEMON=1
45-
46-
#########################################
47-
#packet env
48-
#########################################
49-
#apirouter service
50-
export DOCKER_HOST=tcp://147.75.195.39:6443
51-
#Hyper Credentials
52-
53-
export ACCESS_KEY="8Gxxxxxxxxxxxxxxxxx8JL"
54-
export SECRET_KEY="Ek7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxpOe"
55-
56-
57-
#########################################
58-
#zenlayer env
59-
#########################################
60-
#apirouter service
61-
#DOCKER_HOST=tcp://us-west-1.hyper.sh:443
62-
63-
#Hyper Credentials
64-
#ACCESS_KEY=
65-
#SECRET_KEY=
66-
67-
68-
#########################################
69-
## AWS Credentials(option)
70-
#########################################
71-
export AWS_ACCESS_KEY=AKIxxxxxxxxxxxxxQRQ
72-
export AWS_SECRET_KEY=UWuxxxxxxxxxxxxxxxxxxxxxxxxxxQCH
73-
74-
75-
#########################################
76-
##MONGODB(option)
77-
#########################################
78-
export MONGODB_URL=
79-
80-
81-
##For test load image from basic auth url
82-
export URL_WITH_BASIC_AUTH=http://xxxx:xxxxxx@test.hyper.sh/ubuntu.tar.gz
83-
EOF
84-
37+
cp util.conf.template util.conf
8538
fi
8639

8740

8841
# load util.conf
8942
source ${WORKDIR}/util.conf
9043

9144
# check util.conf
92-
if [[ "${DOCKER_HOST}" == "" ]] || [[ "${ACCESS_KEY}" == "" ]] || [[ "${SECRET_KEY}" == "" ]];then
45+
if [[ "${ACCESS_KEY}" == "" ]] || [[ "${SECRET_KEY}" == "" ]];then
9346
echo "please update 'ACCESS_KEY' and 'SECRET_KEY' in '${WORKDIR}/util.conf'"
9447
exit 1
9548
fi
@@ -110,18 +63,19 @@ case $1 in
11063
;;
11164
enter)
11265
docker run -it --rm \
113-
-e DOCKER_HOST=${DOCKER_HOST} \
66+
-e DOCKER_HOST=${HYPER_HOST} \
11467
-e ACCESS_KEY=${ACCESS_KEY} \
11568
-e SECRET_KEY=${SECRET_KEY} \
11669
-e AWS_ACCESS_KEY=${AWS_ACCESS_KEY} \
11770
-e AWS_SECRET_KEY=${AWS_SECRET_KEY} \
11871
-e URL_WITH_BASIC_AUTH=${URL_WITH_BASIC_AUTH} \
11972
-e MONGODB_URL=${MONGODB_URL} \
12073
-v $(pwd)/../:/go/src/github.com/hyperhq/hypercli \
121-
hyperhq/hypercli zsh
74+
hyperhq/hypercli bash
12275
;;
12376
test)
124-
mkdir -p ${IMAGE_DIR}
77+
export DOCKER_HOST=${HYPER_HOST}
78+
mkdir -p ${IMAGE_DIR}
12579
shift
12680
if [ $# -ne 0 ];then
12781
if [ $1 == "all" ];then

0 commit comments

Comments
 (0)