From c4bac306a69a14c30d10016c4dadb6aba690fd62 Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 20:53:54 -0500 Subject: [PATCH 1/6] Change IP address of eureka servers --- tests/config_sample/local.gcfg | 4 ++-- tests/config_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/config_sample/local.gcfg b/tests/config_sample/local.gcfg index ebcd132..a344c4c 100644 --- a/tests/config_sample/local.gcfg +++ b/tests/config_sample/local.gcfg @@ -1,4 +1,4 @@ [Eureka] -ServiceUrls = http://172.16.0.11:8080/eureka/v2 -ServiceUrls = http://172.16.0.22:8080/eureka/v2 +ServiceUrls = http://172.17.0.2:8080/eureka/v2 +ServiceUrls = http://172.17.0.3:8080/eureka/v2 ConnectTimeoutSeconds = 2 diff --git a/tests/config_test.go b/tests/config_test.go index 4fc4940..0c77167 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -30,8 +30,8 @@ func TestConfigs(t *testing.T) { So(conf.Eureka.InTheCloud, ShouldEqual, false) So(conf.Eureka.ConnectTimeoutSeconds, ShouldEqual, 2) Convey("Both test servers should be in the service URL list", func() { - So(conf.Eureka.ServiceUrls, ShouldContain, "http://172.16.0.11:8080/eureka/v2") - So(conf.Eureka.ServiceUrls, ShouldContain, "http://172.16.0.22:8080/eureka/v2") + So(conf.Eureka.ServiceUrls, ShouldContain, "http://172.17.0.2:8080/eureka/v2") + So(conf.Eureka.ServiceUrls, ShouldContain, "http://172.17.0.3:8080/eureka/v2") }) So(conf.Eureka.UseDNSForServiceUrls, ShouldEqual, false) }) From f2201cf3f10bb62e4efb4feb9f73700e4475ee3d Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 20:54:08 -0500 Subject: [PATCH 2/6] Add Dockerfile and config properties --- docker/Dockerfile | 5 +++++ docker/eureka-client-test.properties | 2 ++ docker/eureka-server-test.properties | 3 +++ 3 files changed, 10 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/eureka-client-test.properties create mode 100644 docker/eureka-server-test.properties diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..4d77b6b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM netflixoss/eureka:1.1.147 +MAINTAINER Fargo dev team https://github.com/hudl/fargo + +ADD eureka-client-test.properties /tomcat/webapps/eureka/WEB-INF/classes/eureka-client-test.properties +ADD eureka-server-test.properties /tomcat/webapps/eureka/WEB-INF/classes/eureka-server-test.properties diff --git a/docker/eureka-client-test.properties b/docker/eureka-client-test.properties new file mode 100644 index 0000000..b917597 --- /dev/null +++ b/docker/eureka-client-test.properties @@ -0,0 +1,2 @@ +eureka.serviceUrl.default=http://172.17.0.2:8080/eureka/v2/,http://172.17.0.3:8080/eureka/v2/ +eureka.vipAddress=eureka diff --git a/docker/eureka-server-test.properties b/docker/eureka-server-test.properties new file mode 100644 index 0000000..c7a35be --- /dev/null +++ b/docker/eureka-server-test.properties @@ -0,0 +1,3 @@ +eureka.enableSelfPreservation=false +eureka.numberRegistrySyncRetries=0 +eureka.waitTimeInMsWhenSyncEmpty=0 From 55e893d1d97184a9f6379cc91088c6db27c43a0d Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 20:54:57 -0500 Subject: [PATCH 3/6] Remove old Vagrant setup --- Vagrantfile | 36 ------------------- provision_eureka.sh | 31 ---------------- .../eureka-client-prod.properties | 24 ------------- .../eureka-client-test.properties | 25 ------------- .../eureka-client.properties | 27 -------------- .../eureka-server-prod.properties | 3 -- .../eureka-server-test.properties | 3 -- .../eureka-server.properties | 8 ----- tests/eureka_properties/log4j.properties | 6 ---- 9 files changed, 163 deletions(-) delete mode 100644 Vagrantfile delete mode 100644 provision_eureka.sh delete mode 100644 tests/eureka_properties/eureka-client-prod.properties delete mode 100644 tests/eureka_properties/eureka-client-test.properties delete mode 100644 tests/eureka_properties/eureka-client.properties delete mode 100644 tests/eureka_properties/eureka-server-prod.properties delete mode 100644 tests/eureka_properties/eureka-server-test.properties delete mode 100644 tests/eureka_properties/eureka-server.properties delete mode 100644 tests/eureka_properties/log4j.properties diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 74cf510..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,36 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - config.vm.define "node1", primary: true do |node1| - node1.vm.box = "opscode-f19-64" - node1.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode-fedora-19_provisionerless.box" - #node1.vm.synced_folder "~/code/eureka", "/eureka-repo" - node1.vm.provision :shell, :inline => "hostname 'node1.localdomain'; echo 'node1.localdomain' > /etc/hostname" - node1.vm.provision :shell, :path => "provision_eureka.sh" - node1.vm.network :private_network, ip: "172.16.0.11" - node1.vm.provider :virtualbox do |vb| - vb.gui = false - vb.customize ["modifyvm", :id, "--memory", "2500"] - vb.customize ["modifyvm", :id, "--cpus", "4"] - # This allows symlinks to be created within the /vagrant root directory - vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] - end - end - config.vm.define "node2" do |node2| - node2.vm.box = "opscode-f19-64" - node2.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode-fedora-19_provisionerless.box" - #node2.vm.synced_folder "~/code/eureka", "/eureka-repo" - node2.vm.provision :shell, :inline => "hostname 'node2.localdomain'; echo 'node2.localdomain' > /etc/hostname" - node2.vm.provision :shell, :path => "provision_eureka.sh" - node2.vm.network :private_network, ip: "172.16.0.22" - node2.vm.provider :virtualbox do |vb| - vb.gui = false - vb.customize ["modifyvm", :id, "--memory", "2500"] - vb.customize ["modifyvm", :id, "--cpus", "4"] - # This allows symlinks to be created within the /vagrant root directory - vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] - end - end - -end diff --git a/provision_eureka.sh b/provision_eureka.sh deleted file mode 100644 index 7d5fe37..0000000 --- a/provision_eureka.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -sysctl -w net.ipv6.conf.all.disable_ipv6=1 -# this is for vbox guest additions v 4.3.10, may not be necessary on your machine http://stackoverflow.com/a/22723807 -ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions || true -systemctl stop firewalld.service -systemctl disable firewalld.service -yum install --nogpgcheck -y unzip tomcat tomcat-admin-webapps htop vim - -echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts -echo " - - -" > /etc/tomcat/tomcat-users.xml -chown tomcat:tomcat /etc/tomcat/tomcat-users.xml -chmod 644 /etc/tomcat/tomcat-users.xml - -echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 -172.16.0.11 node1 node1.localdomain -172.16.0.22 node2 node2.localdomain -" > /etc/hosts - -ARTIFACT="https://netflixoss.ci.cloudbees.com/job/eureka-master/lastSuccessfulBuild/artifact/eureka-server/build/libs/eureka-server-1.1.147-SNAPSHOT.war" - -wget -O /var/lib/tomcat/webapps/eureka.zip ${ARTIFACT} -unzip -o -d /var/lib/tomcat/webapps/eureka /var/lib/tomcat/webapps/eureka.zip -cp /vagrant/tests/eureka_properties/*.properties /var/lib/tomcat/webapps/eureka/WEB-INF/classes/ -chown -R tomcat:tomcat /var/lib/tomcat/webapps/eureka -rm -f /var/lib/tomcat/webapps/eureka.zip - -service tomcat restart -chkconfig tomcat on diff --git a/tests/eureka_properties/eureka-client-prod.properties b/tests/eureka_properties/eureka-client-prod.properties deleted file mode 100644 index 8f80b56..0000000 --- a/tests/eureka_properties/eureka-client-prod.properties +++ /dev/null @@ -1,24 +0,0 @@ - -#Availability zones with the format eureka..availabilityZones, -#eureka.us-east-1.availabilityZones=us-east-1c,us-east-1d,us-east-1e - -eureka.us-east-1.availabilityZones=default - -#Service urls for eureka server in each zone -#eureka.serviceUrl.us-east-1c=http://ec2-552-627-568-165.compute-1.amazonaws.com:7001/discovery/v2/,http://ec2-168-101-182-134.compute-1.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-east-1d=http://ec2-552-627-568-170.compute-1.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-east-1e=http://ec2-50-179-285-592.compute-1.amazonaws.com:7001/discovery/v2/ - -eureka.serviceUrl.default=http://172.16.0.11:8080/eureka/v2/,http://172.16.0.22:8080/eureka/v2/ - -#Availability zones and serviceUrls for us-west-1 region -#eureka.us-west-1.availabilityZones=us-west-1a,us-west-1b,us-west-1c -#eureka.serviceUrl.us-west-1a=http://ec2-67-45-89-248.us-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-west-1b=http://ec2-67-45-89-249.us-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-west-1c=http://ec2-67-45-89-250.us-west-1.compute.amazonaws.com:7001/discovery/v2/ - -#Availability zones and serviceUrls for eu-west-1 region -#eureka.eu-west-1.availabilityZones=eu-west-1a,eu-west-1b,eu-west-1c -#eureka.serviceUrl.eu-west-1a=http://ec2-59-78-75-193.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.eu-west-1b=http://ec2-59-78-75-199.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.eu-west-1c=http://ec2-59-78-75-212.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ diff --git a/tests/eureka_properties/eureka-client-test.properties b/tests/eureka_properties/eureka-client-test.properties deleted file mode 100644 index 0f958ee..0000000 --- a/tests/eureka_properties/eureka-client-test.properties +++ /dev/null @@ -1,25 +0,0 @@ - -#Availability zones with the format eureka..availabilityZones, -#eureka.us-east-1.availabilityZones=us-east-1c,us-east-1d,us-east-1e - -eureka.us-east-1.availabilityZones=default - -#Service urls for eureka server in each zone -#eureka.serviceUrl.us-east-1c=http://ec2-552-627-568-165.compute-1.amazonaws.com:7001/discovery/v2/,http://ec2-168-101-182-134.compute-1.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-east-1d=http://ec2-552-627-568-170.compute-1.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-east-1e=http://ec2-50-179-285-592.compute-1.amazonaws.com:7001/discovery/v2/ - -eureka.serviceUrl.defaultZone=http://172.16.0.11:8080/eureka/v2/,http://172.16.0.22:8080/eureka/v2/ -eureka.serviceUrl.default.defaultZone=http://172.16.0.11:8080/eureka/v2/,http://172.16.0.22:8080/eureka/v2/ - -#Availability zones and serviceUrls for us-west-1 region -#eureka.us-west-1.availabilityZones=us-west-1a,us-west-1b,us-west-1c -#eureka.serviceUrl.us-west-1a=http://ec2-67-45-89-248.us-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-west-1b=http://ec2-67-45-89-249.us-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.us-west-1c=http://ec2-67-45-89-250.us-west-1.compute.amazonaws.com:7001/discovery/v2/ - -#Availability zones and serviceUrls for eu-west-1 region -#eureka.eu-west-1.availabilityZones=eu-west-1a,eu-west-1b,eu-west-1c -#eureka.serviceUrl.eu-west-1a=http://ec2-59-78-75-193.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.eu-west-1b=http://ec2-59-78-75-199.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ -#eureka.serviceUrl.eu-west-1c=http://ec2-59-78-75-212.eu-west-1.compute.amazonaws.com:7001/discovery/v2/ diff --git a/tests/eureka_properties/eureka-client.properties b/tests/eureka_properties/eureka-client.properties deleted file mode 100644 index 9d1e86b..0000000 --- a/tests/eureka_properties/eureka-client.properties +++ /dev/null @@ -1,27 +0,0 @@ -##Eureka Client configuration for Eureka Service - -#Properties based configuration for eureka client. The properties specified here is mostly what the users -#need to change. All of these can be specified as a java system property with -D option (eg)-Deureka.region=us-east-1 - - -#Region where eureka is deployed -For AWS specify one of the AWS regions, for other datacenters specify a arbitrary string -#indicating the region.This is normally specified as a -D option (eg) -Deureka.region=us-east-1 -#eureka.region=us-east-1 -eureka.region=default - -#Name of the application to be identified by other services - -eureka.name=eureka - -#Virtual host name by which the clients identifies this service -eureka.vipAddress=eureka.mydomain.net - -#The port where the service will be identified and will be serving requests -eureka.port=8080 - -#For eureka clients running in eureka server, it needs to connect to servers in other zones -eureka.preferSameZone=false - -#Change this if you want to use a DNS based lookup for determining other eureka servers. For example -#of specifying the DNS entries, check the eureka-client-test.properties, eureka-client-prod.properties -eureka.shouldUseDns=false diff --git a/tests/eureka_properties/eureka-server-prod.properties b/tests/eureka_properties/eureka-server-prod.properties deleted file mode 100644 index 45454b3..0000000 --- a/tests/eureka_properties/eureka-server-prod.properties +++ /dev/null @@ -1,3 +0,0 @@ -#AWS access key which has access to EIP binding and looking up autoscaling information -eureka.awsAccessId=[Enter a valid AWS AccessId] -eureka.awsSecretKey=[Enter a valid AWS SecretKey] diff --git a/tests/eureka_properties/eureka-server-test.properties b/tests/eureka_properties/eureka-server-test.properties deleted file mode 100644 index 45454b3..0000000 --- a/tests/eureka_properties/eureka-server-test.properties +++ /dev/null @@ -1,3 +0,0 @@ -#AWS access key which has access to EIP binding and looking up autoscaling information -eureka.awsAccessId=[Enter a valid AWS AccessId] -eureka.awsSecretKey=[Enter a valid AWS SecretKey] diff --git a/tests/eureka_properties/eureka-server.properties b/tests/eureka_properties/eureka-server.properties deleted file mode 100644 index bdbaf33..0000000 --- a/tests/eureka_properties/eureka-server.properties +++ /dev/null @@ -1,8 +0,0 @@ -#Set this only for this sample service without which starting the instance will by default wait for the default of 5 mins -eureka.waitTimeInMsWhenSyncEmpty=0 -eureka.enableSelfPreservation=false - -#AWS access key which has access to EIP binding and looking up autoscaling information -eureka.awsAccessId=ADIIEIFIFPFIKC -eureka.awsSecretKey=dieuilfkfoioljhjhjuTRoIiijc -@next=eureka-${environment}-${region}.properties diff --git a/tests/eureka_properties/log4j.properties b/tests/eureka_properties/log4j.properties deleted file mode 100644 index 05baf95..0000000 --- a/tests/eureka_properties/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootCategory=INFO,stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout=com.netflix.logging.log4jAdapter.NFPatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d %-5p %C:%L [%t] [%M] %m%n -log4j.logger.asyncAppenders=INFO,stdout \ No newline at end of file From 937dd9deab52c2cb66ccd978d2c981957ecb3c68 Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 20:57:20 -0500 Subject: [PATCH 4/6] Save dockerfiles for multiple eureka versions --- docker/{Dockerfile => Dockerfile-v1.1.147} | 0 docker/Dockerfile-v1.3 | 5 +++++ 2 files changed, 5 insertions(+) rename docker/{Dockerfile => Dockerfile-v1.1.147} (100%) create mode 100644 docker/Dockerfile-v1.3 diff --git a/docker/Dockerfile b/docker/Dockerfile-v1.1.147 similarity index 100% rename from docker/Dockerfile rename to docker/Dockerfile-v1.1.147 diff --git a/docker/Dockerfile-v1.3 b/docker/Dockerfile-v1.3 new file mode 100644 index 0000000..01958f6 --- /dev/null +++ b/docker/Dockerfile-v1.3 @@ -0,0 +1,5 @@ +FROM netflixoss/eureka:1.3.1 +MAINTAINER Fargo dev team https://github.com/hudl/fargo + +ADD eureka-client-test.properties /tomcat/webapps/eureka/WEB-INF/classes/eureka-client-test.properties +ADD eureka-server-test.properties /tomcat/webapps/eureka/WEB-INF/classes/eureka-server-test.properties From 05153feb7de7a1c4d4fc77835db09a81693ab35a Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 20:57:56 -0500 Subject: [PATCH 5/6] Don't check hostnames, since docker names hosts after their runtime ID --- tests/net_test.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/net_test.go b/tests/net_test.go index 283e9f2..59def09 100644 --- a/tests/net_test.go +++ b/tests/net_test.go @@ -30,14 +30,8 @@ func TestGetApps(t *testing.T) { Convey("Pull single application", t, func() { a, _ := e.GetApp("EUREKA") So(len(a.Instances), ShouldEqual, 2) - for idx, ins := range a.Instances { - if ins.HostName == "node1.localdomain" { - So(a.Instances[idx].IPAddr, ShouldEqual, "172.16.0.11") - So(a.Instances[idx].HostName, ShouldEqual, "node1.localdomain") - } else { - So(a.Instances[idx].IPAddr, ShouldEqual, "172.16.0.22") - So(a.Instances[idx].HostName, ShouldEqual, "node2.localdomain") - } + for _, ins := range a.Instances { + So(ins.IPAddr, ShouldBeIn, []string{"172.17.0.2", "172.17.0.3"}) } }) } From 2321b58c45d80509b83d1194f3e11c72971da76d Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Sat, 14 Nov 2015 21:10:39 -0500 Subject: [PATCH 6/6] Document using docker for testing --- README.md | 25 ++++++++++++++++--- docker/{Dockerfile-v1.3 => Dockerfile-v1.3.1} | 0 2 files changed, 21 insertions(+), 4 deletions(-) rename docker/{Dockerfile-v1.3 => Dockerfile-v1.3.1} (100%) diff --git a/README.md b/README.md index 8573ba5..241dd84 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,28 @@ included [vagrant](http://vagrantup.com) specs. We're on semver and tag releases accordingly. The releases are signed and can be verified with `git tag --verify vA.B.C`. -## Using Vagrant +## Using Docker -The Vagrantfile in this repo will set up a two-server eureka cluster using the -OpsCode bento boxes. By default, the VMs are named node1.localdomain and -node2.localdomain. They'll be provisioned and eureka will start automatically. +Fargo is tested against two eureka versions, v1.1.147 and v1.3.1. To support +testing, we provide Docker containers that supply Eureka locally. Here's how to +get started. + +1. Clone Fargo +1. If you don't have it, [install Docker](https://docs.docker.com/). +1. Change into the `docker` directory of this repository. + +``` +# Build the image, change "1.3.1" to 1.1.147 for the older version +VERSION=1.3.1 +docker build -f Dockerfile-v$VERSION -t hudloss/eureka:$VERSION . +# Run two copies of the image (the containers will communicate with each other) +docker run -d --name eureka1 hudloss/eureka:$VERSION +docker run -d --name eureka2 hudloss/eureka:$VERSION +``` + +Now you're all set, and you should have Eureka servers available at +172.17.0.2:8080 and 172.17.0.3:8080. Run Fargo's tests with `go test ./...` +from the root of the repository. Happy Hacking! # Contributors diff --git a/docker/Dockerfile-v1.3 b/docker/Dockerfile-v1.3.1 similarity index 100% rename from docker/Dockerfile-v1.3 rename to docker/Dockerfile-v1.3.1