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

Commit d8a9672

Browse files
authored
Merge pull request #222 from hyperhq/integration-test
Integration test
2 parents 5ad7679 + f62bbcc commit d8a9672

File tree

258 files changed

+40352
-9333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+40352
-9333
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ man/man8
3838
pyenv
3939
vendor/pkg/
4040
*.yml
41+
.idea
42+
integration-cli/util.conf

Dockerfile.dev

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM centos:7.3.1611
2+
3+
#This Dockerfile is used for dev hypercli
4+
#REF: integration-cli/README.md
5+
6+
##########################################################################
7+
RUN yum install -y\
8+
automake\
9+
gcc\
10+
wget\
11+
time\
12+
git
13+
14+
15+
## Install Go
16+
ENV GO_VERSION 1.7.4
17+
RUN wget http://golangtc.com/static/go/${GO_VERSION}/go${GO_VERSION}.linux-amd64.tar.gz
18+
#RUN wget http://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
19+
RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local
20+
21+
## Env
22+
ENV PATH /go/bin:/usr/local/go/bin:$PATH
23+
ENV GOPATH /go:/go/src/github.com/hyperhq/hypercli/vendor
24+
25+
ENV HYPER_CONFIG=/root/.hyper
26+
ENV DOCKER_REMOTE_DAEMON=1
27+
ENV DOCKER_CERT_PATH=fixtures/hyper_ssl
28+
ENV DOCKER_TLS_VERIFY=
29+
ENV DOCKER_HOST=
30+
ENV ACCESS_KEY=
31+
ENV SECRET_KEY=
32+
33+
34+
## Ensure /usr/bin/hyper
35+
RUN ln -s /go/src/github.com/hyperhq/hypercli/hyper/hyper /usr/bin/hyper
36+
RUN echo alias hypercli=\"hyper -H \${DOCKER_HOST}\" >> /root/.bashrc
37+
38+
39+
## Ensure /go/src/github.com/docker/docker
40+
RUN mkdir -p /go/src/github.com/docker
41+
RUN ln -s /go/src/github.com/hyperhq/hypercli /go/src/github.com/docker/docker
42+
43+
44+
WORKDIR /go/src/github.com/hyperhq/hypercli
45+
VOLUME ["/go/src/github.com/hyperhq/hypercli"]
46+
ENTRYPOINT ["hack/generate-hyper-conf-dev.sh"]
47+
48+
49+
##########################################################################
50+
# install on-my-zsh
51+
RUN yum install -y zsh
52+
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
53+
RUN sed -i "s/^ZSH_THEME=.*/ZSH_THEME=\"gianu\"/g" /root/.zshrc
54+
RUN echo alias hypercli=\"hyper -H \${DOCKER_HOST}\" >> /root/.zshrc
55+
56+
# config git
57+
RUN git config --global color.ui true; \
58+
git config --global color.status auto; \
59+
git config --global color.diff auto; \
60+
git config --global color.branch auto; \
61+
git config --global color.interactive auto; \
62+
git config --global alias.st 'status'; \
63+
git config --global alias.ci 'commit'; \
64+
git config --global alias.co 'checkout'; \
65+
git config --global alias.br 'branch'; \
66+
git config --global alias.sr 'show-ref'; \
67+
git config --global alias.cm '!sh -c "br_name=`git symbolic-ref HEAD|sed s#refs/heads/##`; git commit -em \"[\${br_name}] \""'; \
68+
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"; \
69+
git config --global push.default current

