Skip to content

Commit

Permalink
Integration testing for the EC2 Tag Based Discovery (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Harko authored and patriknw committed Apr 9, 2018
1 parent 38c6d5e commit c0d0383
Show file tree
Hide file tree
Showing 18 changed files with 465 additions and 197 deletions.
16 changes: 12 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/.idea
target
credentials.sh
.DS_Store

target/

*.iml
*.ipr
*.iws
.idea

*.class
*.log

*.orig
**/.idea
21 changes: 2 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ scala:
jdk:
- oraclejdk8

before_script:
# Download kubectl, which is a requirement for using minikube.
- export CHANGE_MINIKUBE_NONE_USER=true
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Download minikube.
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
- sudo minikube start --vm-driver=none --kubernetes-version=v1.8.0
# Fix the kubectl context, as it's often stale.
- minikube update-context
# Wait for Kubernetes to be up and ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done

before_cache:
- find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete
Expand All @@ -37,20 +25,15 @@ script:
- git diff --exit-code --color || { echo "[error] Unformatted code found. Please run 'test:compile' and commit the reformatted code."; false; } && sbt -J-XX:ReservedCodeCacheSize=128m ++$TRAVIS_SCALA_VERSION ";test"
# check policies, if on master also upload
- if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_EVENT_TYPE" == "push" ]]; then sbt 'set credentials += Credentials("whitesource", "whitesourcesoftware.com", "", System.getenv("WHITESOURCE_KEY"))' whitesourceCheckPolicies whitesourceUpdate; else sbt 'set credentials += Credentials("whitesource", "whitesourcesoftware.com", "", System.getenv("WHITESOURCE_KEY"))' whitesourceCheckPolicies; fi; fi
# Create example Redis deployment on Kubernetes.
- kubectl cluster-info
- kubectl run travis-example --image=redis
- kubectl get deployment



deploy:
provider: script
script:
- sbt -J-XX:ReservedCodeCacheSize=128m ++$TRAVIS_SCALA_VERSION publish && curl -I https://ci.lightbend.com/job/techhub-publisher/build?token=$TECH_HUB_TOKEN
on:
tags: true
repo: akka/akka-management

env:
global:
# encrypt with: travis encrypt WHITESOURCE_KEY=...
Expand Down
116 changes: 0 additions & 116 deletions bootstrap-joining-demo/aws-api-ec2/CloudFormation/akka-cluster.yaml

This file was deleted.

32 changes: 14 additions & 18 deletions bootstrap-joining-demo/aws-api-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ Your Akka Cluster on Vanilla EC2 using Tag Based Discovery
==========================================================

Note: these steps can be easily automated via CloudFormation or
Python / shell scripts etc. In fact, a simple CloudFormation script is provided
[here](CloudFormation).

Examine the source code
-----------------------
Examine the source code. See how simple it is: there is no hardcoding
of seed node IPs or host names in the application.conf file.
Python / shell scripts etc. In fact, a simple CloudFormation script is provided [here](src/main/resources/CloudFormation).


Step 1: Launch Instances
------------------------

From the AWS Management Console, provision a few EC2 instances (you'll need at least 2). Recommended image: Ubuntu Server 16.04
(AMI ID: ami-26ebbc5c). As for the instance type, this demo app runs fine even on t1.micro instances. As for the security group,
From the AWS Management Console, provision a few EC2 instances (you'll need at least 2). Recommended image: Ubuntu Server 16.04. As for the instance type, this demo app runs fine even on t1.micro instances. As for the security group,
for now, just select the default one and make sure you allow yourself ssh access to your instances. Once the instances are ready,
ssh into them - you'll need to install Java 8. You can use this [guide](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04).
ssh into them - you may need to install Java 8 ( you can use this [guide](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04)).


Step 2: Create IAM Role
Expand Down Expand Up @@ -65,34 +58,37 @@ Step 6: Package the App
Compile and package the demo app.

```
$ cd bootstrap-joining-demo
$ cd aws-api
$ cd akka-management
$ sbt
> project bootstrap-joining-demo-aws-api-ec2-tag-based
> universal:packageBin
```

Now, in the `bootstrap-joining-demo/aws-api/target/universal` folder, you should have a
`bootstrap-joining-demo-aws-api-1.0.zip` file.
Now, in the `bootstrap-joining-demo/aws-api-ec2/target/universal` folder, you should have a
`app.zip` file.

Step 7: Tag Instances
---------------------

Tag your instances with tag "service" -> "products-api".
Tag your instances with tag "service" -> "products-api".
The demo app is configured (via the "akka.discovery.aws-api-ec2-tag-based.filters" key, see the application.conf file)
to require an additional tag "purpose" -> "demo".

![tagging instances](screenshots/discovery-aws-ec2-tagged-instances.png)



Step 8: Run and validate the cluster !
--------------------------------------

Transfer (via scp, for example) the package zip file to your EC2 instances.
Unzip the package and run the app like this on each instance:

```
$ unzip bootstrap-joining-demo-aws-api-1.0.zip
$ cd bootstrap-joining-demo-aws-api-1.0/bin
$ unzip app.zip
$ cd app/bin
$ MY_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
$ ./bootstrap-joining-demo-aws-api -Dakka.management.http.hostname=$MY_IP -Dakka.remote.netty.tcp.hostname=$MY_IP
$ ./akka-management-bootstrap-joining-demo-aws-api-ec2-tag-based -Dakka.management.http.hostname=$MY_IP -Dakka.remote.netty.tcp.hostname=$MY_IP
```

Follow the logs and watch for signs of successful cluster formation (e.g., a welcome message from one of the nodes).
Expand Down
10 changes: 4 additions & 6 deletions bootstrap-joining-demo/aws-api-ec2/build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
enablePlugins(JavaAppPackaging)
name := "bootstrap-joining-demo-aws-api-ec2"

version := "1.0"
packageName in Universal := "app" // should produce app.zip

scalaVersion := "2.12.4"
libraryDependencies += "com.amazonaws" % "aws-java-sdk-cloudformation" % "1.11.271" % IntegrationTest

libraryDependencies += "com.lightbend.akka.management" % "akka-management-cluster-bootstrap_2.12" % "0.8.0"
libraryDependencies += "com.amazonaws" % "aws-java-sdk-autoscaling" % "1.11.271" % IntegrationTest

libraryDependencies += "com.lightbend.akka.management" % "akka-management-cluster-http_2.12" % "0.8.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % IntegrationTest

libraryDependencies += "com.lightbend.akka.discovery" % "akka-discovery-aws-api_2.12" % "0.8.0"

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
akka {
log-config-on-start = "off"
actor {
provider = "local"
# the integration test uses akka just for the Akka Http client, so we can turn off the cluster
}
}
Loading

0 comments on commit c0d0383

Please sign in to comment.