Merge remote-tracking branches 'remotes/upstream/wip-customer' and 'remotes/upstream/wip-vagrant' into wip-customer
This commit is contained in:
103
Vagrantfile
vendored
Normal file
103
Vagrantfile
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure(2) do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = 2048
|
||||
v.cpus = 2
|
||||
end
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
# vb.memory = "1024"
|
||||
# end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
#!/bin/sh
|
||||
|
||||
# https://github.com/pussinboots/vagrant-devel/blob/master/provision/packages/java8.sh
|
||||
|
||||
if which java >/dev/null; then
|
||||
echo "skip java 8 installation"
|
||||
else
|
||||
echo "java 8 installation"
|
||||
apt-get install --yes python-software-properties
|
||||
add-apt-repository ppa:webupd8team/java
|
||||
apt-get update -qq
|
||||
echo debconf shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
|
||||
echo debconf shared/accepted-oracle-license-v1-1 seen true | /usr/bin/debconf-set-selections
|
||||
apt-get install --yes oracle-java8-installer
|
||||
yes "" | apt-get -f install
|
||||
fi
|
||||
SHELL
|
||||
|
||||
config.vm.provision "docker" do |d|
|
||||
end
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
if which docker-compose >/dev/null; then
|
||||
echo "skip docker-compose installation"
|
||||
else
|
||||
sudo bash -c "curl -L https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose ; chmod +x /usr/local/bin/docker-compose"
|
||||
fi
|
||||
SHELL
|
||||
|
||||
end
|
||||
@@ -16,8 +16,12 @@ fi
|
||||
${DOCKER_COMPOSE?} up -d mongodb
|
||||
|
||||
if [ -z "$DOCKER_HOST_IP" ] ; then
|
||||
export DOCKER_HOST_IP=$(docker-machine ip default)
|
||||
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
|
||||
if which docker-machine >/dev/null; then
|
||||
export DOCKER_HOST_IP=$(docker-machine ip default)
|
||||
else
|
||||
export DOCKER_HOST_IP=localhost
|
||||
fi
|
||||
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
|
||||
fi
|
||||
|
||||
if [ -z "$SPRING_DATA_MONGODB_URI" ] ; then
|
||||
@@ -27,7 +31,7 @@ fi
|
||||
|
||||
export SERVICE_HOST=$DOCKER_HOST_IP
|
||||
|
||||
./gradlew $* build
|
||||
./gradlew $* build -x :e2e-test:test
|
||||
|
||||
if [ -z "$EVENTUATE_API_KEY_ID" -o -z "$EVENTUATE_API_KEY_SECRET" ] ; then
|
||||
echo You must set EVENTUATE_API_KEY_ID and EVENTUATE_API_KEY_SECRET
|
||||
@@ -37,11 +41,11 @@ fi
|
||||
|
||||
${DOCKER_COMPOSE?} up -d
|
||||
|
||||
$DIR/wait-for-services.sh $DOCKER_HOST_IP
|
||||
$DIR/wait-for-services.sh $DOCKER_HOST_IP 8080 8081 8082
|
||||
|
||||
set -e
|
||||
|
||||
./gradlew $* :e2e-test:cleanTest :e2e-test:test
|
||||
./gradlew -a $* :e2e-test:cleanTest :e2e-test:test -P ignoreE2EFailures=false
|
||||
|
||||
${DOCKER_COMPOSE?} stop
|
||||
${DOCKER_COMPOSE?} rm -v --force
|
||||
|
||||
@@ -31,9 +31,9 @@ public class CustomerController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}/toaccounts", method = RequestMethod.POST)
|
||||
public Observable<ResponseEntity<?>> addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) {
|
||||
public Observable<String> addToAccount(@PathVariable String id, @Validated @RequestBody ToAccountInfo request) {
|
||||
return customerService.addToAccount(id, request)
|
||||
.map(entityAndEventInfo -> ResponseEntity.ok().build());
|
||||
.map(entityAndEventInfo -> entityAndEventInfo.entityVersion().asString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ dependencies {
|
||||
}
|
||||
|
||||
test {
|
||||
ignoreFailures true
|
||||
ignoreFailures System.getenv("EVENTUATE_API_KEY_ID") == null
|
||||
}
|
||||
|
||||
|
||||
55
java-spring/handy-curl-commands.sh
Executable file
55
java-spring/handy-curl-commands.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#! /bin/bash -e
|
||||
|
||||
# Create a customer
|
||||
|
||||
customer=$(curl -v --data '{
|
||||
"address": {
|
||||
"city": "Oakland",
|
||||
"state": "CA",
|
||||
"street1": "1 High Street",
|
||||
"zipCode": "12345"
|
||||
},
|
||||
"email": "foo@bar.com",
|
||||
"name": {
|
||||
"firstName": "John",
|
||||
"lastName": "Doe"
|
||||
},
|
||||
"phoneNumber": "415551212",
|
||||
"ssn": "123-45-6789"
|
||||
}' -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8083/customers)
|
||||
|
||||
customerId=$(echo $customer | jq -r .id)
|
||||
|
||||
echo customerId=$customerId
|
||||
|
||||
# Create account 1
|
||||
|
||||
account1=$(curl -v --data "{\"initialBalance\" : 500, \"customerId\" : \"$customerId\"}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8080/accounts)
|
||||
|
||||
accountId1=$(echo $account1 | jq -r ".accountId")
|
||||
|
||||
curl -v http://${DOCKER_HOST_IP?}:8081/accounts/$accountId1
|
||||
|
||||
echo accountId1=$accountId1
|
||||
|
||||
# Create account 2
|
||||
|
||||
account2=$(curl -v --data "{\"initialBalance\" : 300, \"customerId\" : \"$customerId\"}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8080/accounts)
|
||||
|
||||
accountId2=$(echo $account2 | jq -r ".accountId")
|
||||
|
||||
|
||||
curl -v http://${DOCKER_HOST_IP?}:8081/accounts/$accountId2
|
||||
|
||||
echo accountId2=$accountId2
|
||||
|
||||
#
|
||||
|
||||
|
||||
transfer=$(curl -v --data "{\"amount\" : 150,
|
||||
\"fromAccountId\" : \"$accountId1\", \"toAccountId\" : \"$accountId2\"
|
||||
}" -H "content-type: application/json" http://${DOCKER_HOST_IP?}:8082/transfers)
|
||||
|
||||
echo transfer=$transfer
|
||||
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
while [[ true ]]; do
|
||||
nc -z -w 4 ${1?} 8080 && nc -z -w 4 ${1?} 8081 && nc -z -w 4 ${1?} 8082
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
done=false
|
||||
|
||||
host=$1
|
||||
shift
|
||||
ports=$*
|
||||
|
||||
while [[ "$done" = false ]]; do
|
||||
for port in $ports; do
|
||||
curl -q http://${host}:${port}/health >& /dev/null
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
done=true
|
||||
else
|
||||
done=false
|
||||
fi
|
||||
done
|
||||
if [[ "$done" = true ]]; then
|
||||
echo connected
|
||||
break
|
||||
fi
|
||||
break;
|
||||
fi
|
||||
#curl -q http://${1?}:8080/health >& /dev/null && curl -q http://${1?}:8081/health >& /dev/null && curl -q http://${1?}:8082/health >& /dev/null
|
||||
echo -n .
|
||||
sleep 1
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user