Continous integration through Travis CI (#71)
* Adding Travis CI badge * Modifying end to end tests to reflect testing against docker-compose setup in Travis CI. * Adding bash script to run simple container with tests within bridge network for Mac. * Adding documentation for setting up a developer environment. * Decreasing amount of CPU needed for CreateJobWithPulse because a higher value causes Travis CI to hang.
This commit is contained in:
parent
0e4a0d726b
commit
1c2b1c5079
6 changed files with 198 additions and 8 deletions
15
.travis.yml
Normal file
15
.travis.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- "1.10.x"
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
install:
|
||||||
|
- docker-compose up -d
|
||||||
|
|
||||||
|
script:
|
||||||
|
- go test -v github.com/paypal/gorealis
|
|
@ -1,4 +1,4 @@
|
||||||
# gorealis [](https://godoc.org/github.com/paypal/gorealis)
|
# gorealis [](https://godoc.org/github.com/paypal/gorealis) [](https://travis-ci.org/paypal/gorealis)
|
||||||
|
|
||||||
Go library for interacting with [Apache Aurora](https://github.com/apache/aurora).
|
Go library for interacting with [Apache Aurora](https://github.com/apache/aurora).
|
||||||
|
|
||||||
|
|
81
docker-compose.yml
Normal file
81
docker-compose.yml
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
zk:
|
||||||
|
image: rdelvalle/zookeeper
|
||||||
|
restart: on-failure
|
||||||
|
ports:
|
||||||
|
- "2181:2181"
|
||||||
|
environment:
|
||||||
|
ZK_CONFIG: tickTime=2000,initLimit=10,syncLimit=5,maxClientCnxns=128,forceSync=no,clientPort=2181
|
||||||
|
ZK_ID: 1
|
||||||
|
networks:
|
||||||
|
aurora_cluster:
|
||||||
|
ipv4_address: 192.168.33.2
|
||||||
|
|
||||||
|
master:
|
||||||
|
image: mesosphere/mesos-master:1.5.0
|
||||||
|
restart: on-failure
|
||||||
|
ports:
|
||||||
|
- "5050:5050"
|
||||||
|
environment:
|
||||||
|
MESOS_ZK: zk://192.168.33.2:2181/mesos
|
||||||
|
MESOS_QUORUM: 1
|
||||||
|
MESOS_HOSTNAME: localhost
|
||||||
|
MESOS_CLUSTER: test-cluster
|
||||||
|
MESOS_REGISTRY: replicated_log
|
||||||
|
networks:
|
||||||
|
aurora_cluster:
|
||||||
|
ipv4_address: 192.168.33.3
|
||||||
|
depends_on:
|
||||||
|
- zk
|
||||||
|
|
||||||
|
agent-one:
|
||||||
|
image: rdelvalle/mesos-agent:1.5.0
|
||||||
|
pid: host
|
||||||
|
restart: on-failure
|
||||||
|
ports:
|
||||||
|
- "5051:5051"
|
||||||
|
environment:
|
||||||
|
MESOS_MASTER: zk://192.168.33.2:2181/mesos
|
||||||
|
MESOS_CONTAINERIZERS: docker,mesos
|
||||||
|
MESOS_PORT: 5051
|
||||||
|
MESOS_HOSTNAME: localhost
|
||||||
|
MESOS_RESOURCES: ports(*):[11000-11999]
|
||||||
|
MESOS_SYSTEMD_ENABLE_SUPPORT: 'false'
|
||||||
|
MESOS_WORK_DIR: /tmp/mesos
|
||||||
|
networks:
|
||||||
|
aurora_cluster:
|
||||||
|
ipv4_address: 192.168.33.4
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
depends_on:
|
||||||
|
- zk
|
||||||
|
|
||||||
|
aurora-one:
|
||||||
|
image: rdelvalle/aurora:0.20.0
|
||||||
|
pid: host
|
||||||
|
ports:
|
||||||
|
- "8081:8081"
|
||||||
|
restart: on-failure
|
||||||
|
environment:
|
||||||
|
CLUSTER_NAME: test-cluster
|
||||||
|
ZK_ENDPOINTS: "192.168.33.2:2181"
|
||||||
|
MESOS_MASTER: "zk://192.168.33.2:2181/mesos"
|
||||||
|
networks:
|
||||||
|
aurora_cluster:
|
||||||
|
ipv4_address: 192.168.33.7
|
||||||
|
depends_on:
|
||||||
|
- zk
|
||||||
|
- master
|
||||||
|
- agent-one
|
||||||
|
|
||||||
|
networks:
|
||||||
|
aurora_cluster:
|
||||||
|
driver: bridge
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: 192.168.33.0/16
|
||||||
|
gateway: 192.168.33.1
|
90
docs/developing.md
Normal file
90
docs/developing.md
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
# Developing gorealis
|
||||||
|
|
||||||
|
|
||||||
|
### Installing Docker
|
||||||
|
|
||||||
|
For our developer environment we leverage of Docker containers.
|
||||||
|
|
||||||
|
First you must have Docker installed. Instructions on how to install Docker
|
||||||
|
vary from platform to platform and can be found [here](https://docs.docker.com/install/).
|
||||||
|
|
||||||
|
### Installing docker-compose
|
||||||
|
|
||||||
|
To make the creation of our developer environment as simple as possible, we leverage
|
||||||
|
docker-compose to bring up all independent components up separately.
|
||||||
|
|
||||||
|
This also allows us to delete and recreate our development cluster very quickly.
|
||||||
|
|
||||||
|
To install docker-compose please follow the instructions for your platform
|
||||||
|
[here](https://docs.docker.com/compose/install/).
|
||||||
|
|
||||||
|
|
||||||
|
### Getting the source code
|
||||||
|
|
||||||
|
As of go 1.10.x, GOPATH is still relevant. This may change in the future but
|
||||||
|
for the sake of making development less error prone, it is suggested that the following
|
||||||
|
directories be created:
|
||||||
|
|
||||||
|
`$ mkdir -p $GOPATH/src/github.com/paypal`
|
||||||
|
|
||||||
|
And then clone the master branch into the newly created folder:
|
||||||
|
|
||||||
|
`$ cd $GOPATH/src/github.com/paypal; git clone git@github.com:paypal/gorealis.git`
|
||||||
|
|
||||||
|
Since we check in our vendor folder, gorealis no further set up is needed.
|
||||||
|
|
||||||
|
### Bringing up the cluster
|
||||||
|
|
||||||
|
To develop gorealis, you will need a fully functioning Mesos cluster along with
|
||||||
|
Apache Aurora.
|
||||||
|
|
||||||
|
In order to bring up our docker-compose set up execute the following command from the root
|
||||||
|
of the git repository:
|
||||||
|
|
||||||
|
`$ docker-compose up -d`
|
||||||
|
|
||||||
|
### Testing code
|
||||||
|
|
||||||
|
Since Docker does not work well using host mode under MacOS, a workaround has been employed:
|
||||||
|
docker-compose brings up a bridged network.
|
||||||
|
|
||||||
|
* The ports 8081 is exposed for Aurora. http://localhost:8081 will load the Aurora Web UI.
|
||||||
|
* The port 5050 is exposed for Mesos. http://localhost:5050 will load the Mesos Web UI.
|
||||||
|
|
||||||
|
#### Note for developers on MacOS:
|
||||||
|
Running the cluster using a bridged network on MacOS has some side effects.
|
||||||
|
Since Aurora exposes it's internal IP location through Zookeeper, gorealis will determine
|
||||||
|
the address to be 192.168.33.7. The address 192.168.33.7 is valid when running in a Linux
|
||||||
|
environment but not when running under MacOS. To run code involving the ZK leader fetcher
|
||||||
|
(such as the tests), a container connected to the network needs to be launched.
|
||||||
|
|
||||||
|
For example, running the tests in a container can be done through the following command from
|
||||||
|
the root of the git repository:
|
||||||
|
|
||||||
|
`$ docker run -t -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine go test github.com/paypal/gorealis`
|
||||||
|
|
||||||
|
Or
|
||||||
|
|
||||||
|
`$ ./runTestsMac.sh`
|
||||||
|
|
||||||
|
Alternatively, if an interactive shell is necessary, the following command may be used:
|
||||||
|
`$ docker run -it -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine /bin/sh`
|
||||||
|
|
||||||
|
### Cleaning up the cluster
|
||||||
|
|
||||||
|
If something went wrong while developing and a clean environment is desired, perform the
|
||||||
|
following command from the root of the git directory:
|
||||||
|
|
||||||
|
`$ docker-compose down && docker-compose up -d`
|
||||||
|
|
||||||
|
|
||||||
|
### Tearing down the cluster
|
||||||
|
|
||||||
|
Once development is done, the environment may be torn down by executing (from the root of the
|
||||||
|
git directory):
|
||||||
|
|
||||||
|
`$ docker-compose down`
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestNonExistentEndpoint(t *testing.T) {
|
||||||
Jitter: 0.1}
|
Jitter: 0.1}
|
||||||
|
|
||||||
// Attempt to connect to a bad endpoint
|
// Attempt to connect to a bad endpoint
|
||||||
r, err := realis.NewRealisClient(realis.SchedulerUrl("http://127.0.0.1:8081/doesntexist/"),
|
r, err := realis.NewRealisClient(realis.SchedulerUrl("http://192.168.33.7:8081/doesntexist/"),
|
||||||
realis.TimeoutMS(200),
|
realis.TimeoutMS(200),
|
||||||
realis.BackOff(backoff),
|
realis.BackOff(backoff),
|
||||||
)
|
)
|
||||||
|
@ -92,11 +92,11 @@ func TestNonExistentEndpoint(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLeaderFromZK(t *testing.T) {
|
func TestLeaderFromZK(t *testing.T) {
|
||||||
cluster := realis.GetDefaultClusterFromZKUrl("192.168.33.7:2181")
|
cluster := realis.GetDefaultClusterFromZKUrl("192.168.33.2:2181")
|
||||||
url, err := realis.LeaderFromZK(*cluster)
|
url, err := realis.LeaderFromZK(*cluster)
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "http://aurora.local:8081", url)
|
assert.Equal(t, "http://192.168.33.7:8081", url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRealisClient_ReestablishConn(t *testing.T) {
|
func TestRealisClient_ReestablishConn(t *testing.T) {
|
||||||
|
@ -171,7 +171,7 @@ func TestRealisClient_CreateJobWithPulse_Thermos(t *testing.T) {
|
||||||
Name("create_thermos_job_test").
|
Name("create_thermos_job_test").
|
||||||
ExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
ExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
||||||
ExecutorData(string(thermosPayload)).
|
ExecutorData(string(thermosPayload)).
|
||||||
CPU(1).
|
CPU(.5).
|
||||||
RAM(64).
|
RAM(64).
|
||||||
Disk(100).
|
Disk(100).
|
||||||
IsService(true).
|
IsService(true).
|
||||||
|
@ -295,7 +295,7 @@ func TestRealisClient_ScheduleCronJob_Thermos(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRealisClient_DrainHosts(t *testing.T) {
|
func TestRealisClient_DrainHosts(t *testing.T) {
|
||||||
hosts := []string{"192.168.33.7"}
|
hosts := []string{"localhost"}
|
||||||
_, _, err := r.DrainHosts(hosts...)
|
_, _, err := r.DrainHosts(hosts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error: %+v\n", err.Error())
|
fmt.Printf("error: %+v\n", err.Error())
|
||||||
|
@ -308,7 +308,7 @@ func TestRealisClient_DrainHosts(t *testing.T) {
|
||||||
[]aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING},
|
[]aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING},
|
||||||
1,
|
1,
|
||||||
50)
|
50)
|
||||||
assert.Equal(t, map[string]bool{"192.168.33.7": true}, hostResults)
|
assert.Equal(t, map[string]bool{"localhost": true}, hostResults)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
t.Run("TestRealisClient_MonitorNontransitioned", func(t *testing.T) {
|
t.Run("TestRealisClient_MonitorNontransitioned", func(t *testing.T) {
|
||||||
|
@ -321,7 +321,7 @@ func TestRealisClient_DrainHosts(t *testing.T) {
|
||||||
|
|
||||||
// Assert monitor returned an error that was not nil, and also a list of the non-transitioned hosts
|
// Assert monitor returned an error that was not nil, and also a list of the non-transitioned hosts
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Equal(t, map[string]bool{"192.168.33.7": true, "IMAGINARY_HOST": false}, hostResults)
|
assert.Equal(t, map[string]bool{"localhost": true, "IMAGINARY_HOST": false}, hostResults)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("TestRealisClient_EndMaintenance", func(t *testing.T) {
|
t.Run("TestRealisClient_EndMaintenance", func(t *testing.T) {
|
||||||
|
|
4
runTestsMac.sh
Executable file
4
runTestsMac.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Since we run our docker compose setup in bridge mode to be able to run on MacOS, we have to launch a Docker container within the bridge network in order to avoid any routing issues.
|
||||||
|
docker run -t -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-stretch go test -v github.com/paypal/gorealis
|
Loading…
Add table
Add a link
Reference in a new issue