From 00f69eb327a0ab49ec6488c26d89229e1bb8dca8 Mon Sep 17 00:00:00 2001 From: yhua Date: Tue, 7 Jun 2016 12:19:48 +0800 Subject: [PATCH 1/4] automation testing --- .travis.yml | 63 ++++++++-- tests/apitests/.harborAPISearch_test.go.swp | Bin 0 -> 12288 bytes tests/apitests/apilib/.harborapi.go.swp | Bin 0 -> 12288 bytes tests/apitests/apilib/accesslog.go | 23 ++++ tests/apitests/apilib/harborapi.go | 113 ++++++++++++++++++ tests/apitests/apilib/harborlogout.go | 15 +++ tests/apitests/apilib/harlogin.go | 28 +++++ tests/apitests/apilib/project.go | 15 +++ tests/apitests/apilib/projecttemp4search.go | 9 ++ tests/apitests/apilib/repository.go | 16 +++ .../apitests/apilib/repositorytemp4search.go | 9 ++ tests/apitests/apilib/role.go | 7 ++ tests/apitests/apilib/roleparam.go | 6 + tests/apitests/apilib/search.go | 8 ++ tests/apitests/apilib/user.go | 11 ++ tests/apitests/hbapiaddprj_test.go | 95 +++++++++++++++ tests/apitests/hbapisearch_test.go | 31 +++++ tests/hostcfg.sh | 4 + tests/startuptest.go | 36 ++++++ tests/testprepare.sh | 11 ++ tests/userlogintest.go | 55 +++++++++ 21 files changed, 548 insertions(+), 7 deletions(-) create mode 100644 tests/apitests/.harborAPISearch_test.go.swp create mode 100644 tests/apitests/apilib/.harborapi.go.swp create mode 100644 tests/apitests/apilib/accesslog.go create mode 100644 tests/apitests/apilib/harborapi.go create mode 100644 tests/apitests/apilib/harborlogout.go create mode 100644 tests/apitests/apilib/harlogin.go create mode 100644 tests/apitests/apilib/project.go create mode 100644 tests/apitests/apilib/projecttemp4search.go create mode 100644 tests/apitests/apilib/repository.go create mode 100644 tests/apitests/apilib/repositorytemp4search.go create mode 100644 tests/apitests/apilib/role.go create mode 100644 tests/apitests/apilib/roleparam.go create mode 100644 tests/apitests/apilib/search.go create mode 100644 tests/apitests/apilib/user.go create mode 100644 tests/apitests/hbapiaddprj_test.go create mode 100644 tests/apitests/hbapisearch_test.go create mode 100755 tests/hostcfg.sh create mode 100644 tests/startuptest.go create mode 100755 tests/testprepare.sh create mode 100644 tests/userlogintest.go diff --git a/.travis.yml b/.travis.yml index aff9e1f81..9037e46ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo: true + language: go go: @@ -5,10 +7,32 @@ go: go_import_path: github.com/vmware/harbor -service: - - mysql +services: + - docker + - mysql -env: DB_HOST=127.0.0.1 DB_PORT=3306 DB_USR=root DB_PWD= +dist: trusty +addons: + apt: + packages: + - mysql-server-5.6 + - mysql-client-core-5.6 + - mysql-client-5.6 + +env: + DB_HOST: 127.0.0.1 + DB_PORT: 3306 + DB_USR: root + DB_PWD: + DOCKER_COMPOSE_VERSION: 1.7.1 + HARBOR_ADMIN: admin + HARBOR_ADMIN_PASSWD: Harbor12345 + +before_install: + - ./tests/hostcfg.sh + - cd Deploy + - ./prepare + - cd .. install: - sudo apt-get update && sudo apt-get install -y libldap2-dev @@ -17,12 +41,37 @@ install: - go get -d github.com/go-sql-driver/mysql - go get github.com/golang/lint/golint - go get github.com/GeertJohan/fgt - + - sudo apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" docker-engine=1.11.1-0~trusty + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + - go get github.com/dghubble/sling + - go get github.com/stretchr/testify + - go get github.com/yhua123/harbor/tests/apitests/apilib + before_script: # create tables and load data - mysql < ./Deploy/db/registry.sql -uroot --verbose script: - - go list ./... | grep -v /vendor/ | xargs -L1 fgt golint - - go list ./... | grep -v 'vendor' | xargs -L1 go vet - - go list ./... | grep -v 'vendor' | xargs -L1 go test -v + - go list ./... | grep -v 'tests' | grep -v /vendor/ | xargs -L1 fgt golint + - go list ./... | grep -v 'tests' | grep -v 'vendor' | xargs -L1 go vet + - go list ./... | grep -v 'tests' | grep -v 'vendor' | xargs -L1 go test -v + + - docker-compose -f Deploy/docker-compose.yml up -d + + - docker ps + - docker version + - docker-compose version + - go run tests/startuptest.go http://localhost/ + - go run tests/userlogintest.go -name ${HARBOR_ADMIN} -passwd ${HARBOR_ADMIN_PASSWD} + + + # test for API + - #IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'` + - #echo $IP + - #docker login -u admin -p Harbor12345 $IP:80 + - #./tests/testprepare.sh + - docker ps + - go test -v ./tests/apitests diff --git a/tests/apitests/.harborAPISearch_test.go.swp b/tests/apitests/.harborAPISearch_test.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..3a572392e5b6ec198dd9141a659562032f96646e GIT binary patch literal 12288 zcmeI2L2uJA6vsVIR4_p74qgxw97$M%;Ixd_$r7VnOUbV_d5iw69FQyH-TJ-jSG`(w&gXA(J5=1 zPaVIrw>_;80U|&IhyW2F0z`la5CJ0a-x1L11lvMZ2dd0YR{g}TzWSt&2oM1xKm>>Y z5g-CYfCvx)B0vO)01@~H3HUw6rVlgr8Y=$(U*+)aC}UrtFVIKm74#BHpj9Y_+R!58 zLJm}ez8_)i9rOZv2DPEfPz(Ar$=DWj0y+d8ggztgd+06n1~TXP08t|XM1Tko0U|&I zhyW2F0z`laj0tSw_lE0knm;w|+>m`+iOkOv?c5ewDuUt67yVGu*K|(@N+d kDr@NDaO9SUf|cu9KxeUdkV>Vw%~Jv}`hQ#P$SYzEn-`f^2)kcK2CQ>8iNvSnf0`qp~^=-RvXFEGv zc+^HbfHw(8H5yNP5&y)ChJ=GiVxlG{CLV|}F&;D#FC0v~`JJ8J*T1xQgzQT`?C$K$ zZ)U#po8NC5w$}a9&>`Ae*-P--Lde;TqhnW36Y|q`LZlE%7q9h;_|)#QsMmd$m!DFN za!+@;r>D2v)7xF%{X}ZmSa2Gm$(>dsVa`z=tGx%AtO@BT+{X@!{Ps=Y*PKTB5~Y<1 zvDN^J_k{w50;?;K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)-`OcdDkkQ&jW4>zOY?bC~J8zpQ)=77^>*)=>tS?IstIu%);j*BC Date: Tue, 7 Jun 2016 12:27:21 +0800 Subject: [PATCH 2/4] automation testing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9037e46ce..979f7dd06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,7 @@ script: # test for API - #IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'` - #echo $IP - - #docker login -u admin -p Harbor12345 $IP:80 + - #docker login -u admin -p Harbor12345 $IP - #./tests/testprepare.sh - docker ps - go test -v ./tests/apitests From 12e15de42eb6fc7ccf1ed38236ef052e87e87102 Mon Sep 17 00:00:00 2001 From: yhua Date: Tue, 7 Jun 2016 13:28:51 +0800 Subject: [PATCH 3/4] change docker status --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 979f7dd06..ae4a4507b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ before_install: - cd Deploy - ./prepare - cd .. + - cat /etc/default/docker install: - sudo apt-get update && sudo apt-get install -y libldap2-dev From 202a2a91c5c0a666306d6d682181cf489c80c067 Mon Sep 17 00:00:00 2001 From: yhua Date: Tue, 7 Jun 2016 13:41:27 +0800 Subject: [PATCH 4/4] remove cat --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ae4a4507b..979f7dd06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,6 @@ before_install: - cd Deploy - ./prepare - cd .. - - cat /etc/default/docker install: - sudo apt-get update && sudo apt-get install -y libldap2-dev