Skip to content

Commit

Permalink
relax gitignore for things within our repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elliot Schlegelmilch committed Jun 21, 2017
0 parents commit 66741ff
Show file tree
Hide file tree
Showing 324 changed files with 42,974 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node-helpers
virtual-machine
deploytest
.DS_Store
*.retry
startVagrant.sh
minishift
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Place your settings in this file to overwrite default and user settings.
{
"javascript.validate.enable": false
}
83 changes: 83 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
node {
def docker_compose = "docker run -t --rm -v \$WORKSPACE:\$WORKSPACE -v /var/run/docker.sock:/var/run/docker.sock -w \$WORKSPACE docker/compose:1.13.0 -p lagoon"


deleteDir()

stage ('Checkout') {
checkout scm
}

lock('minishift') {
try {
ansiColor('xterm') {
stage ('checkout services') {
sshagent (credentials: ['lagoon-ci']) {
sh "./initGit.sh"
}
}

parallel (
'start services': {
stage ('start services') {
sh "${docker_compose} up -d --force"
}
},
'start openshift': {
stage ('start openshift') {
sh './startOpenShift.sh'
}
}
)


parallel (
'_tests': {
stage ('run tests') {
sh "${docker_compose} exec tests ansible-playbook /ansible/playbooks/node.yaml"
cleanup(docker_compose)
}
},
'webhook-handler logs': {
stage ('webhook-handler') {
sh "${docker_compose} logs -f webhook-handler"
}
},
'webhooks2tasks logs': {
stage ('webhooks2tasks') {
sh "${docker_compose} logs -f webhooks2tasks"
}
},
'openshiftdeploy logs': {
stage ('openshiftdeploy') {
sh "${docker_compose} logs -f openshiftdeploy"
}
},
'openshiftremove logs': {
stage ('openshiftremove') {
sh "${docker_compose} logs -f openshiftremove"
}
},
'all logs': {
stage ('all') {
sh "${docker_compose} logs -f "
}
}
)
}
} catch (e) {
echo "Something went wrong, trying to cleanup"
cleanup(docker_compose)
throw e
}
}
}

def cleanup(docker_compose) {
try {
sh "${docker_compose} down -v"
sh "./minishift/minishift delete"
} catch (error) {
echo "cleanup failed, ignoring this."
}
}
16 changes: 16 additions & 0 deletions Jenkinsfile.testing-develop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node {

def docker_compose = "docker run -t --rm -v \$WORKSPACE:\$WORKSPACE -v /var/run/docker.sock:/var/run/docker.sock -w \$WORKSPACE docker/compose:1.13.0"


stage ('Checkout') {
checkout scm
}

ansiColor('xterm') {
stage ('run test') {
sh "${docker_compose} -f tests/docker-compose.yaml run --rm tests-develop ansible-playbook /ansible/playbooks/node.yaml"
}
}

}
16 changes: 16 additions & 0 deletions Jenkinsfile.testing-master
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node {

def docker_compose = "docker run -t --rm -v \$WORKSPACE:\$WORKSPACE -v /var/run/docker.sock:/var/run/docker.sock -w \$WORKSPACE docker/compose:1.13.0"


stage ('Checkout') {
checkout scm
}

ansiColor('xterm') {
stage ('run test') {
sh "${docker-compose} -f tests/docker-compose.yaml run --rm tests-master ansible-playbook /ansible/playbooks/node.yaml"
}
}

}
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# amazee.io Lagoon - where the cool microservices hang out!

The amazee.io lagoon is the amazee.io deployment system, completely independent from any servers running. Perfect for local development, testing new features and taking over the world.

- Schema: [https://www.lucidchart.com/documents/edit/a3cf0c4f-1bc1-438f-977d-4b26f235ceac](https://www.lucidchart.com/documents/edit/a3cf0c4f-1bc1-438f-977d-4b26f235ceac)
- Workshop Videos: [https://drive.google.com/drive/u/0/folders/0B7z7DpdobBRcY2pnS2FUVTNIVzg](https://drive.google.com/drive/u/0/folders/0B7z7DpdobBRcY2pnS2FUVTNIVzg)

Please take into account that currently, multi-stage dockerfiles only work with [Docker CE Edge](https://docs.docker.com/edge/).

## Start Services

1. clone me
1. init git

./initGit.sh

1. start Lagoon Services

docker-compose up -d

1. Follow the Services logs

docker-compose logs -f

## Start & Test OpenShift

1. start OpenShift

./startOpenShift.sh

1. test Openshift Node Deployment

docker-compose exec tests ansible-playbook /ansible/playbooks/node.yaml
57 changes: 57 additions & 0 deletions TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# amazee.io Lagoon testing

Our tests are all written with Ansible and mostly follow this approach:

1. They create a new git repository
2. Add and commit some files from a list of files (in `tests/files`) into this git repo
3. Push this git repo into a git server (either locally or on Github)
4. Send a Webhook to the Webhook Handler which is the same as a real webhook that would be sent
5. Starts to monitor the URL that the test would expect something to happen (like deploying a nodejs app that has the git branch as an HTML text)
6. Compares the result on the URL with the expected result

Lagoon is mostly tested in 3 different ways:

## 1. Locally

During local development the best and easiest is to test locally. For that you need all microservices running `docker-compose up -d` and the MiniShift OpenShift running as well: `./startOpenShift.sh`.

Now you can run tests, via ansible:

docker-compose exec tests ansible-playbook /ansible/playbooks/node.yaml

This would run all tests defined in `tests/playbooks/node.yaml`. If you like only to run a subset of the tests, it's best to shortly comment out the tests in these files you don't like to run.

Sometimes you just would like to create another push webhook, without to wait for the git repo to be initialized and beeing pushed. For this case there is a small helper script `tests/playbooks/helpers/just-push.yaml` that will get the current head of the git repo and push a webhook push. It needs to know which git repo you would like to check and push:

docker-compose exec tests ansible-playbook /ansible/playbooks/helpers/just-push.yaml -e git_repo_name=node.git

In order to actually see what is happening inside the microservices, we can use `docker-compose logs`:

docker-compose logs -f

Or only for a specific service:

docker-compose logs -f webhook-handler

Sometimes you would like to see what is happening inside the Jenkins, it can be found here: http://localhost:8888/ (`admin`:`admin`)

## 2. Automated integration testing

In order to test branches and pull requests. There is an full automatic integration test running on Jenkins. It is defined inside the `Jenkinsfile` and runs automatically for every pull request that is opened.

This Jenkins Job will start a minishift and all services inside the Jenkins and run all tests against it.


## 3. Real World Testing

To make sure that our services also work in the real work (eg deployed on OpenShift with real URLs, real git repos and stuff), we also have tests for this. Currently we only deploy the `develop` and `master` branches to a real OpenShift infrastructure.

For these tests we use the exact same ansible scripts like the local or the automated testing, we just push to an actual Github Repo https://github.com/amazeeio-ci-testing and send webhooks to the webhook-handler that are running OpenShift.

The tests are defined in `Jenkinsfile.testing-develop` and `Jenkinsfile.testing-master`. They get their testing infrastructure (endpoints, etc.) from a docker-compose.yaml file within the `tests` folder.

Beside of that it's exactly the same.

The tests can be found here:
- `develop` branch: https://lagoon-ci.amazeeio.cloud/job/lagoon-test-develop/
- `master` branch: https://lagoon-ci.amazeeio.cloud/job/lagoon-test-master/
Loading

0 comments on commit 66741ff

Please sign in to comment.