Skip to content

Commit

Permalink
Merge branch 'develop' into feature/JoistCassandraChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekjain88 committed May 15, 2017
2 parents a1f78d6 + 7c59a33 commit ada4d05
Show file tree
Hide file tree
Showing 24 changed files with 784 additions and 12 deletions.
4 changes: 4 additions & 0 deletions modules/export/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<name>${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>net.jodah</groupId>
<artifactId>failsafe</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*******************************************************************************/
package com.intuit.wasabi.export.rest;

import net.jodah.failsafe.RetryPolicy;

import java.net.URI;

/**
Expand All @@ -40,6 +42,12 @@ public interface RestEndPoint {
*/
int getRetries();

/**
* Retry policy
* @return retry policy
*/
RetryPolicy getRetryPolicy();

/**
* Configuration parames for rest endpoint
*/
Expand Down Expand Up @@ -80,5 +88,20 @@ interface Configuration {
* @return retries
*/
int getRetries();

/**
* Is exponential backoff enabled
*/
boolean isExponentialBackoffEnabled();

/**
* Get exponential backoff initial delay
*/
long getExponentialBackoffDelay();

/**
* Get exponential backoff max delay
*/
long getExponentialBackoffMaxDelay();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

import com.google.inject.Inject;
import com.intuit.wasabi.export.rest.RestEndPoint;
import net.jodah.failsafe.RetryPolicy;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.TimeUnit;

import static org.slf4j.LoggerFactory.getLogger;

Expand Down Expand Up @@ -62,4 +64,14 @@ public Boolean useProxy() {
public int getRetries() {
return configuration.getRetries();
}

@Override
public RetryPolicy getRetryPolicy() {
RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(configuration.getRetries());
if (configuration.isExponentialBackoffEnabled()) {
retryPolicy = retryPolicy.withBackoff(configuration.getExponentialBackoffDelay(),
configuration.getExponentialBackoffMaxDelay(), TimeUnit.SECONDS);
}
return retryPolicy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,34 @@ public Boolean useProxy() {
public int getRetries() {
return Integer.parseInt((String) properties.get("export.rest.retries"));
}

/**
* Returns the export rest endpoint is exponential backoff enabled property.
*
* @return whether exponential backoff is enabled for retries
*/
@Override
public boolean isExponentialBackoffEnabled() {
return Boolean.parseBoolean(properties.getProperty("export.rest.isExponentialBackoffEnabled"));
}

/**
* Returns the export rest endpoint exponential backoff initial delay
*
* @return initial interval size between retries with exponential backoff enabled
*/
@Override
public long getExponentialBackoffDelay() {
return Long.parseLong(properties.getProperty("export.rest.exponentialBackoffDelay"));
}

/**
* Returns the export rest endpoint exponential backoff max delay
*
* @return the maximum interval size until which retries are going to continue with exponential backoff strategy
*/
@Override
public long getExponentialBackoffMaxDelay() {
return Long.parseLong(properties.getProperty("export.rest.exponentialBackoffMaxDelay"));
}
}
24 changes: 24 additions & 0 deletions modules/functional-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ The tests use [TestNG](http://testng.org/doc/) and are implemented using
[rest-assured](https://github.com/jayway/rest-assured/wiki/Usage) and
[Gson](https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/index.html).

#Running Integration Test in Vagrant

Prerequisite:
* cd [workspace]/wasabi. mvn clean install
* Install Oracle VM VirtualBox (version 5.1.18 or higher) and Vagrant (version 1.9.3 or higher).

Mac installation instructions with brew
```shell
# install vagrant
% brew cask install vagrant
# install virtualbox
% brew cask install virtualbox
% brew cask install vagrant-manager
# install vagrant's omnibus
% vagrant plugin install vagrant-omnibus
```

To run all integration tests defined in testng.xml, simply do the following.
* cd [workspace]/wasabi/modules/functional-test
* vagrant up (this step will install dependencies (jdk, Cassandra, MySQL), install Wasabi app, create Cassandra tables, start up Wasabi app, run integration tests, stops Wasabi app and generate Jacoco file for code coverage)
* Test output will be saved in [workspace]/wasabi/modules/functional-test/target/integration-test.out
* vagrant destroy (this will destroy the VM)

**NOTE:** jacoco-it.exec will be stored at [workspace]/wasabi/modules/functional-test/target/jacoco

#Checklist

Expand Down
21 changes: 21 additions & 0 deletions modules/functional-test/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Vagrant.configure("2") do |config|

config.vm.box = 'bento/centos-7.2'
config.vm.provision "shell", :path => "provision.sh"
config.vm.provision "shell", :path => "target/scripts/migration.sh"
config.vm.provision "shell", :path => "target/scripts/server-start.sh"
config.vm.provision "shell", :path => "target/scripts/run-it.sh"
config.vm.provision "shell", :path => "target/scripts/server-stop.sh"

config.vm.define :wasabiosit do |dev|
dev.vm.hostname = "wasabi.os.it"
dev.vm.boot_timeout = 3000

dev.vm.provider "virtualbox" do |v|
v.name = "wasabi.os.it.vbox"
v.memory = 4096
v.cpus = 4
v.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
end
end
126 changes: 126 additions & 0 deletions modules/functional-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,132 @@
</execution>
</executions>
</plugin>
<!-- The following plugins are for running integration tests in Vagrant -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.intuit.wasabi</groupId>
<artifactId>wasabi-repository-datastax</artifactId>
<version>${version}</version>
<type>jar</type>
<includes>com/intuit/wasabi/repository/impl/cassandra/migration/*.*</includes>
<outputDirectory>./target/mutation</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-main-resource</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>${basedir}/../../modules/main/target/</directory>
<includes>
<include>*-all.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>filter-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/scripts</outputDirectory>
<resources>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
<includes>
<include>**/server-start.sh</include>
<include>**/cassandra_migration_rc.sh</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-jacoco-runtime-resource</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<type>jar</type>
</artifactItem>
</artifactItems>
<outputDirectory>./target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-cassandra-migration-resource</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.builtamont</groupId>
<artifactId>cassandra-migration</artifactId>
<version>${cassandra.migration.version}</version>
<classifier>jar-with-dependencies</classifier>
<type>jar</type>
</artifactItem>
</artifactItems>
<outputDirectory>./target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down
61 changes: 61 additions & 0 deletions modules/functional-test/provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
###############################################################################
# Copyright 2017 Intuit
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
#!/usr/bin/env bash

exec > >(tee ./provision.log|logger -t provision -s 2>/dev/console)

sudo yum -y install wget
sudo yum -y install vim

# install apache
yum -y install httpd
sudo service httpd start

# install Oracle JDK
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-x64.rpm"
sudo yum -y localinstall jdk-8u92-linux-x64.rpm

cat <<EOF | sudo tee -a /etc/yum.repos.d/datastax.repo
[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0
EOF

sudo yum -y install dsc21
sudo service cassandra start
sudo systemctl enable cassandra.service

# install mysql
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum -y update
sudo yum -y install mysql-server
sudo systemctl start mysqld

# create MySQL db
MYSQL_HOST="localhost"
MYSQL_DBNAME="wasabi"

mysql -s -N -h $MYSQL_HOST --execute="create database $MYSQL_DBNAME;"
mysql -s -N -h $MYSQL_HOST --execute="create user 'readwrite'@'localhost' identified by 'readwrite';"
mysql -s -N -h $MYSQL_HOST --execute="grant all privileges on wasabi.* to 'readwrite'@'localhost' identified by 'readwrite';"
mysql -s -N -h $MYSQL_HOST --execute="flush privileges;"

# install runit
curl -s https://packagecloud.io/install/repositories/imeyer/runit/script.rpm.sh | sudo bash
sudo yum -y install runit-2.1.2-3.el7.centos.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# Copyright 2017 Intuit
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
#!/usr/bin/env bash

export CASSANDRA_KEYSPACE=${cassandra.experiments.keyspaceName}
export CASSANDRA_KEYSPACE_PREFIX=${cassandra.keyspace.prefix}

export MIGRATION_SCRIPT_1=/vagrant/target/mutation/${wasabi.cassandra.migration.resource.path}
export CASSANDRA_MIGRATION=/vagrant/target/cassandra-migration-${cassandra.migration.version}-jar-with-dependencies.jar
export CQLSH_HOST=localhost
export CASSANDRA_REPLICATION=1

echo CASSANDRA_KEYSPACE $CASSANDRA_KEYSPACE
echo MIGRATION_SCRIPT_1 $MIGRATION_SCRIPT_1
echo CASSANDRA_MIGRATION $CASSANDRA_MIGRATION
echo CASSANDRA_KEYSPACE_PREFIX $CASSANDRA_KEYSPACE_PREFIX
echo CQLSH_HOST $CQLSH_HOST
echo CASSANDRA_REPLICATION $CASSANDRA_REPLICATION

0 comments on commit ada4d05

Please sign in to comment.