Dockerfile.qa

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM centos:7.3.1611
2+
3+
#This Dockerfile is used for autotest hypercli
4+
#REF: integration-cli/README.md
5+
6+
##########################################################################
7+
RUN yum install -y\
8+
automake\
9+
gcc\
10+
wget\
11+
time\
12+
git
13+
14+
15+
## Install Go
16+
ENV GO_VERSION 1.7.4
17+
RUN wget http://golangtc.com/static/go/${GO_VERSION}/go${GO_VERSION}.linux-amd64.tar.gz
18+
#RUN wget http://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
19+
RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local
20+
21+
## Env
22+
ENV PATH /go/bin:/usr/local/go/bin:$PATH
23+
ENV GOPATH /go:/go/src/github.com/hyperhq/hypercli/integration-cli/vendor:/go/src/github.com/hyperhq/hypercli/vendor
24+
25+
ENV HYPER_CONFIG=/root/.hyper
26+
ENV DOCKER_REMOTE_DAEMON=1
27+
ENV DOCKER_CERT_PATH=fixtures/hyper_ssl
28+
ENV DOCKER_TLS_VERIFY=
29+
30+
ENV DOCKER_HOST="tcp://us-west-1.hyper.sh:443"
31+
## if BRANCH start with '#', then it means PR number, otherwise it means branch name
32+
ENV BRANCH="master"
33+
34+
ENV ACCESS_KEY=
35+
ENV SECRET_KEY=
36+
37+
RUN mkdir -p /go/src/github.com/hyperhq
38+
WORKDIR /go/src/github.com/hyperhq
39+
40+
ADD hack/generate-hyper-conf-qa.sh /generate-hyper-conf-qa.sh
41+
ENTRYPOINT ["/generate-hyper-conf-qa.sh"]

