Skip to content

Commit

Permalink
OCDEV e2e tests
Browse files Browse the repository at this point in the history
* Pushing this to get some initial feedback on the structure \
  of the test cases.

* The tests are writting using ginkgo so that it is easier to \
  manage the tests going forward

* We aren't adhering to the standard requirements of BDD, but \
  mapping usecases in ginkgo seems covenient

* For starters, we have picked up Usecase redhat-developer#5
  • Loading branch information
ashetty1 committed Mar 20, 2018
1 parent d54a264 commit fbffe5e
Show file tree
Hide file tree
Showing 216 changed files with 191,870 additions and 51 deletions.
115 changes: 65 additions & 50 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ jobs:
- make validate
- make test-coverage
after_success:
# submit coverage.txt to codecov.io
# submit coverage.txt to codecov.io
- bash <(curl -s https://codecov.io/bash)


- <<: *base-test
stage: test
go: 1.9
script:
- ./scripts/oc-cluster.sh
- make bin
- sudo cp ocdev /usr/bin
- oc login -u system:admin
- go get -u github.com/onsi/ginkgo/ginkgo
- echo $PATH
#- cd tests/e2e
- make test-e2e

# test installation script on linux
- stage: test
services:
Expand All @@ -47,52 +61,53 @@ jobs:
script:
./scripts/install.sh

- stage: deploy
go_import_path: github.com/redhat-developer/ocdev
go: 1.9
install:
- make goget-tools
- gem install fpm
- sudo apt-get -qq update
- sudo apt-get install -y rpm
# Ideally following commands should be in before_deploy section
# but travis-ci runs before_deploy for every provider. We don't want that.
- make prepare-release
- ./scripts/generate-bintray-json.sh
- make packages
script: skip
deploy:
# upload binaries to bintray
- provider: bintray
repo: ocdev/ocdev
file: ./.bintray.json
user: $BINTRAY_USER
key: $BINTRAY_KEY
skip_cleanup: true
on:
on: master
# upload gziped binaries to github release page
- provider: releases
api_key:
secure: GGP7Kk+ZjhwwOTOgY4/TufeZ82Xh6SQDJkUlig6qzOCd01Rh80waWz5X0MzNgf2UotjeiVpgFbhZ3DOeUDwkRxa+/MmmiX+gxgeS+tb5YnhnFzH0Q/13DYFF+RQQrr8jmFs7d4dm56L3U3gW4qFwyHgn9Fy5Aqsd4R4RmObV4sVtxh1Z4g4px1hJNiaKFd7T9ChFPS/fuSz75ThrSQjG4rJFWW5Sb6BPmEOkwMCGAc+b24oEZngq8HMDknuKLU1UTSOef9T9yo65M4uVVMI1RkmbmazObkd6216L7XlIvZrLhINIy3Jl7RCtT2JLgKEmHQ9582WIenRIm4PerlMn6sDHmfb+oYW2JMXhgYEOBzXk0K/RmiRGc8tCpSfEpB5qe6z28+l8SvirX9plBqZytG0EwXUVEt7qwSOlLtfrT/4tJCVpmmXDoJR/TtDrHe2HqsBTBQJpYDrOemqmEAcDDMFVG+yZq4iO+Z1jTdEqUMXUE+0UYl22//Y3+xGzvS+JEIzwU/VI2Sg+zDlTvkogQBl7IQqNl/ttXgLcRl0V/E2PpJR/gJUlEyYImKI3Gh4pV5cY7IRuT17fytp249KyK/q3mkE85/yKWPZc/fGVgqbqL7pdHTuVg/woDv46kK1VFC2lDB9Ll5yWrMGI6U/kxO8bzPa88PE0Z4i4yMoRRLo=
draft: true
prerelease: true
file_glob: true
file: "./dist/release/*"
skip_cleanup: true
on:
tags: true
repo: redhat-developer/ocdev
# upload packages to bintray repositories
- provider: script
skip_cleanup: true
script:
- make upload-packages
on:
tags: true
- provider: script
skip_cleanup: true
script:
- make upload-packages
on:
branch: master

# - stage: deploy
# go_import_path: github.com/redhat-developer/ocdev
# go: 1.9
# install:
# - make goget-tools
# - gem install fpm
# - sudo apt-get -qq update
# - sudo apt-get install -y rpm
# # Ideally following commands should be in before_deploy section
# # but travis-ci runs before_deploy for every provider. We don't want that.
# - make prepare-release
# - ./scripts/generate-bintray-json.sh
# - make packages
# script: skip
# deploy:
# # upload binaries to bintray
# - provider: bintray
# repo: ocdev/ocdev
# file: ./.bintray.json
# user: $BINTRAY_USER
# key: $BINTRAY_KEY
# skip_cleanup: true
# on:
# on: master
# # upload gziped binaries to github release page
# - provider: releases
# api_key:
# secure: GGP7Kk+ZjhwwOTOgY4/TufeZ82Xh6SQDJkUlig6qzOCd01Rh80waWz5X0MzNgf2UotjeiVpgFbhZ3DOeUDwkRxa+/MmmiX+gxgeS+tb5YnhnFzH0Q/13DYFF+RQQrr8jmFs7d4dm56L3U3gW4qFwyHgn9Fy5Aqsd4R4RmObV4sVtxh1Z4g4px1hJNiaKFd7T9ChFPS/fuSz75ThrSQjG4rJFWW5Sb6BPmEOkwMCGAc+b24oEZngq8HMDknuKLU1UTSOef9T9yo65M4uVVMI1RkmbmazObkd6216L7XlIvZrLhINIy3Jl7RCtT2JLgKEmHQ9582WIenRIm4PerlMn6sDHmfb+oYW2JMXhgYEOBzXk0K/RmiRGc8tCpSfEpB5qe6z28+l8SvirX9plBqZytG0EwXUVEt7qwSOlLtfrT/4tJCVpmmXDoJR/TtDrHe2HqsBTBQJpYDrOemqmEAcDDMFVG+yZq4iO+Z1jTdEqUMXUE+0UYl22//Y3+xGzvS+JEIzwU/VI2Sg+zDlTvkogQBl7IQqNl/ttXgLcRl0V/E2PpJR/gJUlEyYImKI3Gh4pV5cY7IRuT17fytp249KyK/q3mkE85/yKWPZc/fGVgqbqL7pdHTuVg/woDv46kK1VFC2lDB9Ll5yWrMGI6U/kxO8bzPa88PE0Z4i4yMoRRLo=
# draft: true
# prerelease: true
# file_glob: true
# file: "./dist/release/*"
# skip_cleanup: true
# on:
# tags: true
# repo: redhat-developer/ocdev
# # upload packages to bintray repositories
# - provider: script
# skip_cleanup: true
# script:
# - make upload-packages
# on:
# tags: true
# - provider: script
# skip_cleanup: true
# script:
# - make upload-packages
# on:
# branch: master
80 changes: 79 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ prepare-release: cross
test:
go test -race $(PKGS)


.PHONY: test-e2e
test-e2e:
go test -v github.com/redhat-developer/ocdev/tests/e2e

# create deb and rpm packages using fpm in ./dist/pkgs/
# run make cross before this!
.PHONY: packages
Expand Down
68 changes: 68 additions & 0 deletions scripts/oc-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh

# Config
# oc_bin_source='https://github.com/openshift/origin/releases/download/v3.7.2/openshift-origin-client-tools-v3.7.2-282e43f-linux-64bit.tar.gz'

# wget $oc_bin_source -O /tmp/oc.tar.gz 2> /dev/null > /dev/null
# mkdir /tmp/ocdir && cd /tmp/ocdir && tar -xvvf /tmp/oc.tar.gz > /dev/null
# sudo mv /tmp/ocdir/*/oc /usr/bin/

sudo service docker stop

sudo sed -i -e 's/sock/sock --insecure-registry 172.30.0.0\/16/' /etc/default/docker
sudo cat /etc/default/docker

sudo service docker start
sudo service docker status

## chmod needs sudo, so all other commands are with sudo
sudo mkdir -p /home/travis/gopath/origin
sudo chmod -R 766 /home/travis/gopath/origin

## download oc binary
sudo wget https://github.com/openshift/origin/releases/download/v3.7.2/openshift-origin-client-tools-v3.7.2-282e43f-linux-64bit.tar.gz -O /home/travis/gopath/origin/openshift-origin-client-tools.tar.gz 2> /dev/null > /dev/null

sudo wget https://github.com/openshift/origin/releases/download/v3.7.2/openshift-origin-server-v3.7.2-282e43f-linux-64bit.tar.gz -O /home/travis/gopath/origin/openshift-origin-server.tar.gz 2> /dev/null > /dev/null

sudo ls -l /home/travis/gopath/origin

sudo tar -xvzf /home/travis/gopath/origin/openshift-origin-client-tools.tar.gz --strip-components=1 -C /bin

sudo tar -xvzf /home/travis/gopath/origin/openshift-origin-server.tar.gz --strip-components=1 -C /bin

export PATH=$PATH:/home/travis/gopath/origin/



#sudo mount --make-shared /
#sudo wget https://github.com/openshift/origin/releases/download/v3.7.2/openshift-origin-server-v3.7.2-282e43f-linux-64bit.tar.gz -O /tmp/openshift-origin-server.tar.gz

#sudo tar -xvzf /tmp/openshift-origin-server.tar.gz --strip-components=1 -C /bin
#sudo ls -l /bin
oc version

# below cmd is important to get oc working in ubuntu
sudo docker run -v /:/rootfs -ti --rm --entrypoint=/bin/bash --privileged openshift/origin:v3.7.2 -c "mv /rootfs/bin/findmnt /rootfs/bin/findmnt.backup"

#sudo mount --make-shared /

built=false
while true; do
oc cluster up
if [ "$?" -eq 0 ]; then
./scripts/travis-check-pods.sh
if [ "$?" -eq 0 ]; then
built=true
break
fi
fi
echo "Retrying oc cluster up after failure"
oc cluster down
sleep 5
done

#oc cluster status

if [ "$built" == false ]; then
exit 1
fi
75 changes: 75 additions & 0 deletions scripts/travis-check-pods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

oc login -u system:admin
oc project default

while true; do
V=$(oc get dc docker-registry --template='{{index .status "latestVersion"}}')
P=$(oc get pod docker-registry-$V-deploy --template='{{index .status "phase"}}')
if [ "$?" -eq 0 ]; then
echo phase is $P for docker-registry deploy $V
if [ "$P" == "Failed" ]; then
echo "registry deploy failed, try again"
oc get pods
oc rollout retry dc/docker-registry
sleep 10
continue
fi
fi
REG=$(oc get pod -l deploymentconfig=docker-registry --template='{{index .items 0 "status" "phase"}}')
if [ "$?" -eq 0 ]; then
break
fi
oc get pods
echo "Waiting for registry pod"
sleep 10
done

while true; do
REG=$(oc get pod -l deploymentconfig=docker-registry --template='{{index .items 0 "status" "phase"}}')
if [ "$?" -ne 0 -o "$REG" == "Error" ]; then
echo "Registy pod is in error state..."
exit 1
fi
if [ "$REG" == "Running" ]; then
break
fi
sleep 5
done

while true; do
V=$(oc get dc router --template='{{index .status "latestVersion"}}')
P=$(oc get pod router-$V-deploy --template='{{index .status "phase"}}')
if [ "$?" -eq 0 ]; then
echo phase is $P for router deploy $V
if [ "$P" == "Failed" ]; then
echo "router deploy failed, try again"
oc get pods
oc rollout retry dc/router
sleep 10
continue
fi
fi
REG=$(oc get pod -l deploymentconfig=router --template='{{index .items 0 "status" "phase"}}')
if [ "$?" -eq 0 ]; then
break
fi
oc get pods
echo "Waiting for router pod"
sleep 10
done


while true; do
REG=$(oc get pod -l deploymentconfig=router --template='{{index .items 0 "status" "phase"}}')
if [ "$?" -ne 0 -o "$REG" == "Error" ]; then
echo "Router pod is in error state..."
exit 1
fi
if [ "$REG" == "Running" ]; then
break
fi
sleep 5
done

echo "Registry and router pods are okay"
Loading

0 comments on commit fbffe5e

Please sign in to comment.