hack/generate-hyper-conf-dev.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
if [ "$@" != "./build.sh" ];then
4+
#ensure config for hyper cli
5+
mkdir -p ~/.hyper
6+
cat > ~/.hyper/config.json <<EOF
7+
{
8+
"clouds": {
9+
"${DOCKER_HOST}": {
10+
"accesskey": "${ACCESS_KEY}",
11+
"secretkey": "${SECRET_KEY}"
12+
}
13+
}
14+
}
15+
EOF
16+
echo "##############################################################################################"
17+
echo "## Welcome to integration test env ##"
18+
echo "##############################################################################################"
19+
#show config for hyper cli
20+
echo "Current hyper config: ~/.hyper/config.json"
21+
echo "----------------------------------------------------------------------------------------------"
22+
cat ~/.hyper/config.json \
23+
| sed 's/"secretkey":.*/"secretkey": "******************************"/g' \
24+
| sed 's/"auth":.*/"auth": "******************************"/g'
25+
echo "----------------------------------------------------------------------------------------------"
26+
27+
#show example
28+
cat <<EOF
29+
30+
Run in container(example):
31+
./build.sh # build hyper cli
32+
-----------------------------------------------------------
33+
hypercli info | grep "ID" # get tennat id
34+
hypercli pull busybox # pull image
35+
hypercli images # list images
36+
-----------------------------------------------------------
37+
cd integration-cli && go test # start autotest
38+
39+
# 'hypercli' is the alias of 'hyper -H \${DOCKER_HOST}'
40+
41+
EOF
42+
fi
43+
44+
#execute command
45+
if [ $# -ne 0 ];then
46+
eval $@
47+
if [ "$@" == "./build.sh" ];then
48+
#show make result
49+
if [ $? -eq 0 ];then
50+
echo "OK:)"
51+
else
52+
echo "Failed:("
53+
fi
54+
fi
55+
fi

hack/generate-hyper-conf-qa.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
env
4+
5+
# set default value of DOCKER_HOST and BRANCH
6+
if [[ "$DOCKER_HOST" == "" ]];then
7+
DOCKER_HOST="tcp://us-west-1.hyper.sh:443"
8+
fi
9+
10+
PR=""
11+
if [[ "${BRANCH:0:1}" == "#" ]];then
12+
PR=${BRANCH:1}
13+
BRANCH=""
14+
echo "========== Task: test PR #${PR} =========="
15+
else
16+
if [[ "${BRANCH}" == "" ]];then
17+
BRANCH="master"
18+
fi
19+
echo "========== Task: test BRANCH ${BRANCH} =========="
20+
fi
21+
22+
23+
if [[ "$@" != "./build.sh" ]];then
24+
#ensure config for hyper cli
25+
mkdir -p ~/.hyper
26+
cat > ~/.hyper/config.json <<EOF
27+
{
28+
"clouds": {
29+
"${DOCKER_HOST}": {
30+
"accesskey": "${ACCESS_KEY}",
31+
"secretkey": "${SECRET_KEY}"
32+
}
33+
}
34+
}
35+
EOF
36+
37+
echo "========== config git proxy =========="
38+
if [ "${http_proxy}" != "" ];then
39+
git config --global http.proxy ${http_proxy}
40+
fi
41+
if [ "${https_proxy}" != "" ];then
42+
git config --global https.proxy ${https_proxy}
43+
fi
44+
git config --list | grep proxy
45+
46+
echo "========== ping github.com =========="
47+
ping -c 6 -W 10 github.com
48+
49+
echo "========== Clone hypercli repo =========="
50+
mkdir -p /go/src/github.com/{hyperhq,docker}
51+
cd /go/src/github.com/hyperhq
52+
git clone https://github.com/hyperhq/hypercli.git
53+
54+
echo "========== Build hypercli =========="
55+
cd /go/src/github.com/hyperhq/hypercli
56+
if [[ "${BRANCH}" != "" ]];then
57+
echo "checkout branch :${BRANCH}"
58+
git checkout ${BRANCH}
59+
elif [[ "${PR}" != "" ]];then
60+
echo "checkout pr :#$PR"
61+
git fetch origin pull/${PR}/head:pr-${PR}
62+
git checkout pr-${PR}
63+
fi
64+
65+
if [[ $? -ne 0 ]];then
66+
echo "Branch ${BRANCH} not exist!"
67+
exit 1
68+
fi
69+
./build.sh
70+
ln -s /go/src/github.com/hyperhq/hypercli /go/src/github.com/docker/docker
71+
ln -s /go/src/github.com/hyperhq/hypercli/hyper/hyper /usr/bin/hyper
72+
echo alias hypercli=\"hyper -H \${DOCKER_HOST}\" >> /root/.bashrc
73+
source /root/.bashrc
74+
75+
echo "##############################################################################################"
76+
echo "## Welcome to integration test env ##"
77+
echo "##############################################################################################"
78+
#show config for hyper cli
79+
echo "Current hyper config: ~/.hyper/config.json"
80+
echo "----------------------------------------------------------------------------------------------"
81+
cat ~/.hyper/config.json \
82+
| sed 's/"secretkey":.*/"secretkey": "******************************"/g' \
83+
| sed 's/"auth":.*/"auth": "******************************"/g'
84+
echo "----------------------------------------------------------------------------------------------"
85+
86+
fi
87+
88+
#execute command
89+
if [[ $# -ne 0 ]];then
90+
echo "========== Test Cmd: $@ =========="
91+
cd /go/src/github.com/hyperhq/hypercli/integration-cli && eval $@
92+
if [[ "$@" == "./build.sh" ]];then
93+
#show make result
94+
if [[ $? -eq 0 ]];then
95+
echo "OK:)"
96+
else
97+
echo "Failed:("
98+
fi
99+
fi
100+
fi

integration-cli/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.log
2+
*.bak
3+

integration-cli/EXTRA_TEST.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Extra Test Case for hyper cli
2+
=============================
3+
4+
5+
# auth test
6+
7+
> filename: `cli_ex_auth_test.go`
8+
9+
## test case 1: different clock between hyper client and apirouter server
10+
11+
```
12+
1) difftime < 5min : valid request
13+
2) difftime >= 5min : invalid request, should return `Unauthorized, illegal timestamp`
14+
```
15+
16+
# config test
17+
```
18+
//TODO
19+
```
20+
21+
# fip test
22+
```
23+
//TODO
24+
```
25+
26+
# snapshot test
27+
```
28+
//TODO
29+
```

0 commit comments

Comments
 (0)