From 16de986a86c5d7465844591884c094fdf2c673fd Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 13 May 2015 18:58:46 +0900 Subject: [PATCH 001/147] add ciscripts. --- ciscripts/create-app.sh | 53 ++++++++++++++++++++++++++++++++++++++ ciscripts/create-centos.sh | 53 ++++++++++++++++++++++++++++++++++++++ ciscripts/create-db.sh | 53 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100755 ciscripts/create-app.sh create mode 100755 ciscripts/create-centos.sh create mode 100755 ciscripts/create-db.sh diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh new file mode 100755 index 0000000..ef95641 --- /dev/null +++ b/ciscripts/create-app.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -x + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS + +# setup vifs.json + +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS +cat "${vifs}" + +# setup user_data.txt + +user_data="user_data.txt" +cat < "${user_data}" +EOS +cat "${user_data}" + +# instance-specific parameter + +cpu_cores="1" +hypervisor="kvm" +memory_size="1024" +image_id="wmi-php1d64" +display_name="app" +ssh_key_id="ssh-cicddemo" + +# mussel + + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --user-data "${user_data}" \ + --display-name "${display_name}" \ diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh new file mode 100755 index 0000000..7094c96 --- /dev/null +++ b/ciscripts/create-centos.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -x + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS + +# setup vifs.json + +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS +cat "${vifs}" + +# setup user_data.txt + +user_data="user_data.txt" +cat < "${user_data}" +EOS +cat "${user_data}" + +# instance-specific parameter + +cpu_cores="1" +hypervisor="kvm" +memory_size="1024" +image_id="wmi-centos1d64" +display_name="centos" +ssh_key_id="ssh-cicddemo" + +# mussel + + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --user-data "${user_data}" \ + --display-name "${display_name}" \ diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh new file mode 100755 index 0000000..f32b6ac --- /dev/null +++ b/ciscripts/create-db.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -x + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS + +# setup vifs.json + +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS +cat "${vifs}" + +# setup user_data.txt + +user_data="user_data.txt" +cat < "${user_data}" +EOS +cat "${user_data}" + +# instance-specific parameter + +cpu_cores="1" +hypervisor="kvm" +memory_size="1024" +image_id="wmi-mysqld1d64" +display_name="db" +ssh_key_id="ssh-cicddemo" + +# mussel + + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --user-data "${user_data}" \ + --display-name "${display_name}" \ From 42cec2d9cf2f69735a51678ebf57ba7d26755b79 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 13 May 2015 20:27:20 +0900 Subject: [PATCH 002/147] add instance-wait4ssh.sh. --- ciscripts/instance-wait4ssh.sh | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 ciscripts/instance-wait4ssh.sh diff --git a/ciscripts/instance-wait4ssh.sh b/ciscripts/instance-wait4ssh.sh new file mode 100755 index 0000000..ef267cc --- /dev/null +++ b/ciscripts/instance-wait4ssh.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +## check + +function open_port?() { + local ipaddr=$1 protocol=$2 port=$3 + + local nc_opts="-w 3" + case ${protocol} in + tcp) ;; + udp) nc_opts="${nc_opts} -u";; + *) ;; + esac + + echo | nc ${nc_opts} ${ipaddr} ${port} >/dev/null +} + +function network_connection?() { + local ipaddr=$1 + ping -c 1 -W 3 ${ipaddr} +} + +## wait for *to be* + +function wait_for_network_to_be_ready() { + local ipaddr=$1 + retry_until "network_connection? ${ipaddr}" +} + +function wait_for_port_to_be_ready() { + local ipaddr=$1 protocol=$2 port=$3 + retry_until "open_port? ${ipaddr} ${protocol} ${port}" +} + +function wait_for_sshd_to_be_ready() { + local ipaddr=$1 + wait_for_port_to_be_ready ${ipaddr} tcp 22 +} + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## get the instance's ipaddress + +ipaddr= +eval "$( + ${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}" +)" +: "${ipaddr:?"should not be empty"}" + +## wait... + +{ + wait_for_network_to_be_ready "${ipaddr}" + wait_for_sshd_to_be_ready "${ipaddr}" +} >&2 +echo ipaddr="${ipaddr}" From d111052db90464a39a2e5625706880fc1001da47 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 13 May 2015 20:33:43 +0900 Subject: [PATCH 003/147] show instance_id only. --- ciscripts/create-app.sh | 7 ++++++- ciscripts/create-centos.sh | 7 ++++++- ciscripts/create-db.sh | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index ef95641..2739e65 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -40,8 +40,9 @@ image_id="wmi-php1d64" display_name="app" ssh_key_id="ssh-cicddemo" -# mussel +## create an instance +instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ --hypervisor "${hypervisor}" \ @@ -51,3 +52,7 @@ ssh_key_id="ssh-cicddemo" --vifs "${vifs}" \ --user-data "${user_data}" \ --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo instance_id="${instance_id}" diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 7094c96..3ef4135 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -40,8 +40,9 @@ image_id="wmi-centos1d64" display_name="centos" ssh_key_id="ssh-cicddemo" -# mussel +## create an instance +instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ --hypervisor "${hypervisor}" \ @@ -51,3 +52,7 @@ ssh_key_id="ssh-cicddemo" --vifs "${vifs}" \ --user-data "${user_data}" \ --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo instance_id="${instance_id}" diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index f32b6ac..8d4a8bb 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -40,8 +40,9 @@ image_id="wmi-mysqld1d64" display_name="db" ssh_key_id="ssh-cicddemo" -# mussel +## create an instance +instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ --hypervisor "${hypervisor}" \ @@ -51,3 +52,7 @@ ssh_key_id="ssh-cicddemo" --vifs "${vifs}" \ --user-data "${user_data}" \ --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo instance_id="${instance_id}" From bce7e54efb6e045795caf81a11898b4f89bbee69 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 13 May 2015 20:38:49 +0900 Subject: [PATCH 004/147] disable user_data and vif. --- ciscripts/create-app.sh | 2 -- ciscripts/create-centos.sh | 2 -- ciscripts/create-db.sh | 2 -- 3 files changed, 6 deletions(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index 2739e65..9501693 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -22,14 +22,12 @@ cat < "${vifs}" "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} } EOS -cat "${vifs}" # setup user_data.txt user_data="user_data.txt" cat < "${user_data}" EOS -cat "${user_data}" # instance-specific parameter diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 3ef4135..0bf6376 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -22,14 +22,12 @@ cat < "${vifs}" "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} } EOS -cat "${vifs}" # setup user_data.txt user_data="user_data.txt" cat < "${user_data}" EOS -cat "${user_data}" # instance-specific parameter diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 8d4a8bb..a08d4cd 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -22,14 +22,12 @@ cat < "${vifs}" "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} } EOS -cat "${vifs}" # setup user_data.txt user_data="user_data.txt" cat < "${user_data}" EOS -cat "${user_data}" # instance-specific parameter From 3d5fb49b96b3fcf8e428a8d5e3f646b35af0ab03 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 13 May 2015 20:53:44 +0900 Subject: [PATCH 005/147] fix to get ipaddr. --- ciscripts/instance-wait4ssh.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ciscripts/instance-wait4ssh.sh b/ciscripts/instance-wait4ssh.sh index ef267cc..bcba28e 100755 --- a/ciscripts/instance-wait4ssh.sh +++ b/ciscripts/instance-wait4ssh.sh @@ -16,6 +16,7 @@ function retry_until() { local sleep_sec=${RETRY_SLEEP_SEC:-3} local tries=0 local start_at=$(date +%s) + local chk_cmd= while :; do eval "${blk}" && { @@ -75,13 +76,20 @@ function wait_for_sshd_to_be_ready() { instance_id="${1}" : "${instance_id:?"should not be empty"}" +## wait... + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] + ## get the instance's ipaddress -ipaddr= -eval "$( - ${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}" +ipaddr="$( + mussel instance show "${instance_id}" \ + | egrep :address: \ + | awk '{print $2}' \ + | tr '\n' ',' )" : "${ipaddr:?"should not be empty"}" +ipaddr="${ipaddr%%,}" ## wait... From 8264fd0ab388e3ad400766f18788a855e6eb73ec Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:05:37 +0900 Subject: [PATCH 006/147] add create-lbapp.sh and create-lbweb.sh. --- ciscripts/create-lbapp.sh | 73 +++++++++++++++++++++++++++++++++++++++ ciscripts/create-lbweb.sh | 73 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100755 ciscripts/create-lbapp.sh create mode 100755 ciscripts/create-lbweb.sh diff --git a/ciscripts/create-lbapp.sh b/ciscripts/create-lbapp.sh new file mode 100755 index 0000000..c7ea92f --- /dev/null +++ b/ciscripts/create-lbapp.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# Usage: +# $0 +# +set -e +set -o pipefail +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +## shell params + +balance_algorithm="leastconn" +engine="haproxy" +max_connection="1000" +instance_port="8080" +instance_protocol="http" +port_maps="8080:http" +display_name="lb8080" + +## create a load_balancer + +load_balancer_id="$( + mussel load_balancer create \ + --balance-algorithm "${balance_algorithm}" \ + --engine "${engine}" \ + --instance-port "${instance_port}" \ + --instance-protocol "${instance_protocol}" \ + --max-connection "${max_connection}" \ + --display-name "${display_name}" \ + $( + IFS=, + for i in ${port_maps}; do + echo --port ${i%%:*} + echo --protocol ${i##*:} + done + ) \ + | egrep ^:id: | awk '{print $2}' +)" + +: "${load_balancer_id:?"load_balancer is empty"}" +echo "${load_balancer_id} is initializing..." >&2 + +## wait for the load_balancer to be running + +retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] +echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/create-lbweb.sh b/ciscripts/create-lbweb.sh new file mode 100755 index 0000000..5118226 --- /dev/null +++ b/ciscripts/create-lbweb.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# Usage: +# $0 +# +set -e +set -o pipefail +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +## shell params + +balance_algorithm="leastconn" +engine="haproxy" +max_connection="1000" +instance_port="80" +instance_protocol="http" +port_maps="80:http" +display_name="lb80" + +## create a load_balancer + +load_balancer_id="$( + mussel load_balancer create \ + --balance-algorithm "${balance_algorithm}" \ + --engine "${engine}" \ + --instance-port "${instance_port}" \ + --instance-protocol "${instance_protocol}" \ + --max-connection "${max_connection}" \ + --display-name "${display_name}" \ + $( + IFS=, + for i in ${port_maps}; do + echo --port ${i%%:*} + echo --protocol ${i##*:} + done + ) \ + | egrep ^:id: | awk '{print $2}' +)" + +: "${load_balancer_id:?"load_balancer is empty"}" +echo "${load_balancer_id} is initializing..." >&2 + +## wait for the load_balancer to be running + +retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] +echo load_balancer_id="${load_balancer_id}" From 7517b539b67e59890dc759aa0d5a6b5167894885 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:05:46 +0900 Subject: [PATCH 007/147] add retry. --- ciscripts/create-app.sh | 34 +++++++++++++++++++++++++++++++++- ciscripts/create-centos.sh | 34 +++++++++++++++++++++++++++++++++- ciscripts/create-db.sh | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index 9501693..302d6a8 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -2,7 +2,34 @@ # set -e set -o pipefail -set -x +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} # setup musselrc @@ -53,4 +80,9 @@ instance_id="$( | egrep ^:id: | awk '{print $2}' )" : "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +## wait for the instance to be running + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 0bf6376..2d6aa35 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -2,7 +2,34 @@ # set -e set -o pipefail -set -x +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} # setup musselrc @@ -53,4 +80,9 @@ instance_id="$( | egrep ^:id: | awk '{print $2}' )" : "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +## wait for the instance to be running + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index a08d4cd..be7d74f 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -2,7 +2,34 @@ # set -e set -o pipefail -set -x +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} # setup musselrc @@ -53,4 +80,9 @@ instance_id="$( | egrep ^:id: | awk '{print $2}' )" : "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +## wait for the instance to be running + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" From fa6313ca2f4d444b1b5f146506f1a588904d8d14 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:31:09 +0900 Subject: [PATCH 008/147] add error trap. --- ciscripts/create-app.sh | 2 ++ ciscripts/create-centos.sh | 2 ++ ciscripts/create-db.sh | 2 ++ 3 files changed, 6 insertions(+) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index 302d6a8..e144012 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -82,6 +82,8 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 +trap "mussel instance destroy \"${instance_id}\"" ERR + ## wait for the instance to be running retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 2d6aa35..8fda289 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -82,6 +82,8 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 +trap "mussel instance destroy \"${instance_id}\"" ERR + ## wait for the instance to be running retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index be7d74f..5c080c1 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -82,6 +82,8 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 +trap "mussel instance destroy \"${instance_id}\"" ERR + ## wait for the instance to be running retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] From 7a3e81a3464bf322ea68f69c1f1c95ee34b04199 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:32:26 +0900 Subject: [PATCH 009/147] add error trap. --- ciscripts/create-lbapp.sh | 2 ++ ciscripts/create-lbweb.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ciscripts/create-lbapp.sh b/ciscripts/create-lbapp.sh index c7ea92f..f5f163f 100755 --- a/ciscripts/create-lbapp.sh +++ b/ciscripts/create-lbapp.sh @@ -67,6 +67,8 @@ load_balancer_id="$( : "${load_balancer_id:?"load_balancer is empty"}" echo "${load_balancer_id} is initializing..." >&2 +trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR + ## wait for the load_balancer to be running retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] diff --git a/ciscripts/create-lbweb.sh b/ciscripts/create-lbweb.sh index 5118226..15383ce 100755 --- a/ciscripts/create-lbweb.sh +++ b/ciscripts/create-lbweb.sh @@ -67,6 +67,8 @@ load_balancer_id="$( : "${load_balancer_id:?"load_balancer is empty"}" echo "${load_balancer_id} is initializing..." >&2 +trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR + ## wait for the load_balancer to be running retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] From e2d2d8a51c7488d5faea35196a88863cb0a52a10 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:44:22 +0900 Subject: [PATCH 010/147] use latest open_port()?. --- ciscripts/instance-wait4ssh.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ciscripts/instance-wait4ssh.sh b/ciscripts/instance-wait4ssh.sh index bcba28e..1db646f 100755 --- a/ciscripts/instance-wait4ssh.sh +++ b/ciscripts/instance-wait4ssh.sh @@ -41,12 +41,12 @@ function open_port?() { local nc_opts="-w 3" case ${protocol} in - tcp) ;; - udp) nc_opts="${nc_opts} -u";; - *) ;; + tcp) ;; + udp) nc_opts="${nc_opts} -u";; + *) ;; esac - echo | nc ${nc_opts} ${ipaddr} ${port} >/dev/null + nc ${nc_opts} ${ipaddr} ${port} <<< "" >/dev/null } function network_connection?() { From ec2e2e3f0397221448a505a845b22e845b4f7174 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 06:54:02 +0900 Subject: [PATCH 011/147] add instance-kill.sh. --- ciscripts/instance-kill.sh | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 ciscripts/instance-kill.sh diff --git a/ciscripts/instance-kill.sh b/ciscripts/instance-kill.sh new file mode 100755 index 0000000..9605b6b --- /dev/null +++ b/ciscripts/instance-kill.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## main + +mussel instance destroy "${instance_id}" >/dev/null +echo "${instance_id} is shuttingdown..." >&2 + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: terminated")"' ]] +echo instance_id="${instance_id}" From 11fc0a0721b5516bc1a7d8a9dc90d358aff10571 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:08:56 +0900 Subject: [PATCH 012/147] add instance-exec.sh. --- ciscripts/instance-exec.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 ciscripts/instance-exec.sh diff --git a/ciscripts/instance-exec.sh b/ciscripts/instance-exec.sh new file mode 100755 index 0000000..266317b --- /dev/null +++ b/ciscripts/instance-exec.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +function ssh() { + $(type -P ssh) -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' ${@} +} + +## shell params + +ssh_user="root" +ssh_key="demokeypair" + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## get the instance's ipaddress + +ipaddr="$( + mussel instance show "${instance_id}" \ + | egrep -w :address: | awk '{print $2}' +)" +: "${ipaddr:?"should not be empty"}" + +## ssh to the instance + +chmod 600 "${ssh_key}" + +shift +ssh "${ssh_user}@${ipaddr}" -i "${ssh_key}" "${@}" From e8e13b0f758c3082bed7c8f452fb3b8160252739 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:13:56 +0900 Subject: [PATCH 013/147] add demokeypair. --- ciscripts/demokeypair | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ciscripts/demokeypair diff --git a/ciscripts/demokeypair b/ciscripts/demokeypair new file mode 100644 index 0000000..b6a26a9 --- /dev/null +++ b/ciscripts/demokeypair @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA6KmXs11l/2WUIBDYmTB0T+BXwwCXT+RP/CTVtxq1Tnq8biwa +pDxHuYgvQWSOOH7DIZq/+GU+P69BBWAbnd1LNkWDOoMmnaIthXQBptZupYFfYiKA +Uh4UH0L0wwenifE2yV+SdWLT6FEiiQ2RTatqK1xiWSwvduWkeMA+dW1NbSk0XmEh +Z76QLsRxrs9JF4jqPXJVulzgjnD9Z5tkNY7MyfD1PNJcM2+MS8XmAApxLQLrfxEl +LZMsgvzvFVec45siOiG+VTWbGADc3lBSHIj2pt6aZDLkOhSnZegmsciVFQk1ulLF +jGjD2LoqYT5/UirpwQsElsjWTEEbBZzV10AVlwIDAQABAoIBAQCdnQ4cv1/ypXC0 +TFU/abjRx8wMWWEoCSY6TQXOtjQvByyRgiVGL2PzhxNkPGewVAeCw1/bOVLzN5lX +t+Tdi+WAzZR51hEZ5pzp9E2OJWPtkPf59h9yAdhl2SkQ2iWgaB1STAFermWZ0yUP +LXbK5B3XZA1oFWvOIwHJn4pwaGx0TpOtEjPHiEkJxj1SRAzN377Uu3SNz9UsRrfQ +3v7iLxrPvwqhXIBo1VzQIliWzH5/IQ6xAqAsMLTo0uJ+d1wkoZ6nGkjt+LYD5hyD +Ov76lOjlevkPu3BENwwt3Este2d00gOC2Qt649P/chd9B8vc4ZZ8F3bPVfmfdiJt +fYRPaF5ZAoGBAP5vEA/lWH5xN6dB7j+wFPLAP7+8H2jz4aBcDWCiDjoMA4JRvc8V +gJxaW33b8gbP39byZAfBLNWHPE+4q/95CW7TkXnzdCR9HxeKC77jnBXg6wX5zist +E/cDMPykATtMqUFf/K46lPjaUbn4gmLEkc9lS7V+ySoPMdMUG6zqQf2DAoGBAOoY +OPSHu2Y7R4V3BnzNeGz6PCrohz7IjqjSD74KhAhuFCM7w+ymDmk2xSIR4S4F7qlD +mBodXpncqxQMtkF2pRRGDefbTXW5m+lWOy/DrsYV0bqy5OqA2r7Ukj5M0o97S8D1 +vhTxwXCehx8GX8RlbybuMkfpB2NefMxakG+BAX9dAoGASPS/vk8dGOSN+L/G+Swc +VZ8aqHfg6c9Emx7KFzNgsPRQ7UVTD9YykqK2KViwBZQFszS9yhtyJ6gnexSQ/ShP +tB+mTzmny+60w6Mpywqo7v0XZxdCLs82MlYP7eF5GO/aeIx1f9/8Z37ygEjp2jhT +NwzssJYySIUi3Eufw+1IDtECgYEAr3NOJMAiTWH6neZyn1Fkg9EdDU/QJdctTQx7 +rgS1ppfSUgH2O0TOIj9hisJ50gOyN3yo4FHI2GrScimA5BmnakWDIJZ2PNjLKRxv +KcJxGJe75EE2XygKSuKJZVYwrkdLpKjKOWpkgCLgxPkDB/C6WSRH3SujVO+5e3QZ +MukulSUCgYBMtuQ6VMrlMTedLW6ryd8VYsVNZaAGuphejFCCuur13M/1wHrRUzqM +hECAngl6fus+weYMiQYx1V8oxz3tBdYO8KKG8pnQySTt5Dln19+vqH2+18RWDKtH +0rwxRJ4Rc3wKFVwK+gz6NsBvftnQAK52qWip71tPY7zt9LeWWJv08g== +-----END RSA PRIVATE KEY----- From fe6d0c9776ac9c06c42e1d4911ca21ef07ccf677 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:16:57 +0900 Subject: [PATCH 014/147] add provision-db.sh. --- ciscripts/provision-db.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 ciscripts/provision-db.sh diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-db.sh new file mode 100755 index 0000000..f869ba4 --- /dev/null +++ b/ciscripts/provision-db.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# requires: +# bash +# mysqladmin, mysql +# +set -e +set -o pipefail +set -u +set -x + +until mysqladmin -uroot ping; do + sleep 1 +done + +dbname="wordpress" +dbuser="wordpressuser" +dbpass="password" +dbacl="10.%" + +mysqladmin -uroot drop ${dbname} <<< "Y" || : +mysqladmin -uroot create ${dbname} --default-character-set=utf8 + +mysql -uroot mysql < Date: Fri, 15 May 2015 07:21:18 +0900 Subject: [PATCH 015/147] add ./instance-get-ipaddr.sh. --- ciscripts/instance-get-ipaddr.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 ciscripts/instance-get-ipaddr.sh diff --git a/ciscripts/instance-get-ipaddr.sh b/ciscripts/instance-get-ipaddr.sh new file mode 100755 index 0000000..ed647ba --- /dev/null +++ b/ciscripts/instance-get-ipaddr.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## get the instance's ipaddress + +ipaddr="$( + mussel instance show "${instance_id}" \ + | egrep :address: \ + | awk '{print $2}' \ + | tr '\n' ',' +)" +: "${ipaddr:?"should not be empty"}" + +## show the instance + +echo ipaddr="${ipaddr%%,}" From 6ac549f28a9ce0308df1b0cebfa82eb219e8e1a8 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:29:14 +0900 Subject: [PATCH 016/147] update db config. --- ciscripts/provision-db.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-db.sh index f869ba4..d19f7e8 100755 --- a/ciscripts/provision-db.sh +++ b/ciscripts/provision-db.sh @@ -13,16 +13,15 @@ until mysqladmin -uroot ping; do sleep 1 done -dbname="wordpress" -dbuser="wordpressuser" -dbpass="password" +dbname="tiny_web_example" +dbuser="root" dbacl="10.%" mysqladmin -uroot drop ${dbname} <<< "Y" || : mysqladmin -uroot create ${dbname} --default-character-set=utf8 mysql -uroot mysql < Date: Fri, 15 May 2015 07:49:42 +0900 Subject: [PATCH 017/147] add runner-db.sh. --- ciscripts/runner-db.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 ciscripts/runner-db.sh diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh new file mode 100755 index 0000000..0a19c95 --- /dev/null +++ b/ciscripts/runner-db.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +eval "$( + ./create-db.sh +)" + +trap "mussel instance destroy \"${instance_id}\"" ERR + +eval "$(./instance-get-ipaddr.sh "${instance_id}")" + +{ + ./instance-wait4ssh.sh "${instance_id}" + ./instance-exec.sh "${instance_id}" < ./provision-db.sh +} + +./instance-kill.sh "${instance_id}" From 1f9626617c95ff9de04d701d8fd52910fdce66bc Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:52:43 +0900 Subject: [PATCH 018/147] add provision-app.sh. --- ciscripts/runner-app.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 ciscripts/runner-app.sh diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh new file mode 100755 index 0000000..f873559 --- /dev/null +++ b/ciscripts/runner-app.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +eval "$( + ./create-centos.sh + )" +trap "mussel instance destroy \"${instance_id}\"" ERR + +eval "$(./instance-get-ipaddr.sh "${instance_id}")" + +{ + ./instance-wait4ssh.sh "${instance_id}" + ./instance-exec.sh "${instance_id}" < ./provision-app.sh +} + +./instance-kill.sh "${instance_id}" From 7df17d6c3e3d16f63320fd1eba3607f317d51034 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:54:36 +0900 Subject: [PATCH 019/147] show instance_id. --- ciscripts/provision-app.sh | 11 +++++++++++ ciscripts/runner-app.sh | 2 +- ciscripts/runner-db.sh | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 ciscripts/provision-app.sh diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh new file mode 100755 index 0000000..4951ef9 --- /dev/null +++ b/ciscripts/provision-app.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x + +hostname diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index f873559..392b5b7 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -18,4 +18,4 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" ./instance-exec.sh "${instance_id}" < ./provision-app.sh } -./instance-kill.sh "${instance_id}" +echo instance_id="${instance_id}" diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh index 0a19c95..714485a 100755 --- a/ciscripts/runner-db.sh +++ b/ciscripts/runner-db.sh @@ -19,4 +19,4 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" ./instance-exec.sh "${instance_id}" < ./provision-db.sh } -./instance-kill.sh "${instance_id}" +echo instance_id="${instance_id}" From 25816cfd8950e503ce2a7f8833c7774359e5f90c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:56:51 +0900 Subject: [PATCH 020/147] adjust redirect. --- ciscripts/runner-app.sh | 2 +- ciscripts/runner-db.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index 392b5b7..5b3fb80 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -16,6 +16,6 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" ./instance-exec.sh "${instance_id}" < ./provision-app.sh -} +} >&2 echo instance_id="${instance_id}" diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh index 714485a..36cfc76 100755 --- a/ciscripts/runner-db.sh +++ b/ciscripts/runner-db.sh @@ -17,6 +17,6 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" ./instance-exec.sh "${instance_id}" < ./provision-db.sh -} +} >&2 echo instance_id="${instance_id}" From 042991dda27866432c3613e0ecf1a0b46f1eb9fa Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 07:59:33 +0900 Subject: [PATCH 021/147] show ipaddr. --- ciscripts/runner-app.sh | 1 + ciscripts/runner-db.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index 5b3fb80..bef5b0f 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -19,3 +19,4 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" } >&2 echo instance_id="${instance_id}" +echo ipaddr="${ipaddr}" diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh index 36cfc76..a901f85 100755 --- a/ciscripts/runner-db.sh +++ b/ciscripts/runner-db.sh @@ -20,3 +20,4 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" } >&2 echo instance_id="${instance_id}" +echo ipaddr="${ipaddr}" From 639ba3885610ddbecfeeac2272fad3b9303c9a0c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:03:35 +0900 Subject: [PATCH 022/147] specify user_data file path. --- ciscripts/create-app.sh | 4 +--- ciscripts/create-centos.sh | 4 +--- ciscripts/create-db.sh | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index e144012..becdc89 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -52,9 +52,7 @@ EOS # setup user_data.txt -user_data="user_data.txt" -cat < "${user_data}" -EOS +user_data="user_data_app.txt" # instance-specific parameter diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 8fda289..3ec2c79 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -52,9 +52,7 @@ EOS # setup user_data.txt -user_data="user_data.txt" -cat < "${user_data}" -EOS +user_data="user_data_centos.txt" # instance-specific parameter diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 5c080c1..8ae7c8f 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -52,9 +52,7 @@ EOS # setup user_data.txt -user_data="user_data.txt" -cat < "${user_data}" -EOS +user_data="user_data_db.txt" # instance-specific parameter From e023168873e04083dcc301275caa0e2b1727bb7f Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:06:38 +0900 Subject: [PATCH 023/147] generate user_data_app.txt. --- ciscripts/runner-db.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh index a901f85..9e948de 100755 --- a/ciscripts/runner-db.sh +++ b/ciscripts/runner-db.sh @@ -19,5 +19,10 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" ./instance-exec.sh "${instance_id}" < ./provision-db.sh } >&2 +{ + echo generating user_data_app.txt... + echo "DB_HOST=${ipaddr}" | tee user_data_app.txt +} >&2 + echo instance_id="${instance_id}" echo ipaddr="${ipaddr}" From d4e625d22a75d19cba303f073c2646d0adb23189 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:11:40 +0900 Subject: [PATCH 024/147] load user_data. --- ciscripts/provision-app.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 4951ef9..0021971 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -9,3 +9,8 @@ set -u set -x hostname + +if [[ -f /metadata/user-data ]]; then + . /metadata/user-data + fi +: "${DB_HOST:?"should not be empty"}" From e59de61c2734e7fdf3781f738cf174ee45afb158 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:19:11 +0900 Subject: [PATCH 025/147] debug user_data. --- ciscripts/provision-app.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 0021971..d996604 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -11,6 +11,7 @@ set -x hostname if [[ -f /metadata/user-data ]]; then + strings /metadata/user-data . /metadata/user-data - fi +fi : "${DB_HOST:?"should not be empty"}" From 95353e84abdeff171fd06faea07e1eedbe171031 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:23:41 +0900 Subject: [PATCH 026/147] fix create.sh path. --- ciscripts/runner-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index bef5b0f..44693c7 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -7,7 +7,7 @@ set -u set -x eval "$( - ./create-centos.sh + ./create-app.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR From d3c836b9a08b212c55144006f47e08395bf57bc9 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:24:18 +0900 Subject: [PATCH 027/147] use centos in app. --- ciscripts/create-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index becdc89..da66c80 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -59,7 +59,7 @@ user_data="user_data_app.txt" cpu_cores="1" hypervisor="kvm" memory_size="1024" -image_id="wmi-php1d64" +image_id="wmi-centos1d64" display_name="app" ssh_key_id="ssh-cicddemo" From 0f77cc8c97d5116864970d16828412dd8e3bd2f2 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:25:52 +0900 Subject: [PATCH 028/147] remove debug code. --- ciscripts/provision-app.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index d996604..1987919 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -11,7 +11,6 @@ set -x hostname if [[ -f /metadata/user-data ]]; then - strings /metadata/user-data . /metadata/user-data fi : "${DB_HOST:?"should not be empty"}" From 4106e8cfb87366178db0440953f2f79f963b7cdd Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:30:25 +0900 Subject: [PATCH 029/147] add myaddr.sh. --- ciscripts/myaddr.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 ciscripts/myaddr.sh diff --git a/ciscripts/myaddr.sh b/ciscripts/myaddr.sh new file mode 100755 index 0000000..405d5b9 --- /dev/null +++ b/ciscripts/myaddr.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# +# +set -e +set -o pipefail +set -u + +for i in $(/sbin/ip route get 8.8.8.8 | head -1); do echo ipaddr=${i}; done | tail -1 From 3664de3cac5feb863c54c7bda81f34761240037f Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:35:44 +0900 Subject: [PATCH 030/147] add parameter check. --- ciscripts/provision-app.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 1987919..f5865f7 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -14,3 +14,4 @@ if [[ -f /metadata/user-data ]]; then . /metadata/user-data fi : "${DB_HOST:?"should not be empty"}" +: "${YUM_HOST:?"should not be empty"}" From 90ca2248389aa87f2bdf9d4f4705d8b1d4f3b5ac Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:46:57 +0900 Subject: [PATCH 031/147] deploy repofile. --- ciscripts/runner-app.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index 44693c7..a41c7fb 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -15,6 +15,7 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" + ./instance-exec.sh "${instance_id}" "cat > /etc/yum.repos.d/example.repo" < ../rpmbuild/tiny-web-example.repo ./instance-exec.sh "${instance_id}" < ./provision-app.sh } >&2 From 15dc2b0aacc0a9e81195d31937c08df9deb81b4e Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:50:17 +0900 Subject: [PATCH 032/147] test repolist. --- ciscripts/provision-app.sh | 3 +++ ciscripts/runner-app.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index f5865f7..169abf8 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -15,3 +15,6 @@ if [[ -f /metadata/user-data ]]; then fi : "${DB_HOST:?"should not be empty"}" : "${YUM_HOST:?"should not be empty"}" + +ls -l /etc/yum.repos.d/tiny-web-example.repo +yum repolist diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index a41c7fb..b3028fa 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -15,7 +15,7 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" "cat > /etc/yum.repos.d/example.repo" < ../rpmbuild/tiny-web-example.repo + ./instance-exec.sh "${instance_id}" "cat > /etc/yum.repos.d/tiny-web-example.repo" < ../rpmbuild/tiny-web-example.repo ./instance-exec.sh "${instance_id}" < ./provision-app.sh } >&2 From 8a920819d3fc09538eaca9c05da0015f5edeefc1 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:53:28 +0900 Subject: [PATCH 033/147] replace yum rpeo host. --- ciscripts/provision-app.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 169abf8..1dd0f47 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -16,5 +16,6 @@ fi : "${DB_HOST:?"should not be empty"}" : "${YUM_HOST:?"should not be empty"}" -ls -l /etc/yum.repos.d/tiny-web-example.repo +[[ -f /etc/yum.repos.d/tiny-web-example.repo ]] +sed -i "s,127.0.0.1,${YUM_HOST}," /etc/yum.repos.d/tiny-web-example.repo yum repolist From 6b03e01899e4a8fdc7ed0d4c3eeb6fafad764ae3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 08:56:09 +0900 Subject: [PATCH 034/147] install rpm. --- ciscripts/provision-app.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 1dd0f47..acb681a 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -19,3 +19,5 @@ fi [[ -f /etc/yum.repos.d/tiny-web-example.repo ]] sed -i "s,127.0.0.1,${YUM_HOST}," /etc/yum.repos.d/tiny-web-example.repo yum repolist + +yum install -y tiny-web-example From fae4c33f31ac0c00ebd307f8b3e6cc0bee823cd9 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 09:00:03 +0900 Subject: [PATCH 035/147] install epel. --- ciscripts/provision-app.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index acb681a..f1e7eb5 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -20,4 +20,15 @@ fi sed -i "s,127.0.0.1,${YUM_HOST}," /etc/yum.repos.d/tiny-web-example.repo yum repolist +# tiny-web-example depends on epel to install nginx +rpm -qa epel-release* | egrep -q epel-release || { + rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm + sed -i \ + -e 's,^#baseurl,baseurl,' \ + -e 's,^mirrorlist=,#mirrorlist=,' \ + -e 's,http://download.fedoraproject.org/pub/epel/,http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/,' \ + /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo + yum install -y ca-certificates +} + yum install -y tiny-web-example From f7fbc78d51773273f5c56f7af1dda0950fc341ac Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 09:04:31 +0900 Subject: [PATCH 036/147] install ruby-2.0.0p598. --- ciscripts/provision-app.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index f1e7eb5..79d2542 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -31,4 +31,7 @@ rpm -qa epel-release* | egrep -q epel-release || { yum install -y ca-certificates } +# tiny-web-example requires ruby-2.0.0p598 +yum install -y http://dlc.wakame.axsh.jp/demo/ruby-rpm/rhel/6/x86_64/ruby-2.0.0p598-2.el6.x86_64.rpm + yum install -y tiny-web-example From 9f824a3657ab43a2dfb0028895069a48dd0b1e73 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 09:10:07 +0900 Subject: [PATCH 037/147] replace dbhost. --- ciscripts/provision-app.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 79d2542..7202bb5 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -35,3 +35,7 @@ rpm -qa epel-release* | egrep -q epel-release || { yum install -y http://dlc.wakame.axsh.jp/demo/ruby-rpm/rhel/6/x86_64/ruby-2.0.0p598-2.el6.x86_64.rpm yum install -y tiny-web-example + +# configure db +sed -i "s,localhost,${DB_HOST}," /etc/tiny-web-example/webapi.conf +cat /etc/tiny-web-example/webapi.conf From ffc504518b996fe17618e94981eaf11e0fc6673c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 19:26:58 +0900 Subject: [PATCH 038/147] fix image id. --- ciscripts/create-db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 8ae7c8f..86d20d4 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -59,7 +59,7 @@ user_data="user_data_db.txt" cpu_cores="1" hypervisor="kvm" memory_size="1024" -image_id="wmi-mysqld1d64" +image_id="wmi-mysql1d64" display_name="db" ssh_key_id="ssh-cicddemo" From 3e02a3a64863b4433aaa37a0f9d65bca2978f6a3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 19:39:43 +0900 Subject: [PATCH 039/147] use metadata. --- ciscripts/myaddr.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ciscripts/myaddr.sh b/ciscripts/myaddr.sh index 405d5b9..7373925 100755 --- a/ciscripts/myaddr.sh +++ b/ciscripts/myaddr.sh @@ -6,4 +6,9 @@ set -e set -o pipefail set -u -for i in $(/sbin/ip route get 8.8.8.8 | head -1); do echo ipaddr=${i}; done | tail -1 +# ip command: +# for i in $(/sbin/ip route get 8.8.8.8 | head -1); do echo ipaddr=${i}; done | tail -1 + +# metadata: +ipaddr="$(< /metadata/meta-data/local-ipv4)" +echo ipaddr="${ipaddr}" From 0d9ac22a8cc05565ddae6719c3dae929a5223870 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 20:00:35 +0900 Subject: [PATCH 040/147] add web3layers-ci.sh. --- ciscripts/web3layers-ci.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 ciscripts/web3layers-ci.sh diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh new file mode 100755 index 0000000..4208288 --- /dev/null +++ b/ciscripts/web3layers-ci.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +# myaddr + +eval "$(./myaddr.sh)" +yum_host="${ipaddr}" + +# run instances + +## db + +eval "$(./runner-db.sh)" +db_id="${instance_id}" +echo "YUM_HOST=${yum_host}" | tee -a user_data_app.txt + +## app + +eval "$(./runner-app.sh)" +app_id="${instance_id}" + +# cleanup instances + +./instance-kill.sh "${db_id}" +./instance-kill.sh "${app_id}" From ece4925c016aa4e232e57bff026c9df8b2e5635d Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Fri, 15 May 2015 20:05:17 +0900 Subject: [PATCH 041/147] add README.md. --- ciscripts/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ciscripts/README.md diff --git a/ciscripts/README.md b/ciscripts/README.md new file mode 100644 index 0000000..ff6eedb --- /dev/null +++ b/ciscripts/README.md @@ -0,0 +1,27 @@ +## Script Chain + +1. run `runner-app.sh` + 1. run `create-app.sh` + 2. run `provision-app.sh` + 3. generate `user_data_app.txt` +2. run `runner-db.sh` + 1. run `create-db.sh` + 2. run `provision-db.sh` + +## JenkinsCI + +Add the following code to JenkinsCI shell job. + +``` +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +cd ciscripts +ls -l +./web3layers-ci.sh +``` From 9c80891a3bcf15e76918536efed58006ae53844e Mon Sep 17 00:00:00 2001 From: t-iwano Date: Wed, 20 May 2015 18:23:48 +0900 Subject: [PATCH 042/147] Added Unit test README. --- webapi/spec/README.md | 114 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 webapi/spec/README.md diff --git a/webapi/spec/README.md b/webapi/spec/README.md new file mode 100644 index 0000000..01345f9 --- /dev/null +++ b/webapi/spec/README.md @@ -0,0 +1,114 @@ +# Unit Testの実行 + +# はじめに + +本書はUnit testを実行するために必要な環境構築手順です。 + +# 動作環境 + +CentOS-6.6にて動作確認を行いました。それよりも古い環境の場合は動作確認してませんので、ご了承下さい。 + +# Unit Test実行環境の構築 + +## mysql-serverの設定 + +Unit Testはデータベースアクセスを行うためmysql-serverのインストール及び設定を行います。 + +### mysql-serverのインストール + +``` +$ sudo yum install -y mysql-server +``` +### mysql-serverの起動 + +``` +$ sudo service mysqld start +``` + +### 自動起動設定 + +現在の設定を確認する + +``` +$ chkconfig --list mysqld +mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off +``` + +mysqldの自動起動設定を有効化する + +``` +$ sudo chkconfig mysqld on +``` + +有効化した設定を確認する + +``` +$ chkconfig --list mysqld +mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off +``` + +### データベースの作成 + +``` +$ mysqladmin -uroot create tiny_web_example +``` +## ruby環境の設定 + +Unit Testではrpecを使用するためruby環境のインストールを行います。 + +### rubyのインストール + +``` +$ sudo yum install -y http://dlc.wakame.axsh.jp.s3.amazonaws.com/demo/ruby-rpm/rhel/6/x86_64/ruby-2.0.0p598-2.el6.x86_64.rpm +``` + +### bundlerのインストール + +``` +$ sudo gem install bundler --no-ri --no-rdoc +``` + +### bundle install実行時に必要なパッケージのインストール + +``` +$ sudo yum install -y mysql-devel +``` + +## Unit Test実行環境の設定 + +### ソースコードの取得 + +Gitを使用してリポジトリからソースコードを取得してください。 + +``` +$ git clone https://github.com/axsh/tiny_web_example.git +``` + +### Gemパッケージのインストール + +``` +$ cd tiny_web_example/webapi +$ bundle install +``` + +### configファイルの設定 + +``` +$ cd tiny_web_example/webapi/config +$ cp webapi.conf.example webapi.conf +``` + +### データベーステーブルの作成 + +``` +$ cd tiny_web_example/webapi +$ bundle exec rake db:up +``` + +## Unit Testの実行 + +``` +$ cd tiny_web_example/webapi/spec +$ cp webapi.conf.example webapi.conf +$ bundle exec rspec ./comment_spec.rb +``` From cc4071037e0b7b458ca87490239430b3e9eb40a2 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Wed, 20 May 2015 18:27:02 +0900 Subject: [PATCH 043/147] Update Unit test README. --- webapi/spec/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapi/spec/README.md b/webapi/spec/README.md index 01345f9..6042a06 100644 --- a/webapi/spec/README.md +++ b/webapi/spec/README.md @@ -96,6 +96,8 @@ $ bundle install ``` $ cd tiny_web_example/webapi/config $ cp webapi.conf.example webapi.conf +$ cd tiny_web_example/webapi/spec +$ cp webapi.conf.example webapi.conf ``` ### データベーステーブルの作成 @@ -109,6 +111,5 @@ $ bundle exec rake db:up ``` $ cd tiny_web_example/webapi/spec -$ cp webapi.conf.example webapi.conf $ bundle exec rspec ./comment_spec.rb ``` From 264518d67485e1c11bb568a189afaf4db3f78632 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Thu, 21 May 2015 20:40:07 +0900 Subject: [PATCH 044/147] Added tiny web example README. --- README.md | 548 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 548 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c75d14a --- /dev/null +++ b/README.md @@ -0,0 +1,548 @@ +# Tiny Web Example + +# はじめに + +tiny_web_exampleはwebapiとfrontendからなる小規模な教材用アプリケーションです。 + +本書ではアプリケーションの実行に必要なパッケージのインストール手順と設定方法を記述しています。 + +テストやパッケージ作成方法については以下のディレクトリを参照してください。 + +> UnitTest: tiny_web_example/webapi/spec/README.md +> IntegrationTest: tiny_web_example/spec_integration/README.md +> RPMBuild: tiny_web_example/rpmbuild/README.md + +また以下の作業はrootユーザーで行ってください。 + +# 動作環境 + +CentOS-6.6にて動作確認を行いました。それよりも古い場合は動作確認していませんので、ご了承ください。 + +# インストール + +## epel環境の構築 + +tiny_web_exampleはmysql-serverとnginxを使用します。nginxはCentOSのBaseリポジトリには存在しないので、EPELリポジトリを利用してインストールします。 + +### epel-releaseのインストール + +``` +# rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm +``` + +実行結果例: +``` +# rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm +Retrieving http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm +warning: /var/tmp/rpm-tmp.AFsABI: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY +Preparing... ########################################### [100%] + 1:epel-release ########################################### [100%] +``` + +### リポジトリリストの確認 + +epelリポジトリが有効になったことを確認します。 + +``` +# yum repolist +``` + +実行結果例: +``` +# yum repolist +Loaded plugins: fastestmirror +Loading mirror speeds from cached hostfile + * base: ftp.yz.yamagata-u.ac.jp + * epel: ftp.tsukuba.wide.ad.jp + * extras: ftp.yz.yamagata-u.ac.jp + * updates: ftp.yz.yamagata-u.ac.jp +repo id repo name status +base CentOS-6.6 - Base 6,518 +*epel Extra Packages for Enterprise Linux 6 - x86_64 11,557 +extras CentOS-6.6 - Extras 38 +updates CentOS-6.6 - Updates 1,134 +repolist: 19,247 +``` + +epelが表示されていれば、epelリポジトリは有効です。 + +## ruby環境のインストール + +tiny_web_exampleはアプリケーションの動作にruby環境が必要です。ここではrbenvを使用してrubyとbundlerのインストールを行います。 + +### rbenvのインストール +``` +# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +``` + +実行結果例: +``` +# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +Initialized empty Git repository in /root/.rbenv/.git/ +remote: Counting objects: 2057, done. +remote: Total 2057 (delta 0), reused 0 (delta 0), pack-reused 2057 +Receiving objects: 100% (2057/2057), 344.17 KiB | 74 KiB/s, done. +Resolving deltas: 100% (1272/1272), done. +``` + +### rbenvの設定 +``` +# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile +# exec $SHELL -l +``` + +### ruby-buildのインストール + +``` +# git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +``` + +実行結果例: +``` +# git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +Initialized empty Git repository in /root/.rbenv/plugins/ruby-build/.git/ +remote: Counting objects: 4530, done. +remote: Total 4530 (delta 0), reused 0 (delta 0), pack-reused 4530 +Receiving objects: 100% (4530/4530), 847.84 KiB | 70 KiB/s, done. +Resolving deltas: 100% (2344/2344), done. +``` + +### rubyのインストール + +``` +# rbenv install -v 2.0.0-p598 +``` + +実行結果例: +``` +``` + +### rbenvの再読み込み + +``` +# rbenv rehash +``` + +### rubyの設定 + +現在インストールされているrubyのバージョン一覧を確認する +``` +# rbenv versions +``` + +実行結果例: +``` +# rbenv versions + 2.0.0-p598 +``` + +### 使用するrubyのバージョンを設定する +``` +# rbenv global 2.0.0-p598 +# ruby -v +``` + +実行結果例: +``` +# ruby -v +ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux] +``` + +### bundlerのインストール +``` +# gem install bundler --no-ri --no-rdoc +``` + +実行結果例: +``` +# gem install bundler --no-ri --no-rdoc +Fetching: bundler-1.9.9.gem (100%) +Successfully installed bundler-1.9.9 +1 gem installed +``` + +## Yumを使ったインストール + +すでにRPMパッケージとリポジトリを作成済みの方はYumによるインストールを推奨します。 + +### repoファイルの作成 +``` +# curl -fsSkL \ +> https://raw.githubusercontent.com/axsh/tiny_web_example/master/rpmbuild/tiny-web-example.repo +> -o /etc/yum.repos.d/tiny-web-example.repo +``` + +### baseurlの修正 + +baseurlを作成したリポジトリのあるサーバーのIPアドレスに変更します。 +``` +# vi /etc/yum.repos.d/tiny-web-example.repo +``` + +実行結果例: +``` +[tiny-web-example] +name=tiny-web-example +baseurl=http://10.0.22.100/pub/ +enabled=1 +gpgcheck=0 +``` + +### tiny_web_exampleのインストール +``` +# yum install -y tiny-web-example +``` + +実行結果例: + +## Gitを使用したインストール + +### ソースコードの取得 + +``` +# git clone https://github.com/axsh/tiny_web_example.git +# mkdir -p /opt/axsh +# mv -i tiny_web_example /opt/axsh/tiny-web-example +``` + +実行結果例: +``` +# git clone https://github.com/axsh/tiny_web_example.git +Initialized empty Git repository in /home/vagrant/tiny_web_example/.git/ +remote: Counting objects: 295, done. +remote: Compressing objects: 100% (10/10), done. +remote: Total 295 (delta 3), reused 0 (delta 0), pack-reused 285 +Receiving objects: 100% (295/295), 288.04 KiB | 165 KiB/s, done. +Resolving deltas: 100% (105/105), done. +# mkdir -p /opt/axsh +# mv -i tiny_web_example /opt/axsh +``` + +### 依存パッケージのインストール + +``` +# yum install -y nginx mysql-server mysql-devel +``` + + +実行結果例: +``` +# yum install -y nginx mysql-server mysql-devel +Loaded plugins: fastestmirror +Setting up Install Process +Loading mirror speeds from cached hostfile + * base: ftp.jaist.ac.jp + * extras: ftp.jaist.ac.jp + * updates: ftp.jaist.ac.jp +No package nginx available. +Resolving Dependencies +--> Running transaction check +___(省略)___ + +Installed: + mysql-devel.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 + +Dependency Installed: + keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 + libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 + libsepol-devel.x86_64 0:2.0.41-4.el6 mysql.x86_64 0:5.1.73-3.el6_5 + openssl-devel.x86_64 0:1.0.1e-30.el6.8 perl-DBD-MySQL.x86_64 0:4.013-3.el6 + perl-DBI.x86_64 0:1.609-4.el6 zlib-devel.x86_64 0:1.2.3-29.el6 + +Complete! +``` + +### gemパッケージのインストール + +webapiで使用するgemをインストールする +``` +# cd /opt/axsh/tiny_web_example/webapi +# bundle install +``` + +実行結果例: +``` +# bundle install +Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root +will break this application for all non-root users on this machine. +Fetching gem metadata from https://rubygems.org/......... +Fetching version metadata from https://rubygems.org/.. +Resolving dependencies... +Installing rake 10.4.2 +Installing backports 3.6.4 +Using bundler 1.9.9 +Installing diff-lcs 1.2.5 +Installing fuguta 1.0.4 +Installing get_process_mem 0.2.0 +Installing kgio 2.9.3 +Installing multi_json 1.11.0 +Installing mysql2 0.3.18 +Installing rack 1.6.1 +Installing rack-cors 0.4.0 +Installing rack-protection 1.5.3 +Installing rack-test 0.6.3 +Installing raindrops 0.13.0 +Installing rspec-support 3.2.2 +Installing rspec-core 3.2.3 +Installing rspec-expectations 3.2.1 +Installing rspec-mocks 3.2.1 +Installing rspec 3.2.0 +Installing sequel 4.22.0 +Installing tilt 1.4.1 +Installing sinatra 1.4.6 +Installing sinatra-contrib 1.4.2 +Installing unicorn 4.9.0 +Installing unicorn-worker-killer 0.4.3 +Bundle complete! 11 Gemfile dependencies, 25 gems now installed. +Bundled gems are installed into ./vendor/bundle. +``` + +frontendで使用するgemをインストールする +``` +# cd /opt/axsh/tiny_web_example/webapi +# bundle install +``` + +実行結果例: +``` +# bundle install +Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root +will break this application for all non-root users on this machine. +Fetching gem metadata from https://rubygems.org/.......... +Fetching version metadata from https://rubygems.org/.. +Resolving dependencies... +Installing backports 3.6.4 +Using bundler 1.9.9 +Installing get_process_mem 0.2.0 +Installing kgio 2.9.3 +Installing multi_json 1.11.0 +Installing mysql2 0.3.18 +Installing rack 1.6.1 +Installing rack-protection 1.5.3 +Installing rack-test 0.6.3 +Installing raindrops 0.13.0 +Installing sequel 4.22.0 +Installing tilt 1.4.1 +Installing sinatra 1.4.6 +Installing sinatra-contrib 1.4.2 +Installing unicorn 4.9.0 +Installing unicorn-worker-killer 0.4.3 +Bundle complete! 7 Gemfile dependencies, 16 gems now installed. +Bundled gems are installed into ./vendor/bundle. +``` + +### 起動スクリプトの配置 +``` +# cd /opt/axsh/tiny_web_example/contrib/etc +# cp default/* /etc/default/ +# cp init/* /etc/init/ +``` + +### configファイルの配置 +``` +# mkdir -p /etc/tiny-web-example +# cp tiny-web-example/* /etc/tiny-web-example/ +``` + +### logディレクトリの作成 +``` +# mkdir -p /var/log/tiny-web-example +``` + +# 設定 + +## 起動スクリプトの設定 + +webapiの起動スクリプトを修正する +``` +# vi /etc/default/tiny-web-example-webapi +``` + +実行結果例: +``` +# tiny-web-example +EXAMPLE_ROOT=/opt/axsh/tiny-web-example +PATH=/root/.rbenv/shims:$PATH + +# Commnet out to run the vdc init script. +#RUN=yes + +## rack params +RACK_ENV=development +BIND_ADDR=0.0.0.0 +PORT=8080 +UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf +``` + +frontendの起動スクリプトを修正する +``` +# vi /etc/default/tiny-web-example-webapp +``` + +実行結果例: +``` +# tiny-web-example +EXAMPLE_ROOT=/opt/axsh/tiny-web-example +PATH=/root/.rbenv/shims:$PATH + +# Commnet out to run the vdc init script. +#RUN=yes + +## rack params +RACK_ENV=development +BIND_ADDR=0.0.0.0 +PORT=80 +UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf +``` + +## configファイルの設定 + +webapiとfrontendが接続するDatabaseのアドレスを記述します + +webapi.confの修正 +``` +# vi /etc/tiny-web-example/webapi.conf +``` + +実行結果例: +``` +# Database connection string +database_uri 'mysql2://localhost/tiny_web_example?user=root' +``` + +webapp.ymlの修正 +``` +# vi /etc/tiny-web-example/webapp.yml +``` + +実行結果例: +``` +database_uri: 'mysql2://localhost/tiny_web_example?user=root' +``` + +## mysqldの起動 +``` +# service mysqld start +``` + +実行結果例: +``` +Initializing MySQL database: WARNING: The host 'vagrant-centos6' could not be looked up with resolveip. +This probably means that your libc libraries are not 100 % compatible +with this binary MySQL version. The MySQL daemon, mysqld, should work +normally with the exception that host name resolving will not work. +This means that you should use IP addresses instead of hostnames +when specifying MySQL privileges ! +Installing MySQL system tables... +OK +Filling help tables... +OK + +To start mysqld at boot time you have to copy +support-files/mysql.server to the right place for your system + +PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! +To do so, start the server, then issue the following commands: + +/usr/bin/mysqladmin -u root password 'new-password' +/usr/bin/mysqladmin -u root -h vagrant-centos6 password 'new-password' + +Alternatively you can run: +/usr/bin/mysql_secure_installation + +which will also give you the option of removing the test +databases and anonymous user created by default. This is +strongly recommended for production servers. + +See the manual for more instructions. + +You can start the MySQL daemon with: +cd /usr ; /usr/bin/mysqld_safe & + +You can test the MySQL daemon with mysql-test-run.pl +cd /usr/mysql-test ; perl mysql-test-run.pl + +Please report any problems with the /usr/bin/mysqlbug script! + + [ OK ] +Starting mysqld: [ OK ] +``` + +## DataBaseの作成 +``` +# mysqladmin create tiny_web_example +``` + +## DataBaseTableの作成 +``` +# cd /opt/axsh/tiny-web-example/webapi/ +# bundle exec rake db:up +``` + +# アプリケーションの実行 + +## webapiの起動 +``` +# initctl start tiny-web-example-webapi RUN=yes +``` + +実行結果例: +``` +# initctl start tiny-web-example-webapi RUN=yes +tiny-web-example-webapi start/running, process 2996 +``` + +## frontendの起動 +``` +# initctl start tiny-web-example-webapp RUN=yes +``` + +実行結果例: +``` +# initctl start tiny-web-example-webapp RUN=yes +tiny-web-example-webapp start/running, process 2988 +``` + +# アプリケーションの動作確認 + +## webapiの確認 + +POSTの確認 +``` +# curl -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' http://localhost:8080/api/0.0.1/comments +``` + +実行結果例: +``` +{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} +``` + +GETの確認(list) +``` +# curl -X GET http://localhost:8080/api/0.0.1/comments +``` + +実行結果例: +``` +[{"total":2,"results":[{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"},{"id":2,"display_name":"webapi test","comment":"sample message 2.","created_at":"2015-05-21 11:19:04 UTC","updated_at":"2015-05-21 11:19:04 UTC"}]}] +``` + +GETの確認(show) +``` +# curl -X GET http://localhost:8080/api/0.0.1/comments/1 +``` + +実行結果例: +``` +{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} +``` + +## frontendの確認 + +Webブラウザからアクセスすると以下のような画面が表示されます + +![sample_bbs](https://cloud.githubusercontent.com/assets/380254/7747443/675f3c94-fff5-11e4-9d03-4eb74a2c68e1.png) + +NameとCommentを入れて動作するか確認してみましょう + From e5658f4b4b16d99890d56ff0d13e91f3f5fadf6d Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 15:08:35 +0900 Subject: [PATCH 045/147] Fixed list information. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c75d14a..0694bbb 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ tiny_web_exampleはwebapiとfrontendからなる小規模な教材用アプリ テストやパッケージ作成方法については以下のディレクトリを参照してください。 -> UnitTest: tiny_web_example/webapi/spec/README.md -> IntegrationTest: tiny_web_example/spec_integration/README.md -> RPMBuild: tiny_web_example/rpmbuild/README.md +* UnitTest: tiny_web_example/webapi/spec/README.md +* IntegrationTest: tiny_web_example/spec_integration/README.md +* RPMBuild: tiny_web_example/rpmbuild/README.md また以下の作業はrootユーザーで行ってください。 From da2387aea4e23e0840a67f2bc3a289e721db5828 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 16:19:57 +0900 Subject: [PATCH 046/147] Update tiny web example README. --- README.md | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0694bbb..56c16c5 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,39 @@ Resolving deltas: 100% (1272/1272), done. # exec $SHELL -l ``` +### ruby-buildに必要なパッケージのインストール +``` +# yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel +``` + +実行結果例: +``` +# yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel +Loaded plugins: fastestmirror +Setting up Install Process +Loading mirror speeds from cached hostfile + * base: ftp.jaist.ac.jp + * epel: ftp.jaist.ac.jp + * extras: ftp.jaist.ac.jp + * updates: ftp.jaist.ac.jp +Package gcc-4.4.7-11.el6.x86_64 already installed and latest version +Resolving Dependencies +__(省略)__ + +Installed: + gdbm-devel.x86_64 0:1.8.0-36.el6 libffi-devel.x86_64 0:3.0.5-3.2.el6 + libyaml-devel.x86_64 0:0.1.3-4.el6_6 ncurses-devel.x86_64 0:5.7-3.20090208.el6 + openssl-devel.x86_64 0:1.0.1e-30.el6.8 readline-devel.x86_64 0:6.0-4.el6 + zlib-devel.x86_64 0:1.2.3-29.el6 + +Dependency Installed: + keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 + libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 + libsepol-devel.x86_64 0:2.0.41-4.el6 libyaml.x86_64 0:0.1.3-4.el6_6 + +Complete! +``` + ### ruby-buildのインストール ``` @@ -116,6 +149,31 @@ Resolving deltas: 100% (2344/2344), done. 実行結果例: ``` +# rbenv install -v 2.0.0-p598 +/tmp/ruby-build.20150522151700.11775 ~ +Downloading ruby-2.0.0-p598.tar.gz... +HTTP/1.1 200 OK +Content-Type: binary/octet-stream +Content-Length: 13608640 +Connection: keep-alive +Date: Mon, 11 May 2015 13:57:49 GMT +Last-Modified: Thu, 13 Nov 2014 14:55:37 GMT +ETag: "e043a21ce0d138fd408518a80aa31bba" +Accept-Ranges: bytes +Server: AmazonS3 +X-Cache: RefreshHit from cloudfront +Via: 1.1 4565d1650806ee8cdd757034d90ec07d.cloudfront.net (CloudFront) +X-Amz-Cf-Id: gn8DN0xoqLLljcQTklcAR2DABrq7vHhhqsmc2KrZ5Plkwtvpqz8_RA== + +-> http://dqw8nmjcqpjn7.cloudfront.net/4136bf7d764cbcc1c7da2824ed2826c3550f2b62af673c79ddbf9049b12095fd +Installing ruby-2.0.0-p598... +/tmp/ruby-build.20150522151700.11775/ruby-2.0.0-p598 /tmp/ruby-build.20150522151700.11775 ~ +__(省略)__ + +Installed ruby-2.0.0-p598 to /root/.rbenv/versions/2.0.0-p598 + +/tmp/ruby-build.20150522152934.22095 ~ +~ ``` ### rbenvの再読み込み @@ -169,7 +227,7 @@ Successfully installed bundler-1.9.9 ### repoファイルの作成 ``` # curl -fsSkL \ -> https://raw.githubusercontent.com/axsh/tiny_web_example/master/rpmbuild/tiny-web-example.repo +> https://raw.githubusercontent.com/axsh/tiny_web_example/master/rpmbuild/tiny-web-example.repo \ > -o /etc/yum.repos.d/tiny-web-example.repo ``` @@ -195,6 +253,48 @@ gpgcheck=0 ``` 実行結果例: +``` +# yum install -y tiny-web-example +Loaded plugins: fastestmirror +Setting up Install Process +Loading mirror speeds from cached hostfile +epel/metalink | 5.0 kB 00:00 + * base: ftp.jaist.ac.jp + * epel: ftp.jaist.ac.jp + * extras: ftp.jaist.ac.jp + * updates: ftp.jaist.ac.jp +base | 3.7 kB 00:00 +base/primary_db | 4.6 MB 00:00 +epel | 4.4 kB 00:00 +epel/primary_db | 6.5 MB 00:00 +extras | 3.4 kB 00:00 +extras/primary_db | 31 kB 00:00 +tiny-web-example | 2.9 kB 00:00 +tiny-web-example/primary_db | 3.7 kB 00:00 +updates | 3.4 kB 00:00 +updates/primary_db | 3.3 MB 00:00 +Resolving Dependencies +__(省略)__ + +Installed: + tiny-web-example.x86_64 0:0.0.1-1.daily.el6 + +Dependency Installed: + GeoIP.x86_64 0:1.6.5-1.el6 GeoIP-GeoLite-data.noarch 0:2015.04-2.el6 + GeoIP-GeoLite-data-extra.noarch 0:2015.04-2.el6 compat-readline5.x86_64 0:5.2-17.1.el6 + fontconfig.x86_64 0:2.8.0-5.el6 freetype.x86_64 0:2.3.11-15.el6_6.1 + gd.x86_64 0:2.0.35-11.el6 geoipupdate.x86_64 0:2.2.1-2.el6 + libX11.x86_64 0:1.6.0-2.2.el6 libX11-common.noarch 0:1.6.0-2.2.el6 + libXau.x86_64 0:1.0.6-4.el6 libXpm.x86_64 0:3.5.10-2.el6 + libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 libpng.x86_64 2:1.2.49-1.el6_2 + libxcb.x86_64 0:1.9.1-2.el6 libxslt.x86_64 0:1.1.26-2.el6_3.1 + mysql.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 + nginx.x86_64 0:1.0.15-11.el6 nginx-filesystem.noarch 0:1.0.15-11.el6 + perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 + ruby.x86_64 0:1.8.7.374-4.el6_6 ruby-libs.x86_64 0:1.8.7.374-4.el6_6 + +Complete! +``` ## Gitを使用したインストール From 88898f6f135e729882ed016daa320059e53a3ab1 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 16:54:42 +0900 Subject: [PATCH 047/147] Fixed directory path. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56c16c5..a63cee1 100644 --- a/README.md +++ b/README.md @@ -357,7 +357,7 @@ Complete! webapiで使用するgemをインストールする ``` -# cd /opt/axsh/tiny_web_example/webapi +# cd /opt/axsh/tiny-web-example/webapi # bundle install ``` @@ -400,7 +400,7 @@ Bundled gems are installed into ./vendor/bundle. frontendで使用するgemをインストールする ``` -# cd /opt/axsh/tiny_web_example/webapi +# cd /opt/axsh/tiny-web-example/frontend # bundle install ``` @@ -434,7 +434,7 @@ Bundled gems are installed into ./vendor/bundle. ### 起動スクリプトの配置 ``` -# cd /opt/axsh/tiny_web_example/contrib/etc +# cd /opt/axsh/tiny-web-example/contrib/etc # cp default/* /etc/default/ # cp init/* /etc/init/ ``` From 7e426876a874f93d76c1ae715d551f05cff6831f Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 17:07:36 +0900 Subject: [PATCH 048/147] Remove duplication information. --- webapi/spec/README.md | 110 +++++------------------------------------- 1 file changed, 12 insertions(+), 98 deletions(-) diff --git a/webapi/spec/README.md b/webapi/spec/README.md index 6042a06..db1bc55 100644 --- a/webapi/spec/README.md +++ b/webapi/spec/README.md @@ -1,115 +1,29 @@ -# Unit Testの実行 +# Unit Test # はじめに -本書はUnit testを実行するために必要な環境構築手順です。 +本書はUnit testの実行方法を記述しています。 + +また以下の作業はrootユーザーで行ってください。 # 動作環境 CentOS-6.6にて動作確認を行いました。それよりも古い環境の場合は動作確認してませんので、ご了承下さい。 -# Unit Test実行環境の構築 - -## mysql-serverの設定 - -Unit Testはデータベースアクセスを行うためmysql-serverのインストール及び設定を行います。 - -### mysql-serverのインストール - -``` -$ sudo yum install -y mysql-server -``` -### mysql-serverの起動 - -``` -$ sudo service mysqld start -``` - -### 自動起動設定 - -現在の設定を確認する - -``` -$ chkconfig --list mysqld -mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off -``` - -mysqldの自動起動設定を有効化する - -``` -$ sudo chkconfig mysqld on -``` - -有効化した設定を確認する - -``` -$ chkconfig --list mysqld -mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off -``` - -### データベースの作成 - -``` -$ mysqladmin -uroot create tiny_web_example -``` -## ruby環境の設定 +# 前提条件 -Unit Testではrpecを使用するためruby環境のインストールを行います。 +トップページのREADME.md (Tiny Web Example)を読み環境構築が完了していること。 -### rubyのインストール +# configファイルの設定 ``` -$ sudo yum install -y http://dlc.wakame.axsh.jp.s3.amazonaws.com/demo/ruby-rpm/rhel/6/x86_64/ruby-2.0.0p598-2.el6.x86_64.rpm +# cd /opt/axsh/tiny-web-example/webapi/spec +# cp webapi.conf.example webapi.conf ``` -### bundlerのインストール - -``` -$ sudo gem install bundler --no-ri --no-rdoc -``` - -### bundle install実行時に必要なパッケージのインストール - -``` -$ sudo yum install -y mysql-devel -``` - -## Unit Test実行環境の設定 - -### ソースコードの取得 - -Gitを使用してリポジトリからソースコードを取得してください。 - -``` -$ git clone https://github.com/axsh/tiny_web_example.git -``` - -### Gemパッケージのインストール - -``` -$ cd tiny_web_example/webapi -$ bundle install -``` - -### configファイルの設定 - -``` -$ cd tiny_web_example/webapi/config -$ cp webapi.conf.example webapi.conf -$ cd tiny_web_example/webapi/spec -$ cp webapi.conf.example webapi.conf -``` - -### データベーステーブルの作成 - -``` -$ cd tiny_web_example/webapi -$ bundle exec rake db:up -``` - -## Unit Testの実行 +# Unit Testの実行 ``` -$ cd tiny_web_example/webapi/spec -$ bundle exec rspec ./comment_spec.rb +# cd /opt/axsh/tiny-web-example/webapi/spec +# bundle exec rspec ./comment_spec.rb ``` From 36e630bc1732c7b2380dd8fc5dec63d36a337aad Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 17:21:58 +0900 Subject: [PATCH 049/147] Added Configure database uri. --- webapi/spec/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webapi/spec/README.md b/webapi/spec/README.md index db1bc55..5d4e7fb 100644 --- a/webapi/spec/README.md +++ b/webapi/spec/README.md @@ -21,6 +21,17 @@ CentOS-6.6にて動作確認を行いました。それよりも古い環境の # cp webapi.conf.example webapi.conf ``` +DataBaseのIPアドレスを記述します +``` +# vi webapi.conf +``` + +実行結果例: +``` +# Database connection string +database_uri 'mysql2://localhost/tiny_web_example?user=root' +``` + # Unit Testの実行 ``` From 17389e714f25bb0157050ecf846947b285da6f38 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 17:22:27 +0900 Subject: [PATCH 050/147] Added Integration test README. --- spec_integration/README.md | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 spec_integration/README.md diff --git a/spec_integration/README.md b/spec_integration/README.md new file mode 100644 index 0000000..c8a5740 --- /dev/null +++ b/spec_integration/README.md @@ -0,0 +1,78 @@ +# Integration Test + +# はじめに + +本書はIntegration testの実行方法を記述しています。 + +また以下の作業はrootユーザーで行ってください。 + +# 動作環境 + +CentOS-6.6にて動作確認を行いました。それよりも古い環境の場合は動作確認してませんので、ご了承下さい。 + +# 前提条件 + +トップページのREADME.md (Tiny Web Example)を読み環境構築が完了していること。 + +# Gemのインストール +``` +# cd /opt/axsh/tiny-web-example/spec_integration +# bundle install +``` + +実行結果例: +``` +# bundle install +Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all +non-root users on this machine. +Fetching gem metadata from https://rubygems.org/......... +Fetching version metadata from https://rubygems.org/.. +Resolving dependencies... +Using bundler 1.9.9 +Installing diff-lcs 1.2.5 +Installing rspec-support 3.2.2 +Installing rspec-core 3.2.3 +Installing rspec-expectations 3.2.1 +Installing rspec-mocks 3.2.1 +Installing rspec 3.2.0 +Bundle complete! 2 Gemfile dependencies, 7 gems now installed. +Bundled gems are installed into ./vendor/bundle. +``` + +# Configの設定 +``` +# cd /opt/axsh/tiny-web-example/spec_integration/config +# cp webapi.conf.example webapi.conf +``` + +webapiに接続するDataBaseのIPアドレスを記述します +``` +# vi webapi.conf +``` + +実行結果例: +``` +uri: 'http://localhost:8080' +``` + +# Integration Testの実行 +``` +# cd /opt/axsh/tiny-web-example/spec_integration +# bundle exec rspec ./spec/webapi_integration_spec.rb +``` + +実行結果例: +``` +# bundle exec rspec ./spec/webapi_integration_spec.rb + +Webapi Integration spec + post + create a new comment + get + show list for the comments + show detail the comment + +Finished in 0.04481 seconds (files took 0.15042 seconds to load) +3 examples, 0 failures + +``` From 6f50be93214ef631d96b9112c74963c80419707e Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 18:46:37 +0900 Subject: [PATCH 051/147] Added rpmbuild README. --- rpmbuild/README.md | 122 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 rpmbuild/README.md diff --git a/rpmbuild/README.md b/rpmbuild/README.md new file mode 100644 index 0000000..869dceb --- /dev/null +++ b/rpmbuild/README.md @@ -0,0 +1,122 @@ +# RPM Build + +# はじめに + +本書ではtiny-web-exampleのRPMパッケージ作成手順を記述しています。 + +また以下の作業はrootユーザーで行ってください。 + +# 動作環境 + +CentOS-6.6にて動作確認を行いました。それよりも古い環境の場合は動作確認してませんので、ご了承下さい。 + +# 前提条件 + +トップページのREADME.md (Tiny Web Example)を読み環境構築が完了していること。 + +# rpmbuild環境の構築 + +rpmをビルドするために必要なパッケージをインストールします +``` +# yum install -y rpm-build rpmlint yum-utils +``` + +実行結果例: +``` +# yum install -y rpm-build rpmlint yum-utils +Loaded plugins: fastestmirror +Setting up Install Process +Loading mirror speeds from cached hostfile + * base: mirror.fairway.ne.jp + * epel: ftp.iij.ad.jp + * extras: mirror.fairway.ne.jp + * updates: mirror.fairway.ne.jp +Resolving Dependencies +__(省略)__ + +Installed: + rpm-build.x86_64 0:4.8.0-38.el6_6 rpmlint.noarch 0:0.94-3.1.el6 yum-utils.noarch 0:1.1.30-30.el6 + +Dependency Installed: + desktop-file-utils.x86_64 0:0.15-9.el6 elfutils.x86_64 0:0.158-3.2.el6 enchant.x86_64 1:1.5.0-4.el6 gdb.x86_64 0:7.2-75.el6 + hunspell.x86_64 0:1.2.8-16.el6 patch.x86_64 0:2.6-6.el6 python-enchant.x86_64 0:1.3.1-5.2.el6 python-magic.x86_64 0:5.04-21.el6 + unzip.x86_64 0:6.0-2.el6_6 + +Complete! +``` + +# ソースコードの取得 +``` +# git clone https://github.com/axsh/tiny_web_example.git +``` + +実行結果例: +``` +# git clone https://github.com/axsh/tiny_web_example.git +Initialized empty Git repository in /root/tiny_web_example/.git/ +remote: Counting objects: 307, done. +remote: Compressing objects: 100% (22/22), done. +Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. +remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 +Resolving deltas: 100% (112/112), done. +``` + + +# 依存関係のインストール +``` +# cd tiny_web_example +# yum-builddep ./rpmbuild/SPECS/tiny-web-example.spec +``` + +実行結果例: +``` +# yum-builddep ./rpmbuild/SPECS/tiny-web-example.spec +Loaded plugins: fastestmirror +Enabling epel-source repository +Loading mirror speeds from cached hostfile +epel-source/metalink | 5.0 kB 00:00 + * base: mirror.fairway.ne.jp + * epel: ftp.iij.ad.jp + * epel-source: ftp.iij.ad.jp + * extras: mirror.fairway.ne.jp + * updates: mirror.fairway.ne.jp +epel-source | 3.7 kB 00:00 +epel-source/primary_db | 1.8 MB 00:00 +Getting requirements for ./rpmbuild/SPECS/tiny-web-example.spec + --> Already installed : mysql-devel-5.1.73-3.el6_5.x86_64 +No uninstalled build requires +``` + +# rpmbuildの実行 +``` +rpmbuild -bb ./rpmbuild/SPECS/tiny-web-example.spec +``` + +実行結果例: +``` +# rpmbuild -bb ./rpmbuild/SPECS/tiny-web-example.spec +Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.w7wyVS ++ umask 022 ++ cd /root/rpmbuild/BUILD ++ '[' -d tiny-web-example-0.0.1 ']' ++ git clone git://github.com/axsh/tiny_web_example.git tiny-web-example-0.0.1 +Initialized empty Git repository in /root/rpmbuild/BUILD/tiny-web-example-0.0.1/.git/ +remote: Counting objects: 307, done. +remote: Compressing objects: 100% (22/22), done. +remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 +Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. +Resolving deltas: 100% (112/112), done. +__(省略)__ + ++ umask 022 ++ cd /root/rpmbuild/BUILD ++ cd tiny-web-example-0.0.1 ++ RUBYDIR=/usr/bin/ruby ++ rpmbuild/rules clean +rm -rf /root/rpmbuild/BUILD/tiny-web-example-0.0.1/vendor/bundle +rm -f /root/rpmbuild/BUILD/tiny-web-example-0.0.1/bundle-install-stamp +rm -f build-stamp ++ rm -rf /root/rpmbuild/BUILDROOT/tiny-web-example-0.0.1-1.daily.el6.x86_64 ++ exit 0 +``` + From 4937fabb0930b952165e029fef3da4654e5108e6 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 19:33:28 +0900 Subject: [PATCH 052/147] Added quote. --- README.md | 588 ++++++++++++++++++------------------- rpmbuild/README.md | 148 +++++----- spec_integration/README.md | 62 ++-- 3 files changed, 399 insertions(+), 399 deletions(-) diff --git a/README.md b/README.md index a63cee1..0a8153d 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ tiny_web_exampleはmysql-serverとnginxを使用します。nginxはCentOSのBas ``` 実行結果例: -``` -# rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm -Retrieving http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm -warning: /var/tmp/rpm-tmp.AFsABI: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY -Preparing... ########################################### [100%] - 1:epel-release ########################################### [100%] -``` +>``` +># rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm +>Retrieving http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm +>warning: /var/tmp/rpm-tmp.AFsABI: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY +>Preparing... ########################################### [100%] +> 1:epel-release ########################################### [100%] +>``` ### リポジトリリストの確認 @@ -48,21 +48,21 @@ epelリポジトリが有効になったことを確認します。 ``` 実行結果例: -``` -# yum repolist -Loaded plugins: fastestmirror -Loading mirror speeds from cached hostfile - * base: ftp.yz.yamagata-u.ac.jp - * epel: ftp.tsukuba.wide.ad.jp - * extras: ftp.yz.yamagata-u.ac.jp - * updates: ftp.yz.yamagata-u.ac.jp -repo id repo name status -base CentOS-6.6 - Base 6,518 -*epel Extra Packages for Enterprise Linux 6 - x86_64 11,557 -extras CentOS-6.6 - Extras 38 -updates CentOS-6.6 - Updates 1,134 -repolist: 19,247 -``` +>``` +># yum repolist +>Loaded plugins: fastestmirror +>Loading mirror speeds from cached hostfile +> * base: ftp.yz.yamagata-u.ac.jp +> * epel: ftp.tsukuba.wide.ad.jp +> * extras: ftp.yz.yamagata-u.ac.jp +> * updates: ftp.yz.yamagata-u.ac.jp +>repo id repo name status +>base CentOS-6.6 - Base 6,518 +>*epel Extra Packages for Enterprise Linux 6 - x86_64 11,557 +>extras CentOS-6.6 - Extras 38 +>updates CentOS-6.6 - Updates 1,134 +>repolist: 19,247 +>``` epelが表示されていれば、epelリポジトリは有効です。 @@ -76,14 +76,14 @@ tiny_web_exampleはアプリケーションの動作にruby環境が必要です ``` 実行結果例: -``` -# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv -Initialized empty Git repository in /root/.rbenv/.git/ -remote: Counting objects: 2057, done. -remote: Total 2057 (delta 0), reused 0 (delta 0), pack-reused 2057 -Receiving objects: 100% (2057/2057), 344.17 KiB | 74 KiB/s, done. -Resolving deltas: 100% (1272/1272), done. -``` +>``` +># git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +>Initialized empty Git repository in /root/.rbenv/.git/ +>remote: Counting objects: 2057, done. +>remote: Total 2057 (delta 0), reused 0 (delta 0), pack-reused 2057 +>Receiving objects: 100% (2057/2057), 344.17 KiB | 74 KiB/s, done. +>Resolving deltas: 100% (1272/1272), done. +>``` ### rbenvの設定 ``` @@ -98,32 +98,32 @@ Resolving deltas: 100% (1272/1272), done. ``` 実行結果例: -``` -# yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel -Loaded plugins: fastestmirror -Setting up Install Process -Loading mirror speeds from cached hostfile - * base: ftp.jaist.ac.jp - * epel: ftp.jaist.ac.jp - * extras: ftp.jaist.ac.jp - * updates: ftp.jaist.ac.jp -Package gcc-4.4.7-11.el6.x86_64 already installed and latest version -Resolving Dependencies -__(省略)__ - -Installed: - gdbm-devel.x86_64 0:1.8.0-36.el6 libffi-devel.x86_64 0:3.0.5-3.2.el6 - libyaml-devel.x86_64 0:0.1.3-4.el6_6 ncurses-devel.x86_64 0:5.7-3.20090208.el6 - openssl-devel.x86_64 0:1.0.1e-30.el6.8 readline-devel.x86_64 0:6.0-4.el6 - zlib-devel.x86_64 0:1.2.3-29.el6 - -Dependency Installed: - keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 - libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 - libsepol-devel.x86_64 0:2.0.41-4.el6 libyaml.x86_64 0:0.1.3-4.el6_6 - -Complete! -``` +>``` +># yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel +>Loaded plugins: fastestmirror +>Setting up Install Process +>Loading mirror speeds from cached hostfile +> * base: ftp.jaist.ac.jp +> * epel: ftp.jaist.ac.jp +> * extras: ftp.jaist.ac.jp +> * updates: ftp.jaist.ac.jp +>Package gcc-4.4.7-11.el6.x86_64 already installed and latest version +>Resolving Dependencies +>__(省略)__ +> +>Installed: +> gdbm-devel.x86_64 0:1.8.0-36.el6 libffi-devel.x86_64 0:3.0.5-3.2.el6 +> libyaml-devel.x86_64 0:0.1.3-4.el6_6 ncurses-devel.x86_64 0:5.7-3.20090208.el6 +> openssl-devel.x86_64 0:1.0.1e-30.el6.8 readline-devel.x86_64 0:6.0-4.el6 +> zlib-devel.x86_64 0:1.2.3-29.el6 +> +>Dependency Installed: +> keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 +> libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 +> libsepol-devel.x86_64 0:2.0.41-4.el6 libyaml.x86_64 0:0.1.3-4.el6_6 +> +>Complete! +>``` ### ruby-buildのインストール @@ -132,14 +132,14 @@ Complete! ``` 実行結果例: -``` -# git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build -Initialized empty Git repository in /root/.rbenv/plugins/ruby-build/.git/ -remote: Counting objects: 4530, done. -remote: Total 4530 (delta 0), reused 0 (delta 0), pack-reused 4530 -Receiving objects: 100% (4530/4530), 847.84 KiB | 70 KiB/s, done. -Resolving deltas: 100% (2344/2344), done. -``` +>``` +># git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +>Initialized empty Git repository in /root/.rbenv/plugins/ruby-build/.git/ +>remote: Counting objects: 4530, done. +>remote: Total 4530 (delta 0), reused 0 (delta 0), pack-reused 4530 +>Receiving objects: 100% (4530/4530), 847.84 KiB | 70 KiB/s, done. +>Resolving deltas: 100% (2344/2344), done. +>``` ### rubyのインストール @@ -148,33 +148,33 @@ Resolving deltas: 100% (2344/2344), done. ``` 実行結果例: -``` -# rbenv install -v 2.0.0-p598 -/tmp/ruby-build.20150522151700.11775 ~ -Downloading ruby-2.0.0-p598.tar.gz... -HTTP/1.1 200 OK -Content-Type: binary/octet-stream -Content-Length: 13608640 -Connection: keep-alive -Date: Mon, 11 May 2015 13:57:49 GMT -Last-Modified: Thu, 13 Nov 2014 14:55:37 GMT -ETag: "e043a21ce0d138fd408518a80aa31bba" -Accept-Ranges: bytes -Server: AmazonS3 -X-Cache: RefreshHit from cloudfront -Via: 1.1 4565d1650806ee8cdd757034d90ec07d.cloudfront.net (CloudFront) -X-Amz-Cf-Id: gn8DN0xoqLLljcQTklcAR2DABrq7vHhhqsmc2KrZ5Plkwtvpqz8_RA== - --> http://dqw8nmjcqpjn7.cloudfront.net/4136bf7d764cbcc1c7da2824ed2826c3550f2b62af673c79ddbf9049b12095fd -Installing ruby-2.0.0-p598... -/tmp/ruby-build.20150522151700.11775/ruby-2.0.0-p598 /tmp/ruby-build.20150522151700.11775 ~ -__(省略)__ - -Installed ruby-2.0.0-p598 to /root/.rbenv/versions/2.0.0-p598 - -/tmp/ruby-build.20150522152934.22095 ~ -~ -``` +>``` +># rbenv install -v 2.0.0-p598 +>/tmp/ruby-build.20150522151700.11775 ~ +>Downloading ruby-2.0.0-p598.tar.gz... +>HTTP/1.1 200 OK +>Content-Type: binary/octet-stream +>Content-Length: 13608640 +>Connection: keep-alive +>Date: Mon, 11 May 2015 13:57:49 GMT +>Last-Modified: Thu, 13 Nov 2014 14:55:37 GMT +>ETag: "e043a21ce0d138fd408518a80aa31bba" +>Accept-Ranges: bytes +>Server: AmazonS3 +>X-Cache: RefreshHit from cloudfront +>Via: 1.1 4565d1650806ee8cdd757034d90ec07d.cloudfront.net (CloudFront) +>X-Amz-Cf-Id: gn8DN0xoqLLljcQTklcAR2DABrq7vHhhqsmc2KrZ5Plkwtvpqz8_RA== +> +>-> http://dqw8nmjcqpjn7.cloudfront.net/4136bf7d764cbcc1c7da2824ed2826c3550f2b62af673c79ddbf9049b12095fd +>Installing ruby-2.0.0-p598... +>/tmp/ruby-build.20150522151700.11775/ruby-2.0.0-p598 /tmp/ruby-build.20150522151700.11775 ~ +>__(省略)__ +> +>Installed ruby-2.0.0-p598 to /root/.rbenv/versions/2.0.0-p598 +> +>/tmp/ruby-build.20150522152934.22095 ~ +>~ +>``` ### rbenvの再読み込み @@ -190,10 +190,10 @@ Installed ruby-2.0.0-p598 to /root/.rbenv/versions/2.0.0-p598 ``` 実行結果例: -``` -# rbenv versions - 2.0.0-p598 -``` +>``` +># rbenv versions +> 2.0.0-p598 +>``` ### 使用するrubyのバージョンを設定する ``` @@ -202,10 +202,10 @@ Installed ruby-2.0.0-p598 to /root/.rbenv/versions/2.0.0-p598 ``` 実行結果例: -``` -# ruby -v -ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux] -``` +>``` +># ruby -v +>ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux] +>``` ### bundlerのインストール ``` @@ -213,12 +213,12 @@ ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux] ``` 実行結果例: -``` -# gem install bundler --no-ri --no-rdoc -Fetching: bundler-1.9.9.gem (100%) -Successfully installed bundler-1.9.9 -1 gem installed -``` +>``` +># gem install bundler --no-ri --no-rdoc +>Fetching: bundler-1.9.9.gem (100%) +>Successfully installed bundler-1.9.9 +>1 gem installed +>``` ## Yumを使ったインストール @@ -253,48 +253,48 @@ gpgcheck=0 ``` 実行結果例: -``` -# yum install -y tiny-web-example -Loaded plugins: fastestmirror -Setting up Install Process -Loading mirror speeds from cached hostfile -epel/metalink | 5.0 kB 00:00 - * base: ftp.jaist.ac.jp - * epel: ftp.jaist.ac.jp - * extras: ftp.jaist.ac.jp - * updates: ftp.jaist.ac.jp -base | 3.7 kB 00:00 -base/primary_db | 4.6 MB 00:00 -epel | 4.4 kB 00:00 -epel/primary_db | 6.5 MB 00:00 -extras | 3.4 kB 00:00 -extras/primary_db | 31 kB 00:00 -tiny-web-example | 2.9 kB 00:00 -tiny-web-example/primary_db | 3.7 kB 00:00 -updates | 3.4 kB 00:00 -updates/primary_db | 3.3 MB 00:00 -Resolving Dependencies -__(省略)__ - -Installed: - tiny-web-example.x86_64 0:0.0.1-1.daily.el6 - -Dependency Installed: - GeoIP.x86_64 0:1.6.5-1.el6 GeoIP-GeoLite-data.noarch 0:2015.04-2.el6 - GeoIP-GeoLite-data-extra.noarch 0:2015.04-2.el6 compat-readline5.x86_64 0:5.2-17.1.el6 - fontconfig.x86_64 0:2.8.0-5.el6 freetype.x86_64 0:2.3.11-15.el6_6.1 - gd.x86_64 0:2.0.35-11.el6 geoipupdate.x86_64 0:2.2.1-2.el6 - libX11.x86_64 0:1.6.0-2.2.el6 libX11-common.noarch 0:1.6.0-2.2.el6 - libXau.x86_64 0:1.0.6-4.el6 libXpm.x86_64 0:3.5.10-2.el6 - libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 libpng.x86_64 2:1.2.49-1.el6_2 - libxcb.x86_64 0:1.9.1-2.el6 libxslt.x86_64 0:1.1.26-2.el6_3.1 - mysql.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 - nginx.x86_64 0:1.0.15-11.el6 nginx-filesystem.noarch 0:1.0.15-11.el6 - perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 - ruby.x86_64 0:1.8.7.374-4.el6_6 ruby-libs.x86_64 0:1.8.7.374-4.el6_6 - -Complete! -``` +>``` +># yum install -y tiny-web-example +>Loaded plugins: fastestmirror +>Setting up Install Process +>Loading mirror speeds from cached hostfile +>epel/metalink | 5.0 kB 00:00 +> * base: ftp.jaist.ac.jp +> * epel: ftp.jaist.ac.jp +> * extras: ftp.jaist.ac.jp +> * updates: ftp.jaist.ac.jp +>base | 3.7 kB 00:00 +>base/primary_db | 4.6 MB 00:00 +>epel | 4.4 kB 00:00 +>epel/primary_db | 6.5 MB 00:00 +>extras | 3.4 kB 00:00 +>extras/primary_db | 31 kB 00:00 +>tiny-web-example | 2.9 kB 00:00 +>tiny-web-example/primary_db | 3.7 kB 00:00 +>updates | 3.4 kB 00:00 +>updates/primary_db | 3.3 MB 00:00 +>Resolving Dependencies +>__(省略)__ +> +>Installed: +> tiny-web-example.x86_64 0:0.0.1-1.daily.el6 +> +>Dependency Installed: +> GeoIP.x86_64 0:1.6.5-1.el6 GeoIP-GeoLite-data.noarch 0:2015.04-2.el6 +> GeoIP-GeoLite-data-extra.noarch 0:2015.04-2.el6 compat-readline5.x86_64 0:5.2-17.1.el6 +> fontconfig.x86_64 0:2.8.0-5.el6 freetype.x86_64 0:2.3.11-15.el6_6.1 +> gd.x86_64 0:2.0.35-11.el6 geoipupdate.x86_64 0:2.2.1-2.el6 +> libX11.x86_64 0:1.6.0-2.2.el6 libX11-common.noarch 0:1.6.0-2.2.el6 +> libXau.x86_64 0:1.0.6-4.el6 libXpm.x86_64 0:3.5.10-2.el6 +> libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 libpng.x86_64 2:1.2.49-1.el6_2 +> libxcb.x86_64 0:1.9.1-2.el6 libxslt.x86_64 0:1.1.26-2.el6_3.1 +> mysql.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 +> nginx.x86_64 0:1.0.15-11.el6 nginx-filesystem.noarch 0:1.0.15-11.el6 +> perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 +> ruby.x86_64 0:1.8.7.374-4.el6_6 ruby-libs.x86_64 0:1.8.7.374-4.el6_6 +> +>Complete! +>``` ## Gitを使用したインストール @@ -307,17 +307,17 @@ Complete! ``` 実行結果例: -``` -# git clone https://github.com/axsh/tiny_web_example.git -Initialized empty Git repository in /home/vagrant/tiny_web_example/.git/ -remote: Counting objects: 295, done. -remote: Compressing objects: 100% (10/10), done. -remote: Total 295 (delta 3), reused 0 (delta 0), pack-reused 285 -Receiving objects: 100% (295/295), 288.04 KiB | 165 KiB/s, done. -Resolving deltas: 100% (105/105), done. -# mkdir -p /opt/axsh -# mv -i tiny_web_example /opt/axsh -``` +>``` +># git clone https://github.com/axsh/tiny_web_example.git +>Initialized empty Git repository in /home/vagrant/tiny_web_example/.git/ +>remote: Counting objects: 295, done. +>remote: Compressing objects: 100% (10/10), done. +>remote: Total 295 (delta 3), reused 0 (delta 0), pack-reused 285 +>Receiving objects: 100% (295/295), 288.04 KiB | 165 KiB/s, done. +>Resolving deltas: 100% (105/105), done. +># mkdir -p /opt/axsh +># mv -i tiny_web_example /opt/axsh +>``` ### 依存パッケージのインストール @@ -327,31 +327,31 @@ Resolving deltas: 100% (105/105), done. 実行結果例: -``` -# yum install -y nginx mysql-server mysql-devel -Loaded plugins: fastestmirror -Setting up Install Process -Loading mirror speeds from cached hostfile - * base: ftp.jaist.ac.jp - * extras: ftp.jaist.ac.jp - * updates: ftp.jaist.ac.jp -No package nginx available. -Resolving Dependencies ---> Running transaction check -___(省略)___ - -Installed: - mysql-devel.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 - -Dependency Installed: - keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 - libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 - libsepol-devel.x86_64 0:2.0.41-4.el6 mysql.x86_64 0:5.1.73-3.el6_5 - openssl-devel.x86_64 0:1.0.1e-30.el6.8 perl-DBD-MySQL.x86_64 0:4.013-3.el6 - perl-DBI.x86_64 0:1.609-4.el6 zlib-devel.x86_64 0:1.2.3-29.el6 - -Complete! -``` +>``` +># yum install -y nginx mysql-server mysql-devel +>Loaded plugins: fastestmirror +>Setting up Install Process +>Loading mirror speeds from cached hostfile +> * base: ftp.jaist.ac.jp +> * extras: ftp.jaist.ac.jp +> * updates: ftp.jaist.ac.jp +>No package nginx available. +>Resolving Dependencies +>--> Running transaction check +>___(省略)___ +> +>Installed: +> mysql-devel.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 +> +>Dependency Installed: +> keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-37.el6_6 +> libcom_err-devel.x86_64 0:1.41.12-21.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 +> libsepol-devel.x86_64 0:2.0.41-4.el6 mysql.x86_64 0:5.1.73-3.el6_5 +> openssl-devel.x86_64 0:1.0.1e-30.el6.8 perl-DBD-MySQL.x86_64 0:4.013-3.el6 +> perl-DBI.x86_64 0:1.609-4.el6 zlib-devel.x86_64 0:1.2.3-29.el6 +> +>Complete! +>``` ### gemパッケージのインストール @@ -362,41 +362,41 @@ webapiで使用するgemをインストールする ``` 実行結果例: -``` -# bundle install -Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root -will break this application for all non-root users on this machine. -Fetching gem metadata from https://rubygems.org/......... -Fetching version metadata from https://rubygems.org/.. -Resolving dependencies... -Installing rake 10.4.2 -Installing backports 3.6.4 -Using bundler 1.9.9 -Installing diff-lcs 1.2.5 -Installing fuguta 1.0.4 -Installing get_process_mem 0.2.0 -Installing kgio 2.9.3 -Installing multi_json 1.11.0 -Installing mysql2 0.3.18 -Installing rack 1.6.1 -Installing rack-cors 0.4.0 -Installing rack-protection 1.5.3 -Installing rack-test 0.6.3 -Installing raindrops 0.13.0 -Installing rspec-support 3.2.2 -Installing rspec-core 3.2.3 -Installing rspec-expectations 3.2.1 -Installing rspec-mocks 3.2.1 -Installing rspec 3.2.0 -Installing sequel 4.22.0 -Installing tilt 1.4.1 -Installing sinatra 1.4.6 -Installing sinatra-contrib 1.4.2 -Installing unicorn 4.9.0 -Installing unicorn-worker-killer 0.4.3 -Bundle complete! 11 Gemfile dependencies, 25 gems now installed. -Bundled gems are installed into ./vendor/bundle. -``` +>``` +># bundle install +>Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root +>will break this application for all non-root users on this machine. +>Fetching gem metadata from https://rubygems.org/......... +>Fetching version metadata from https://rubygems.org/.. +>Resolving dependencies... +>Installing rake 10.4.2 +>Installing backports 3.6.4 +>Using bundler 1.9.9 +>Installing diff-lcs 1.2.5 +>Installing fuguta 1.0.4 +>Installing get_process_mem 0.2.0 +>Installing kgio 2.9.3 +>Installing multi_json 1.11.0 +>Installing mysql2 0.3.18 +>Installing rack 1.6.1 +>Installing rack-cors 0.4.0 +>Installing rack-protection 1.5.3 +>Installing rack-test 0.6.3 +>Installing raindrops 0.13.0 +>Installing rspec-support 3.2.2 +>Installing rspec-core 3.2.3 +>Installing rspec-expectations 3.2.1 +>Installing rspec-mocks 3.2.1 +>Installing rspec 3.2.0 +>Installing sequel 4.22.0 +>Installing tilt 1.4.1 +>Installing sinatra 1.4.6 +>Installing sinatra-contrib 1.4.2 +>Installing unicorn 4.9.0 +>Installing unicorn-worker-killer 0.4.3 +>Bundle complete! 11 Gemfile dependencies, 25 gems now installed. +>Bundled gems are installed into ./vendor/bundle. +>``` frontendで使用するgemをインストールする ``` @@ -405,32 +405,32 @@ frontendで使用するgemをインストールする ``` 実行結果例: -``` -# bundle install -Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root -will break this application for all non-root users on this machine. -Fetching gem metadata from https://rubygems.org/.......... -Fetching version metadata from https://rubygems.org/.. -Resolving dependencies... -Installing backports 3.6.4 -Using bundler 1.9.9 -Installing get_process_mem 0.2.0 -Installing kgio 2.9.3 -Installing multi_json 1.11.0 -Installing mysql2 0.3.18 -Installing rack 1.6.1 -Installing rack-protection 1.5.3 -Installing rack-test 0.6.3 -Installing raindrops 0.13.0 -Installing sequel 4.22.0 -Installing tilt 1.4.1 -Installing sinatra 1.4.6 -Installing sinatra-contrib 1.4.2 -Installing unicorn 4.9.0 -Installing unicorn-worker-killer 0.4.3 -Bundle complete! 7 Gemfile dependencies, 16 gems now installed. -Bundled gems are installed into ./vendor/bundle. -``` +>``` +># bundle install +>Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root +>will break this application for all non-root users on this machine. +>Fetching gem metadata from https://rubygems.org/.......... +>Fetching version metadata from https://rubygems.org/.. +>Resolving dependencies... +>Installing backports 3.6.4 +>Using bundler 1.9.9 +>Installing get_process_mem 0.2.0 +>Installing kgio 2.9.3 +>Installing multi_json 1.11.0 +>Installing mysql2 0.3.18 +>Installing rack 1.6.1 +>Installing rack-protection 1.5.3 +>Installing rack-test 0.6.3 +>Installing raindrops 0.13.0 +>Installing sequel 4.22.0 +>Installing tilt 1.4.1 +>Installing sinatra 1.4.6 +>Installing sinatra-contrib 1.4.2 +>Installing unicorn 4.9.0 +>Installing unicorn-worker-killer 0.4.3 +>Bundle complete! 7 Gemfile dependencies, 16 gems now installed. +>Bundled gems are installed into ./vendor/bundle. +>``` ### 起動スクリプトの配置 ``` @@ -527,47 +527,47 @@ database_uri: 'mysql2://localhost/tiny_web_example?user=root' ``` 実行結果例: -``` -Initializing MySQL database: WARNING: The host 'vagrant-centos6' could not be looked up with resolveip. -This probably means that your libc libraries are not 100 % compatible -with this binary MySQL version. The MySQL daemon, mysqld, should work -normally with the exception that host name resolving will not work. -This means that you should use IP addresses instead of hostnames -when specifying MySQL privileges ! -Installing MySQL system tables... -OK -Filling help tables... -OK - -To start mysqld at boot time you have to copy -support-files/mysql.server to the right place for your system - -PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! -To do so, start the server, then issue the following commands: - -/usr/bin/mysqladmin -u root password 'new-password' -/usr/bin/mysqladmin -u root -h vagrant-centos6 password 'new-password' - -Alternatively you can run: -/usr/bin/mysql_secure_installation - -which will also give you the option of removing the test -databases and anonymous user created by default. This is -strongly recommended for production servers. - -See the manual for more instructions. - -You can start the MySQL daemon with: -cd /usr ; /usr/bin/mysqld_safe & - -You can test the MySQL daemon with mysql-test-run.pl -cd /usr/mysql-test ; perl mysql-test-run.pl - -Please report any problems with the /usr/bin/mysqlbug script! - - [ OK ] -Starting mysqld: [ OK ] -``` +>``` +>Initializing MySQL database: WARNING: The host 'vagrant-centos6' could not be looked up with resolveip. +>This probably means that your libc libraries are not 100 % compatible +>with this binary MySQL version. The MySQL daemon, mysqld, should work +>normally with the exception that host name resolving will not work. +>This means that you should use IP addresses instead of hostnames +>when specifying MySQL privileges ! +>Installing MySQL system tables... +>OK +>Filling help tables... +>OK +> +>To start mysqld at boot time you have to copy +>support-files/mysql.server to the right place for your system +> +>PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! +>To do so, start the server, then issue the following commands: +> +>/usr/bin/mysqladmin -u root password 'new-password' +>/usr/bin/mysqladmin -u root -h vagrant-centos6 password 'new-password' +> +>Alternatively you can run: +>/usr/bin/mysql_secure_installation +> +>which will also give you the option of removing the test +>databases and anonymous user created by default. This is +>strongly recommended for production servers. +> +>See the manual for more instructions. +> +>You can start the MySQL daemon with: +>cd /usr ; /usr/bin/mysqld_safe & +> +>You can test the MySQL daemon with mysql-test-run.pl +>cd /usr/mysql-test ; perl mysql-test-run.pl +> +>Please report any problems with the /usr/bin/mysqlbug script! +> +> [ OK ] +>Starting mysqld: [ OK ] +>``` ## DataBaseの作成 ``` @@ -614,9 +614,9 @@ POSTの確認 ``` 実行結果例: -``` -{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} -``` +>``` +>{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} +>``` GETの確認(list) ``` @@ -624,9 +624,9 @@ GETの確認(list) ``` 実行結果例: -``` -[{"total":2,"results":[{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"},{"id":2,"display_name":"webapi test","comment":"sample message 2.","created_at":"2015-05-21 11:19:04 UTC","updated_at":"2015-05-21 11:19:04 UTC"}]}] -``` +>``` +>[{"total":2,"results":[{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"},{"id":2,"display_name":"webapi test","comment":"sample message 2.","created_at":"2015-05-21 11:19:04 UTC","updated_at":"2015-05-21 11:19:04 UTC"}]}] +>``` GETの確認(show) ``` @@ -634,9 +634,9 @@ GETの確認(show) ``` 実行結果例: -``` -{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} -``` +>``` +>{"id":1,"display_name":"webapi test","comment":"sample message.","created_at":"2015-05-21 11:18:07 UTC","updated_at":"2015-05-21 11:18:07 UTC"} +>``` ## frontendの確認 diff --git a/rpmbuild/README.md b/rpmbuild/README.md index 869dceb..9601f8c 100644 --- a/rpmbuild/README.md +++ b/rpmbuild/README.md @@ -22,28 +22,28 @@ rpmをビルドするために必要なパッケージをインストールし ``` 実行結果例: -``` -# yum install -y rpm-build rpmlint yum-utils -Loaded plugins: fastestmirror -Setting up Install Process -Loading mirror speeds from cached hostfile - * base: mirror.fairway.ne.jp - * epel: ftp.iij.ad.jp - * extras: mirror.fairway.ne.jp - * updates: mirror.fairway.ne.jp -Resolving Dependencies -__(省略)__ - -Installed: - rpm-build.x86_64 0:4.8.0-38.el6_6 rpmlint.noarch 0:0.94-3.1.el6 yum-utils.noarch 0:1.1.30-30.el6 - -Dependency Installed: - desktop-file-utils.x86_64 0:0.15-9.el6 elfutils.x86_64 0:0.158-3.2.el6 enchant.x86_64 1:1.5.0-4.el6 gdb.x86_64 0:7.2-75.el6 - hunspell.x86_64 0:1.2.8-16.el6 patch.x86_64 0:2.6-6.el6 python-enchant.x86_64 0:1.3.1-5.2.el6 python-magic.x86_64 0:5.04-21.el6 - unzip.x86_64 0:6.0-2.el6_6 - -Complete! -``` +>``` +># yum install -y rpm-build rpmlint yum-utils +>Loaded plugins: fastestmirror +>Setting up Install Process +>Loading mirror speeds from cached hostfile +> * base: mirror.fairway.ne.jp +> * epel: ftp.iij.ad.jp +> * extras: mirror.fairway.ne.jp +> * updates: mirror.fairway.ne.jp +>Resolving Dependencies +>__(省略)__ +> +>Installed: +> rpm-build.x86_64 0:4.8.0-38.el6_6 rpmlint.noarch 0:0.94-3.1.el6 yum-utils.noarch 0:1.1.30-30.el6 +> +>Dependency Installed: +> desktop-file-utils.x86_64 0:0.15-9.el6 elfutils.x86_64 0:0.158-3.2.el6 enchant.x86_64 1:1.5.0-4.el6 gdb.x86_64 0:7.2-75.el6 +> hunspell.x86_64 0:1.2.8-16.el6 patch.x86_64 0:2.6-6.el6 python-enchant.x86_64 0:1.3.1-5.2.el6 python-magic.x86_64 0:5.04-21.el6 +> unzip.x86_64 0:6.0-2.el6_6 +> +>Complete! +>``` # ソースコードの取得 ``` @@ -51,15 +51,15 @@ Complete! ``` 実行結果例: -``` -# git clone https://github.com/axsh/tiny_web_example.git -Initialized empty Git repository in /root/tiny_web_example/.git/ -remote: Counting objects: 307, done. -remote: Compressing objects: 100% (22/22), done. -Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. -remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 -Resolving deltas: 100% (112/112), done. -``` +>``` +># git clone https://github.com/axsh/tiny_web_example.git +>Initialized empty Git repository in /root/tiny_web_example/.git/ +>remote: Counting objects: 307, done. +>remote: Compressing objects: 100% (22/22), done. +>Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. +>remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 +>Resolving deltas: 100% (112/112), done. +>``` # 依存関係のインストール @@ -69,23 +69,23 @@ Resolving deltas: 100% (112/112), done. ``` 実行結果例: -``` -# yum-builddep ./rpmbuild/SPECS/tiny-web-example.spec -Loaded plugins: fastestmirror -Enabling epel-source repository -Loading mirror speeds from cached hostfile -epel-source/metalink | 5.0 kB 00:00 - * base: mirror.fairway.ne.jp - * epel: ftp.iij.ad.jp - * epel-source: ftp.iij.ad.jp - * extras: mirror.fairway.ne.jp - * updates: mirror.fairway.ne.jp -epel-source | 3.7 kB 00:00 -epel-source/primary_db | 1.8 MB 00:00 -Getting requirements for ./rpmbuild/SPECS/tiny-web-example.spec - --> Already installed : mysql-devel-5.1.73-3.el6_5.x86_64 -No uninstalled build requires -``` +>``` +># yum-builddep ./rpmbuild/SPECS/tiny-web-example.spec +>Loaded plugins: fastestmirror +>Enabling epel-source repository +>Loading mirror speeds from cached hostfile +>epel-source/metalink | 5.0 kB 00:00 +> * base: mirror.fairway.ne.jp +> * epel: ftp.iij.ad.jp +> * epel-source: ftp.iij.ad.jp +> * extras: mirror.fairway.ne.jp +> * updates: mirror.fairway.ne.jp +>epel-source | 3.7 kB 00:00 +>epel-source/primary_db | 1.8 MB 00:00 +>Getting requirements for ./rpmbuild/SPECS/tiny-web-example.spec +> --> Already installed : mysql-devel-5.1.73-3.el6_5.x86_64 +>No uninstalled build requires +>``` # rpmbuildの実行 ``` @@ -93,30 +93,30 @@ rpmbuild -bb ./rpmbuild/SPECS/tiny-web-example.spec ``` 実行結果例: -``` -# rpmbuild -bb ./rpmbuild/SPECS/tiny-web-example.spec -Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.w7wyVS -+ umask 022 -+ cd /root/rpmbuild/BUILD -+ '[' -d tiny-web-example-0.0.1 ']' -+ git clone git://github.com/axsh/tiny_web_example.git tiny-web-example-0.0.1 -Initialized empty Git repository in /root/rpmbuild/BUILD/tiny-web-example-0.0.1/.git/ -remote: Counting objects: 307, done. -remote: Compressing objects: 100% (22/22), done. -remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 -Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. -Resolving deltas: 100% (112/112), done. -__(省略)__ - -+ umask 022 -+ cd /root/rpmbuild/BUILD -+ cd tiny-web-example-0.0.1 -+ RUBYDIR=/usr/bin/ruby -+ rpmbuild/rules clean -rm -rf /root/rpmbuild/BUILD/tiny-web-example-0.0.1/vendor/bundle -rm -f /root/rpmbuild/BUILD/tiny-web-example-0.0.1/bundle-install-stamp -rm -f build-stamp -+ rm -rf /root/rpmbuild/BUILDROOT/tiny-web-example-0.0.1-1.daily.el6.x86_64 -+ exit 0 -``` +>``` +># rpmbuild -bb ./rpmbuild/SPECS/tiny-web-example.spec +>Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.w7wyVS +>+ umask 022 +>+ cd /root/rpmbuild/BUILD +>+ '[' -d tiny-web-example-0.0.1 ']' +>+ git clone git://github.com/axsh/tiny_web_example.git tiny-web-example-0.0.1 +>Initialized empty Git repository in /root/rpmbuild/BUILD/tiny-web-example-0.0.1/.git/ +>remote: Counting objects: 307, done. +>remote: Compressing objects: 100% (22/22), done. +>remote: Total 307 (delta 10), reused 0 (delta 0), pack-reused 285 +>Receiving objects: 100% (307/307), 294.71 KiB | 103 KiB/s, done. +>Resolving deltas: 100% (112/112), done. +>__(省略)__ +> +>+ umask 022 +>+ cd /root/rpmbuild/BUILD +>+ cd tiny-web-example-0.0.1 +>+ RUBYDIR=/usr/bin/ruby +>+ rpmbuild/rules clean +>rm -rf /root/rpmbuild/BUILD/tiny-web-example-0.0.1/vendor/bundle +>rm -f /root/rpmbuild/BUILD/tiny-web-example-0.0.1/bundle-install-stamp +>rm -f build-stamp +>+ rm -rf /root/rpmbuild/BUILDROOT/tiny-web-example-0.0.1-1.daily.el6.x86_64 +>+ exit 0 +>``` diff --git a/spec_integration/README.md b/spec_integration/README.md index c8a5740..67e4c57 100644 --- a/spec_integration/README.md +++ b/spec_integration/README.md @@ -21,23 +21,23 @@ CentOS-6.6にて動作確認を行いました。それよりも古い環境の ``` 実行結果例: -``` -# bundle install -Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all -non-root users on this machine. -Fetching gem metadata from https://rubygems.org/......... -Fetching version metadata from https://rubygems.org/.. -Resolving dependencies... -Using bundler 1.9.9 -Installing diff-lcs 1.2.5 -Installing rspec-support 3.2.2 -Installing rspec-core 3.2.3 -Installing rspec-expectations 3.2.1 -Installing rspec-mocks 3.2.1 -Installing rspec 3.2.0 -Bundle complete! 2 Gemfile dependencies, 7 gems now installed. -Bundled gems are installed into ./vendor/bundle. -``` +>``` +># bundle install +>Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all +>non-root users on this machine. +>Fetching gem metadata from https://rubygems.org/......... +>Fetching version metadata from https://rubygems.org/.. +>Resolving dependencies... +>Using bundler 1.9.9 +>Installing diff-lcs 1.2.5 +>Installing rspec-support 3.2.2 +>Installing rspec-core 3.2.3 +>Installing rspec-expectations 3.2.1 +>Installing rspec-mocks 3.2.1 +>Installing rspec 3.2.0 +>Bundle complete! 2 Gemfile dependencies, 7 gems now installed. +>Bundled gems are installed into ./vendor/bundle. +>``` # Configの設定 ``` @@ -62,17 +62,17 @@ uri: 'http://localhost:8080' ``` 実行結果例: -``` -# bundle exec rspec ./spec/webapi_integration_spec.rb - -Webapi Integration spec - post - create a new comment - get - show list for the comments - show detail the comment - -Finished in 0.04481 seconds (files took 0.15042 seconds to load) -3 examples, 0 failures - -``` +>``` +># bundle exec rspec ./spec/webapi_integration_spec.rb +> +>Webapi Integration spec +> post +> create a new comment +> get +> show list for the comments +> show detail the comment +> +>Finished in 0.04481 seconds (files took 0.15042 seconds to load) +>3 examples, 0 failures +> +>``` From b18b41c02f09e923b0b1ad5fa41c628865747774 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 22 May 2015 19:47:43 +0900 Subject: [PATCH 053/147] Changed wording. --- README.md | 10 +++++----- spec_integration/README.md | 2 +- webapi/spec/README.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0a8153d..6ab8c9b 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,7 @@ baseurlを作成したリポジトリのあるサーバーのIPアドレスに # vi /etc/yum.repos.d/tiny-web-example.repo ``` -実行結果例: +修正結果: ``` [tiny-web-example] name=tiny-web-example @@ -459,7 +459,7 @@ webapiの起動スクリプトを修正する # vi /etc/default/tiny-web-example-webapi ``` -実行結果例: +修正結果: ``` # tiny-web-example EXAMPLE_ROOT=/opt/axsh/tiny-web-example @@ -480,7 +480,7 @@ frontendの起動スクリプトを修正する # vi /etc/default/tiny-web-example-webapp ``` -実行結果例: +修正結果: ``` # tiny-web-example EXAMPLE_ROOT=/opt/axsh/tiny-web-example @@ -505,7 +505,7 @@ webapi.confの修正 # vi /etc/tiny-web-example/webapi.conf ``` -実行結果例: +修正結果: ``` # Database connection string database_uri 'mysql2://localhost/tiny_web_example?user=root' @@ -516,7 +516,7 @@ webapp.ymlの修正 # vi /etc/tiny-web-example/webapp.yml ``` -実行結果例: +修正結果: ``` database_uri: 'mysql2://localhost/tiny_web_example?user=root' ``` diff --git a/spec_integration/README.md b/spec_integration/README.md index 67e4c57..ba3024e 100644 --- a/spec_integration/README.md +++ b/spec_integration/README.md @@ -50,7 +50,7 @@ webapiに接続するDataBaseのIPアドレスを記述します # vi webapi.conf ``` -実行結果例: +修正結果: ``` uri: 'http://localhost:8080' ``` diff --git a/webapi/spec/README.md b/webapi/spec/README.md index 5d4e7fb..7c552c6 100644 --- a/webapi/spec/README.md +++ b/webapi/spec/README.md @@ -26,7 +26,7 @@ DataBaseのIPアドレスを記述します # vi webapi.conf ``` -実行結果例: +修正結果: ``` # Database connection string database_uri 'mysql2://localhost/tiny_web_example?user=root' From 2c076e0b80dd7b818140c2a13e7b315033da7fbd Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 17:34:29 +0900 Subject: [PATCH 054/147] use wmi-centos1d64. --- ciscripts/create-db.sh | 2 +- ciscripts/provision-db.sh | 30 +++++++++++++++++++++++++----- ciscripts/runner-db.sh | 5 ----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 86d20d4..360d6e2 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -59,7 +59,7 @@ user_data="user_data_db.txt" cpu_cores="1" hypervisor="kvm" memory_size="1024" -image_id="wmi-mysql1d64" +image_id="wmi-centos1d64" display_name="db" ssh_key_id="ssh-cicddemo" diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-db.sh index d19f7e8..adfbd71 100755 --- a/ciscripts/provision-db.sh +++ b/ciscripts/provision-db.sh @@ -9,19 +9,39 @@ set -o pipefail set -u set -x +# install mysqld +yum install -y --disablerepo=updates mysql-server + +# configure service +svc="mysqld" +chkconfig --list "${svc}" +chkconfig "${svc}" on +chkconfig --list "${svc}" + +# start mysqld service +if ! service "${svc}" status; then + service "${svc}" start +fi + +# wait for mysqld to be ready until mysqladmin -uroot ping; do sleep 1 done +# db params dbname="tiny_web_example" dbuser="root" -dbacl="10.%" +dbacl="10.0.22.%" -mysqladmin -uroot drop ${dbname} <<< "Y" || : -mysqladmin -uroot create ${dbname} --default-character-set=utf8 - -mysql -uroot mysql <&2 -{ - echo generating user_data_app.txt... - echo "DB_HOST=${ipaddr}" | tee user_data_app.txt -} >&2 - echo instance_id="${instance_id}" echo ipaddr="${ipaddr}" From be09b5bfcee4c36d3d65d5fc356ddd9db5bc5e4a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 17:43:26 +0900 Subject: [PATCH 055/147] add rbenv set. --- ciscripts/create-rbenv.sh | 88 ++++++++++++++++++++++++++++++++++++ ciscripts/provision-rbenv.sh | 49 ++++++++++++++++++++ ciscripts/runner-rbenv.sh | 22 +++++++++ 3 files changed, 159 insertions(+) create mode 100755 ciscripts/create-rbenv.sh create mode 100755 ciscripts/provision-rbenv.sh create mode 100755 ciscripts/runner-rbenv.sh diff --git a/ciscripts/create-rbenv.sh b/ciscripts/create-rbenv.sh new file mode 100755 index 0000000..32370dc --- /dev/null +++ b/ciscripts/create-rbenv.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -u + +## functions + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS + +# setup vifs.json + +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS + +# setup user_data.txt + +user_data="user_data_app.txt" + +# instance-specific parameter + +cpu_cores="1" +hypervisor="kvm" +memory_size="1024" +image_id="wmi-centos1d64" +display_name="rbenv" +ssh_key_id="ssh-cicddemo" + +## create an instance + +instance_id="$( + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --user-data "${user_data}" \ + --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +trap "mussel instance destroy \"${instance_id}\"" ERR + +## wait for the instance to be running + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] +echo instance_id="${instance_id}" diff --git a/ciscripts/provision-rbenv.sh b/ciscripts/provision-rbenv.sh new file mode 100755 index 0000000..ec33487 --- /dev/null +++ b/ciscripts/provision-rbenv.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x + +# git +yum install -y git + +# epel +rpm -qa epel-release* | egrep -q epel-release || { + rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm + sed -i \ + -e 's,^#baseurl,baseurl,' \ + -e 's,^mirrorlist=,#mirrorlist=,' \ + -e 's,http://download.fedoraproject.org/pub/epel/,http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/,' \ + /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo + yum install -y ca-certificates +} +yum repolist + +# install rbenv +git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +# setup rbenv +echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +echo 'eval "$(rbenv init -)"' >> ~/.bash_profile +exec $SHELL -l + +# install build require for ruby-build +yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel + +# install ruby-build +git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build + +# install ruby +ruby_version="2.0.0-p598" + +rbenv install -v "${ruby_version}" +rbenv rehash +rbenv versions +rbenv global "${ruby_version}" +ruby -v + +# install bundler +gem install bundler --no-ri --no-rdoc diff --git a/ciscripts/runner-rbenv.sh b/ciscripts/runner-rbenv.sh new file mode 100755 index 0000000..cd4ac2a --- /dev/null +++ b/ciscripts/runner-rbenv.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +eval "$( + ./create-rbenv.sh + )" +trap "mussel instance destroy \"${instance_id}\"" ERR + +eval "$(./instance-get-ipaddr.sh "${instance_id}")" + +{ + ./instance-wait4ssh.sh "${instance_id}" + ./instance-exec.sh "${instance_id}" < ./provision-rbenv.sh +} >&2 + +echo instance_id="${instance_id}" +echo ipaddr="${ipaddr}" From ae7b3e8c0ecb924aa71694cb3ba2703fd0be3838 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 18:33:06 +0900 Subject: [PATCH 056/147] update app set. --- ciscripts/create-app.sh | 2 +- ciscripts/provision-app.sh | 79 ++++++++++++++++++++++++++------------ ciscripts/runner-app.sh | 1 - 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index da66c80..21b0b82 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -59,7 +59,7 @@ user_data="user_data_app.txt" cpu_cores="1" hypervisor="kvm" memory_size="1024" -image_id="wmi-centos1d64" +image_id="wmi-43n0y4mk" display_name="app" ssh_key_id="ssh-cicddemo" diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 7202bb5..f953070 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -8,34 +8,65 @@ set -o pipefail set -u set -x -hostname +YUM_HOST="${YUM_HOST:-"10.0.22.100"}" +DB_HOST="${DB_HOST:-"10.0.22.101"}" -if [[ -f /metadata/user-data ]]; then - . /metadata/user-data -fi -: "${DB_HOST:?"should not be empty"}" -: "${YUM_HOST:?"should not be empty"}" +# install tiny-web-example.repo +cat <<-EOS > /etc/yum.repos.d/tiny-web-example.repo + [tin-web-example] + name=tiny-web-example + baseurl=http://${YUM_HOST}/pub/ + enabled=1 + gpgcheck=0 + EOS -[[ -f /etc/yum.repos.d/tiny-web-example.repo ]] -sed -i "s,127.0.0.1,${YUM_HOST}," /etc/yum.repos.d/tiny-web-example.repo +# show available repo list yum repolist -# tiny-web-example depends on epel to install nginx -rpm -qa epel-release* | egrep -q epel-release || { - rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm - sed -i \ - -e 's,^#baseurl,baseurl,' \ - -e 's,^mirrorlist=,#mirrorlist=,' \ - -e 's,http://download.fedoraproject.org/pub/epel/,http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/,' \ - /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo - yum install -y ca-certificates -} +# install tiny-web-example.rpm +yum install -y tiny-web-example -# tiny-web-example requires ruby-2.0.0p598 -yum install -y http://dlc.wakame.axsh.jp/demo/ruby-rpm/rhel/6/x86_64/ruby-2.0.0p598-2.el6.x86_64.rpm +## /etc/default/tiny-web-example-webapi +cat <<-'EOS' > /etc/default/tiny-web-example-webapi + # tiny-web-example + EXAMPLE_ROOT=/opt/axsh/tiny-web-example + PATH=/root/.rbenv/shims:$PATH -yum install -y tiny-web-example + # Commnet out to run the vdc init script. + #RUN=yes + + ## rack params + RACK_ENV=development + BIND_ADDR=0.0.0.0 + PORT=8080 + UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf + EOS + +## /etc/default/tiny-web-example-webapp +cat <<-'EOS' > /etc/default/tiny-web-example-webapp + # tiny-web-example + EXAMPLE_ROOT=/opt/axsh/tiny-web-example + PATH=/root/.rbenv/shims:$PATH + + # Commnet out to run the vdc init script. + #RUN=yes + + ## rack params + RACK_ENV=development + BIND_ADDR=0.0.0.0 + PORT=80 + UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf + EOS + +# configure db host +sed -i \ + "s,^database_uri .*,database_uri 'mysql2://${DB_HOST}/tiny_web_example?user=root'," \ + /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml + +# setup db +cd /opt/axsh/tiny-web-example/webapi/ +bundle exec rake db:up -# configure db -sed -i "s,localhost,${DB_HOST}," /etc/tiny-web-example/webapi.conf -cat /etc/tiny-web-example/webapi.conf +# start system jobs +initctl start tiny-web-example-webapi RUN=yes +initctl start tiny-web-example-webapp RUN=yes diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index b3028fa..44693c7 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -15,7 +15,6 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" "cat > /etc/yum.repos.d/tiny-web-example.repo" < ../rpmbuild/tiny-web-example.repo ./instance-exec.sh "${instance_id}" < ./provision-app.sh } >&2 From 4a7c7cd969c4ec0515f76a614497bdab28800bc3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 18:58:59 +0900 Subject: [PATCH 057/147] remove unused user_data. --- ciscripts/README.md | 1 - ciscripts/create-app.sh | 5 ----- ciscripts/create-centos.sh | 5 ----- ciscripts/create-db.sh | 5 ----- ciscripts/create-rbenv.sh | 5 ----- ciscripts/myaddr.sh | 14 -------------- ciscripts/web3layers-ci.sh | 6 ------ 7 files changed, 41 deletions(-) delete mode 100755 ciscripts/myaddr.sh diff --git a/ciscripts/README.md b/ciscripts/README.md index ff6eedb..390b8d6 100644 --- a/ciscripts/README.md +++ b/ciscripts/README.md @@ -3,7 +3,6 @@ 1. run `runner-app.sh` 1. run `create-app.sh` 2. run `provision-app.sh` - 3. generate `user_data_app.txt` 2. run `runner-db.sh` 1. run `create-db.sh` 2. run `provision-db.sh` diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index 21b0b82..8250f4a 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -50,10 +50,6 @@ cat < "${vifs}" } EOS -# setup user_data.txt - -user_data="user_data_app.txt" - # instance-specific parameter cpu_cores="1" @@ -73,7 +69,6 @@ instance_id="$( --memory-size "${memory_size}" \ --ssh-key-id "${ssh_key_id}" \ --vifs "${vifs}" \ - --user-data "${user_data}" \ --display-name "${display_name}" \ | egrep ^:id: | awk '{print $2}' )" diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 3ec2c79..742bd02 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -50,10 +50,6 @@ cat < "${vifs}" } EOS -# setup user_data.txt - -user_data="user_data_centos.txt" - # instance-specific parameter cpu_cores="1" @@ -73,7 +69,6 @@ instance_id="$( --memory-size "${memory_size}" \ --ssh-key-id "${ssh_key_id}" \ --vifs "${vifs}" \ - --user-data "${user_data}" \ --display-name "${display_name}" \ | egrep ^:id: | awk '{print $2}' )" diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 360d6e2..9a6d44d 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -50,10 +50,6 @@ cat < "${vifs}" } EOS -# setup user_data.txt - -user_data="user_data_db.txt" - # instance-specific parameter cpu_cores="1" @@ -73,7 +69,6 @@ instance_id="$( --memory-size "${memory_size}" \ --ssh-key-id "${ssh_key_id}" \ --vifs "${vifs}" \ - --user-data "${user_data}" \ --display-name "${display_name}" \ | egrep ^:id: | awk '{print $2}' )" diff --git a/ciscripts/create-rbenv.sh b/ciscripts/create-rbenv.sh index 32370dc..1800b90 100755 --- a/ciscripts/create-rbenv.sh +++ b/ciscripts/create-rbenv.sh @@ -50,10 +50,6 @@ cat < "${vifs}" } EOS -# setup user_data.txt - -user_data="user_data_app.txt" - # instance-specific parameter cpu_cores="1" @@ -73,7 +69,6 @@ instance_id="$( --memory-size "${memory_size}" \ --ssh-key-id "${ssh_key_id}" \ --vifs "${vifs}" \ - --user-data "${user_data}" \ --display-name "${display_name}" \ | egrep ^:id: | awk '{print $2}' )" diff --git a/ciscripts/myaddr.sh b/ciscripts/myaddr.sh deleted file mode 100755 index 7373925..0000000 --- a/ciscripts/myaddr.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# -# -# -set -e -set -o pipefail -set -u - -# ip command: -# for i in $(/sbin/ip route get 8.8.8.8 | head -1); do echo ipaddr=${i}; done | tail -1 - -# metadata: -ipaddr="$(< /metadata/meta-data/local-ipv4)" -echo ipaddr="${ipaddr}" diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 4208288..f3c1d4a 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -6,18 +6,12 @@ set -o pipefail set -u set -x -# myaddr - -eval "$(./myaddr.sh)" -yum_host="${ipaddr}" - # run instances ## db eval "$(./runner-db.sh)" db_id="${instance_id}" -echo "YUM_HOST=${yum_host}" | tee -a user_data_app.txt ## app From c2d9f9d682dcbf55487e788b2fc1e775c30c368b Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:12:28 +0900 Subject: [PATCH 058/147] use/include retry.sh. --- ciscripts/create-app.sh | 27 +-------- ciscripts/create-centos.sh | 27 +-------- ciscripts/create-db.sh | 27 +-------- ciscripts/create-lbapp.sh | 27 +-------- ciscripts/create-lbweb.sh | 27 +-------- ciscripts/create-rbenv.sh | 27 +-------- ciscripts/instance-wait4ssh.sh | 62 +------------------- ciscripts/retry.sh | 101 +++++++++++++++++++++++++++++++++ 8 files changed, 114 insertions(+), 211 deletions(-) create mode 100644 ciscripts/retry.sh diff --git a/ciscripts/create-app.sh b/ciscripts/create-app.sh index 8250f4a..6ab0838 100755 --- a/ciscripts/create-app.sh +++ b/ciscripts/create-app.sh @@ -4,32 +4,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh # setup musselrc diff --git a/ciscripts/create-centos.sh b/ciscripts/create-centos.sh index 742bd02..c97fac7 100755 --- a/ciscripts/create-centos.sh +++ b/ciscripts/create-centos.sh @@ -4,32 +4,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh # setup musselrc diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 9a6d44d..1ec966c 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -4,32 +4,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh # setup musselrc diff --git a/ciscripts/create-lbapp.sh b/ciscripts/create-lbapp.sh index f5f163f..6eb317b 100755 --- a/ciscripts/create-lbapp.sh +++ b/ciscripts/create-lbapp.sh @@ -7,32 +7,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh ## shell params diff --git a/ciscripts/create-lbweb.sh b/ciscripts/create-lbweb.sh index 15383ce..6e7796c 100755 --- a/ciscripts/create-lbweb.sh +++ b/ciscripts/create-lbweb.sh @@ -7,32 +7,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh ## shell params diff --git a/ciscripts/create-rbenv.sh b/ciscripts/create-rbenv.sh index 1800b90..05a4edb 100755 --- a/ciscripts/create-rbenv.sh +++ b/ciscripts/create-rbenv.sh @@ -4,32 +4,9 @@ set -e set -o pipefail set -u -## functions +# include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh # setup musselrc diff --git a/ciscripts/instance-wait4ssh.sh b/ciscripts/instance-wait4ssh.sh index 1db646f..def2c70 100755 --- a/ciscripts/instance-wait4ssh.sh +++ b/ciscripts/instance-wait4ssh.sh @@ -9,67 +9,7 @@ set -u ## functions -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} - -## check - -function open_port?() { - local ipaddr=$1 protocol=$2 port=$3 - - local nc_opts="-w 3" - case ${protocol} in - tcp) ;; - udp) nc_opts="${nc_opts} -u";; - *) ;; - esac - - nc ${nc_opts} ${ipaddr} ${port} <<< "" >/dev/null -} - -function network_connection?() { - local ipaddr=$1 - ping -c 1 -W 3 ${ipaddr} -} - -## wait for *to be* - -function wait_for_network_to_be_ready() { - local ipaddr=$1 - retry_until "network_connection? ${ipaddr}" -} - -function wait_for_port_to_be_ready() { - local ipaddr=$1 protocol=$2 port=$3 - retry_until "open_port? ${ipaddr} ${protocol} ${port}" -} - -function wait_for_sshd_to_be_ready() { - local ipaddr=$1 - wait_for_port_to_be_ready ${ipaddr} tcp 22 -} +. ${BASH_SOURCE[0]%/*}/retry.sh ## shell params diff --git a/ciscripts/retry.sh b/ciscripts/retry.sh new file mode 100644 index 0000000..e2de868 --- /dev/null +++ b/ciscripts/retry.sh @@ -0,0 +1,101 @@ +# -*-Shell-script-*- +# +# requires: +# bash +# + +## retry + +function retry_until() { + local blk="$@" + + local wait_sec=${RETRY_WAIT_SEC:-120} + local sleep_sec=${RETRY_SLEEP_SEC:-3} + local tries=0 + local start_at=$(date +%s) + local chk_cmd= + + while :; do + eval "${blk}" && { + break + } || { + sleep ${sleep_sec} + } + + tries=$((${tries} + 1)) + if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then + echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 + return 1 + fi + echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 + done +} + +function retry_while() { + local blk="$@" + retry_until ! ${blk} +} + +## check + +function open_port?() { + local ipaddr=$1 protocol=$2 port=$3 + + local nc_opts="-w 3" + case ${protocol} in + tcp) ;; + udp) nc_opts="${nc_opts} -u";; + *) ;; + esac + + nc ${nc_opts} ${ipaddr} ${port} <<< "" >/dev/null +} + +function network_connection?() { + local ipaddr=$1 + ping -c 1 -W 3 ${ipaddr} +} + +## wait for *to be* + +function wait_for_network_to_be_ready() { + local ipaddr=$1 + retry_until "network_connection? ${ipaddr}" +} + +function wait_for_port_to_be_ready() { + local ipaddr=$1 protocol=$2 port=$3 + retry_until "open_port? ${ipaddr} ${protocol} ${port}" +} + +function wait_for_sshd_to_be_ready() { + local ipaddr=$1 + wait_for_port_to_be_ready ${ipaddr} tcp 22 +} + +function wait_for_httpd_to_be_ready() { + local ipaddr=$1 + wait_for_port_to_be_ready ${ipaddr} tcp 80 +} + +## wait for *not to be* + +function wait_for_network_not_to_be_ready() { + local ipaddr=$1 + retry_until "! network_connection? ${ipaddr}" +} + +function wait_for_port_not_to_be_ready() { + local ipaddr=$1 protocol=$2 port=$3 + retry_until "! open_port? ${ipaddr} ${protocol} ${port}" +} + +function wait_for_sshd_not_to_be_ready() { + local ipaddr=$1 + wait_for_port_not_to_be_ready ${ipaddr} tcp 22 +} + +function wait_for_httpd_not_to_be_ready() { + local ipaddr=$1 + wait_for_port_not_to_be_ready ${ipaddr} tcp 80 +} From f7bab3ea749e368069f90b8e8213809f2d423506 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:23:21 +0900 Subject: [PATCH 059/147] add "img" prefix. --- ciscripts/{create-db.sh => create-imgdb.sh} | 0 ciscripts/{create-rbenv.sh => create-imgrbenv.sh} | 0 ciscripts/{provision-db.sh => provision-imgdb.sh} | 0 ciscripts/{provision-rbenv.sh => provision-imgrbenv.sh} | 0 ciscripts/{runner-db.sh => runner-imgdb.sh} | 4 ++-- ciscripts/{runner-rbenv.sh => runner-imgrbenv.sh} | 4 ++-- 6 files changed, 4 insertions(+), 4 deletions(-) rename ciscripts/{create-db.sh => create-imgdb.sh} (100%) rename ciscripts/{create-rbenv.sh => create-imgrbenv.sh} (100%) rename ciscripts/{provision-db.sh => provision-imgdb.sh} (100%) rename ciscripts/{provision-rbenv.sh => provision-imgrbenv.sh} (100%) rename ciscripts/{runner-db.sh => runner-imgdb.sh} (76%) rename ciscripts/{runner-rbenv.sh => runner-imgrbenv.sh} (75%) diff --git a/ciscripts/create-db.sh b/ciscripts/create-imgdb.sh similarity index 100% rename from ciscripts/create-db.sh rename to ciscripts/create-imgdb.sh diff --git a/ciscripts/create-rbenv.sh b/ciscripts/create-imgrbenv.sh similarity index 100% rename from ciscripts/create-rbenv.sh rename to ciscripts/create-imgrbenv.sh diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-imgdb.sh similarity index 100% rename from ciscripts/provision-db.sh rename to ciscripts/provision-imgdb.sh diff --git a/ciscripts/provision-rbenv.sh b/ciscripts/provision-imgrbenv.sh similarity index 100% rename from ciscripts/provision-rbenv.sh rename to ciscripts/provision-imgrbenv.sh diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-imgdb.sh similarity index 76% rename from ciscripts/runner-db.sh rename to ciscripts/runner-imgdb.sh index a901f85..fe84448 100755 --- a/ciscripts/runner-db.sh +++ b/ciscripts/runner-imgdb.sh @@ -7,7 +7,7 @@ set -u set -x eval "$( - ./create-db.sh + ./create-imgdb.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR @@ -16,7 +16,7 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" < ./provision-db.sh + ./instance-exec.sh "${instance_id}" < ./provision-imgdb.sh } >&2 echo instance_id="${instance_id}" diff --git a/ciscripts/runner-rbenv.sh b/ciscripts/runner-imgrbenv.sh similarity index 75% rename from ciscripts/runner-rbenv.sh rename to ciscripts/runner-imgrbenv.sh index cd4ac2a..e11d215 100755 --- a/ciscripts/runner-rbenv.sh +++ b/ciscripts/runner-imgrbenv.sh @@ -7,7 +7,7 @@ set -u set -x eval "$( - ./create-rbenv.sh + ./create-imgrbenv.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR @@ -15,7 +15,7 @@ eval "$(./instance-get-ipaddr.sh "${instance_id}")" { ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" < ./provision-rbenv.sh + ./instance-exec.sh "${instance_id}" < ./provision-imgrbenv.sh } >&2 echo instance_id="${instance_id}" From a04a4a8a7566260e5e05b32a7b653293b8f92cba Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:30:57 +0900 Subject: [PATCH 060/147] add "img" prefix to display name. --- ciscripts/create-imgdb.sh | 2 +- ciscripts/create-imgrbenv.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/create-imgdb.sh b/ciscripts/create-imgdb.sh index 1ec966c..00adb24 100755 --- a/ciscripts/create-imgdb.sh +++ b/ciscripts/create-imgdb.sh @@ -33,7 +33,7 @@ cpu_cores="1" hypervisor="kvm" memory_size="1024" image_id="wmi-centos1d64" -display_name="db" +display_name="imgdb" ssh_key_id="ssh-cicddemo" ## create an instance diff --git a/ciscripts/create-imgrbenv.sh b/ciscripts/create-imgrbenv.sh index 05a4edb..9b718d0 100755 --- a/ciscripts/create-imgrbenv.sh +++ b/ciscripts/create-imgrbenv.sh @@ -33,7 +33,7 @@ cpu_cores="1" hypervisor="kvm" memory_size="1024" image_id="wmi-centos1d64" -display_name="rbenv" +display_name="imgrbenv" ssh_key_id="ssh-cicddemo" ## create an instance From 8743cdfaf92748a428a95f99348f49838b9271e7 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Mon, 25 May 2015 19:37:30 +0900 Subject: [PATCH 061/147] Fixed quote. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6ab8c9b..d3bce30 100644 --- a/README.md +++ b/README.md @@ -588,10 +588,10 @@ database_uri: 'mysql2://localhost/tiny_web_example?user=root' ``` 実行結果例: -``` -# initctl start tiny-web-example-webapi RUN=yes -tiny-web-example-webapi start/running, process 2996 -``` +>``` +># initctl start tiny-web-example-webapi RUN=yes +>tiny-web-example-webapi start/running, process 2996 +>``` ## frontendの起動 ``` @@ -599,10 +599,10 @@ tiny-web-example-webapi start/running, process 2996 ``` 実行結果例: -``` -# initctl start tiny-web-example-webapp RUN=yes -tiny-web-example-webapp start/running, process 2988 -``` +>``` +># initctl start tiny-web-example-webapp RUN=yes +>tiny-web-example-webapp start/running, process 2988 +>``` # アプリケーションの動作確認 From 6eb5705751cac94214ef67c2dca78fc90f1bc73f Mon Sep 17 00:00:00 2001 From: t-iwano Date: Mon, 25 May 2015 19:37:59 +0900 Subject: [PATCH 062/147] Added curl options. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d3bce30..e83f08f 100644 --- a/README.md +++ b/README.md @@ -610,7 +610,7 @@ database_uri: 'mysql2://localhost/tiny_web_example?user=root' POSTの確認 ``` -# curl -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' http://localhost:8080/api/0.0.1/comments +# curl -fs -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' http://localhost:8080/api/0.0.1/comments ``` 実行結果例: @@ -620,7 +620,7 @@ POSTの確認 GETの確認(list) ``` -# curl -X GET http://localhost:8080/api/0.0.1/comments +# curl -fs -X GET http://localhost:8080/api/0.0.1/comments ``` 実行結果例: @@ -630,7 +630,7 @@ GETの確認(list) GETの確認(show) ``` -# curl -X GET http://localhost:8080/api/0.0.1/comments/1 +# curl -fs -X GET http://localhost:8080/api/0.0.1/comments/1 ``` 実行結果例: From 447bac3897618e07b9bf5a96ca8b2b027d76a5a8 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:40:09 +0900 Subject: [PATCH 063/147] use retry.sh. --- ciscripts/instance-kill.sh | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/ciscripts/instance-kill.sh b/ciscripts/instance-kill.sh index 9605b6b..101eea4 100755 --- a/ciscripts/instance-kill.sh +++ b/ciscripts/instance-kill.sh @@ -7,32 +7,9 @@ set -e set -o pipefail set -u -## functions +## include -function retry_until() { - local blk="$@" - - local wait_sec=${RETRY_WAIT_SEC:-120} - local sleep_sec=${RETRY_SLEEP_SEC:-3} - local tries=0 - local start_at=$(date +%s) - local chk_cmd= - - while :; do - eval "${blk}" && { - break - } || { - sleep ${sleep_sec} - } - - tries=$((${tries} + 1)) - if [[ "$(($(date +%s) - ${start_at}))" -gt "${wait_sec}" ]]; then - echo "Retry Failure: Exceed ${wait_sec} sec: Retried ${tries} times" >&2 - return 1 - fi - echo [$(date +%FT%X) "#$$"] time:${tries} "eval:${chk_cmd}" >&2 - done -} +. ${BASH_SOURCE[0]%/*}/retry.sh ## shell params From 9dc56396b1ab4ce468346e2616f52f6da34dd4c3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:43:22 +0900 Subject: [PATCH 064/147] add scripts for new image operation. --- ciscripts/instance-commit.sh | 27 +++++++++++++++++++++++++++ ciscripts/instance-start.sh | 25 +++++++++++++++++++++++++ ciscripts/instance-stop.sh | 25 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100755 ciscripts/instance-commit.sh create mode 100755 ciscripts/instance-start.sh create mode 100755 ciscripts/instance-stop.sh diff --git a/ciscripts/instance-commit.sh b/ciscripts/instance-commit.sh new file mode 100755 index 0000000..1a1c81f --- /dev/null +++ b/ciscripts/instance-commit.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## backup an instance + +eval "$( + ${BASH_SOURCE[0]%/*}/instance-stop.sh "${instance_id}" >&2 + ${BASH_SOURCE[0]%/*}/instance-backup.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-start.sh "${instance_id}" >&2 +)" + +echo image_id="${image_id}" diff --git a/ciscripts/instance-start.sh b/ciscripts/instance-start.sh new file mode 100755 index 0000000..ab93838 --- /dev/null +++ b/ciscripts/instance-start.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## create an instance + +mussel instance poweron "${instance_id}" >/dev/null +echo "${instance_id} is starting..." >&2 + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] +echo instance_id="${instance_id}" diff --git a/ciscripts/instance-stop.sh b/ciscripts/instance-stop.sh new file mode 100755 index 0000000..d0cea36 --- /dev/null +++ b/ciscripts/instance-stop.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## create an instance + +mussel instance poweroff "${instance_id}" >/dev/null +echo "${instance_id} is halting..." >&2 + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] +echo instance_id="${instance_id}" From 77f981087be345117fcd5630eedaf488cf5d6323 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:52:15 +0900 Subject: [PATCH 065/147] add instance-backup.sh. --- ciscripts/instance-backup.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 ciscripts/instance-backup.sh diff --git a/ciscripts/instance-backup.sh b/ciscripts/instance-backup.sh new file mode 100755 index 0000000..98d80e2 --- /dev/null +++ b/ciscripts/instance-backup.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +set -u + +## include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## backup an instance + +image_id="$( + mussel instance backup "${instance_id}" \ + | egrep ^:image_id: | awk '{print $2}' +)" +: "${image_id:?"should not be empty"}" +echo "${image_id} is creating..." >&2 + +## wait for the image to be available + +retry_until [[ '"$(mussel image show "${image_id}" | egrep -w "^:state: available")"' ]] +echo image_id="${image_id}" From 876ff5b847019b68e91b26c040aae0b5a2796b26 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 19:55:01 +0900 Subject: [PATCH 066/147] add image-destroy.sh. --- ciscripts/image-destroy.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 ciscripts/image-destroy.sh diff --git a/ciscripts/image-destroy.sh b/ciscripts/image-destroy.sh new file mode 100755 index 0000000..16ecfaf --- /dev/null +++ b/ciscripts/image-destroy.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Usage: +# $0 image_id +# +set -e +set -o pipefail +set -u + +## shell params + +image_id="${1}" +: "${image_id:?"should not be empty"}" + +## main + +mussel image destroy "${image_id}" >/dev/null +echo image_id="${image_id}" From b2314e350be69dda35f5a5ce6fd11d908f57daf6 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 20:05:08 +0900 Subject: [PATCH 067/147] replace "./" with "${BASH_SOURCE[0]%/*}/". --- ciscripts/runner-app.sh | 8 ++++---- ciscripts/runner-imgdb.sh | 8 ++++---- ciscripts/runner-imgrbenv.sh | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index 44693c7..cd920b2 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -7,15 +7,15 @@ set -u set -x eval "$( - ./create-app.sh + ${BASH_SOURCE[0]%/*}/create-app.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR -eval "$(./instance-get-ipaddr.sh "${instance_id}")" +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" { - ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" < ./provision-app.sh + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-app.sh } >&2 echo instance_id="${instance_id}" diff --git a/ciscripts/runner-imgdb.sh b/ciscripts/runner-imgdb.sh index fe84448..2784d07 100755 --- a/ciscripts/runner-imgdb.sh +++ b/ciscripts/runner-imgdb.sh @@ -7,16 +7,16 @@ set -u set -x eval "$( - ./create-imgdb.sh + ${BASH_SOURCE[0]%/*}/create-imgdb.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR -eval "$(./instance-get-ipaddr.sh "${instance_id}")" +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" { - ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" < ./provision-imgdb.sh + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh } >&2 echo instance_id="${instance_id}" diff --git a/ciscripts/runner-imgrbenv.sh b/ciscripts/runner-imgrbenv.sh index e11d215..e321152 100755 --- a/ciscripts/runner-imgrbenv.sh +++ b/ciscripts/runner-imgrbenv.sh @@ -7,15 +7,15 @@ set -u set -x eval "$( - ./create-imgrbenv.sh + ${BASH_SOURCE[0]%/*}/create-imgrbenv.sh )" trap "mussel instance destroy \"${instance_id}\"" ERR -eval "$(./instance-get-ipaddr.sh "${instance_id}")" +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" { - ./instance-wait4ssh.sh "${instance_id}" - ./instance-exec.sh "${instance_id}" < ./provision-imgrbenv.sh + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgrbenv.sh } >&2 echo instance_id="${instance_id}" From 3d86ee514cf51ba59a1ef77b3aabf004516df30c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 20:12:35 +0900 Subject: [PATCH 068/147] add db set. --- ciscripts/create-db.sh | 60 +++++++++++++++++++++++++++++++++++++++ ciscripts/provision-db.sh | 9 ++++++ ciscripts/runner-db.sh | 22 ++++++++++++++ 3 files changed, 91 insertions(+) create mode 100755 ciscripts/create-db.sh create mode 100755 ciscripts/provision-db.sh create mode 100755 ciscripts/runner-db.sh diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh new file mode 100755 index 0000000..bbd5c30 --- /dev/null +++ b/ciscripts/create-db.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -u + +# include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS + +# setup vifs.json + +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS + +# instance-specific parameter + +cpu_cores="1" +hypervisor="kvm" +memory_size="1024" +image_id="wmi-kamsc50b" +display_name="db" +ssh_key_id="ssh-cicddemo" + +## create an instance + +instance_id="$( + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +trap "mussel instance destroy \"${instance_id}\"" ERR + +## wait for the instance to be running + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] +echo instance_id="${instance_id}" diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-db.sh new file mode 100755 index 0000000..b1dd0af --- /dev/null +++ b/ciscripts/provision-db.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x diff --git a/ciscripts/runner-db.sh b/ciscripts/runner-db.sh new file mode 100755 index 0000000..24ff8c4 --- /dev/null +++ b/ciscripts/runner-db.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +eval "$( + ${BASH_SOURCE[0]%/*}/create-db.sh + )" +trap "mussel instance destroy \"${instance_id}\"" ERR + +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" + +{ + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-db.sh +} >&2 + +echo instance_id="${instance_id}" +echo ipaddr="${ipaddr}" From d39f7cbb7c0055e8acd37ef13717111afaffb90e Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 20:47:15 +0900 Subject: [PATCH 069/147] add YUM_HOST and DB_HOST as required params. --- ciscripts/provision-app.sh | 13 ++++++++----- ciscripts/runner-app.sh | 12 +++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index f953070..352b31b 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -8,8 +8,10 @@ set -o pipefail set -u set -x -YUM_HOST="${YUM_HOST:-"10.0.22.100"}" -DB_HOST="${DB_HOST:-"10.0.22.101"}" +# required shell params + +: "${YUM_HOST:?"should not be empty"}" +: "${DB_HOST:?"should not be empty"}" # install tiny-web-example.repo cat <<-EOS > /etc/yum.repos.d/tiny-web-example.repo @@ -59,9 +61,10 @@ cat <<-'EOS' > /etc/default/tiny-web-example-webapp EOS # configure db host -sed -i \ - "s,^database_uri .*,database_uri 'mysql2://${DB_HOST}/tiny_web_example?user=root'," \ - /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml +for config in /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml; do + sed -i "s,'mysql://localhost/tiny_web_example?user=root','mysql2://${DB_HOST}/tiny_web_example?user=root'," ${config} + egrep ^database_uri ${config} +done # setup db cd /opt/axsh/tiny-web-example/webapi/ diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index cd920b2..db4bcae 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -6,6 +6,13 @@ set -o pipefail set -u set -x +# required shell params + +: "${YUM_HOST:?"should not be empty"}" +: "${DB_HOST:?"should not be empty"}" + +# + eval "$( ${BASH_SOURCE[0]%/*}/create-app.sh )" @@ -15,7 +22,10 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" { ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" - ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-app.sh + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ + YUM_HOST=${YUM_HOST} \ + DB_HOST=${DB_HOST} \ + bash -l < ${BASH_SOURCE[0]%/*}/provision-app.sh } >&2 echo instance_id="${instance_id}" From ade17108bc4125620df249e7378dc0c68bdcfa3a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 20:50:05 +0900 Subject: [PATCH 070/147] mem_size: 1024 -> 512 --- ciscripts/create-db.sh | 2 +- ciscripts/create-imgdb.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index bbd5c30..730162a 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -31,7 +31,7 @@ EOS cpu_cores="1" hypervisor="kvm" -memory_size="1024" +memory_size="512" image_id="wmi-kamsc50b" display_name="db" ssh_key_id="ssh-cicddemo" diff --git a/ciscripts/create-imgdb.sh b/ciscripts/create-imgdb.sh index 00adb24..9427ba8 100755 --- a/ciscripts/create-imgdb.sh +++ b/ciscripts/create-imgdb.sh @@ -31,7 +31,7 @@ EOS cpu_cores="1" hypervisor="kvm" -memory_size="1024" +memory_size="512" image_id="wmi-centos1d64" display_name="imgdb" ssh_key_id="ssh-cicddemo" From 6eb22324c81a88a6b557fd1afeb2114280155bf1 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 20:59:36 +0900 Subject: [PATCH 071/147] use lazy replacing. --- ciscripts/provision-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 352b31b..c192710 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -62,7 +62,7 @@ cat <<-'EOS' > /etc/default/tiny-web-example-webapp # configure db host for config in /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml; do - sed -i "s,'mysql://localhost/tiny_web_example?user=root','mysql2://${DB_HOST}/tiny_web_example?user=root'," ${config} + sed -i "s,localhost,${DB_HOST}," ${config} egrep ^database_uri ${config} done From cd05b65ce53818a3a7c1b54c5fe384b7e471555f Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:01:05 +0900 Subject: [PATCH 072/147] use string check with egrep. --- ciscripts/provision-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index c192710..4df1540 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -63,7 +63,7 @@ cat <<-'EOS' > /etc/default/tiny-web-example-webapp # configure db host for config in /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml; do sed -i "s,localhost,${DB_HOST}," ${config} - egrep ^database_uri ${config} + egrep "${DB_HOST}" ${config} done # setup db From 8111d7fbc2f6ac9421d0e95b57acc812c315f378 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:02:22 +0900 Subject: [PATCH 073/147] add double-quotes. --- ciscripts/provision-app.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/provision-app.sh b/ciscripts/provision-app.sh index 4df1540..a54da3a 100755 --- a/ciscripts/provision-app.sh +++ b/ciscripts/provision-app.sh @@ -62,8 +62,8 @@ cat <<-'EOS' > /etc/default/tiny-web-example-webapp # configure db host for config in /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml; do - sed -i "s,localhost,${DB_HOST}," ${config} - egrep "${DB_HOST}" ${config} + sed -i "s,localhost,${DB_HOST}," "${config}" + egrep "${DB_HOST}" "${config}" done # setup db From 5fdd80ee467ef8f4db6aaa366f109c0ecce37944 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:20:10 +0900 Subject: [PATCH 074/147] update image_id. --- ciscripts/create-db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/create-db.sh b/ciscripts/create-db.sh index 730162a..fe51037 100755 --- a/ciscripts/create-db.sh +++ b/ciscripts/create-db.sh @@ -32,7 +32,7 @@ EOS cpu_cores="1" hypervisor="kvm" memory_size="512" -image_id="wmi-kamsc50b" +image_id="wmi-xrjtduc4" display_name="db" ssh_key_id="ssh-cicddemo" From 9cbfa3e12fbd60a7098c9f23c3192f05de5f02fd Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:20:37 +0900 Subject: [PATCH 075/147] graceful shutdown mysqld. --- ciscripts/provision-imgdb.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ciscripts/provision-imgdb.sh b/ciscripts/provision-imgdb.sh index adfbd71..4e4c966 100755 --- a/ciscripts/provision-imgdb.sh +++ b/ciscripts/provision-imgdb.sh @@ -45,3 +45,14 @@ if mysql -u${dbuser} ${dbname} <<< ""; then mysqladmin -u${dbuser} drop ${dbname} <<< "Y" fi mysqladmin -uroot create ${dbname} --default-character-set=utf8 + +# stop mysqld service +service "${svc}" stop + +# wait for mysqld not to be ready +until ! mysqladmin -uroot ping; do + sleep 1 +done + +# +sync From 423e7486da7cbdbf0f78ec48d6e574fcd00de2f3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:27:43 +0900 Subject: [PATCH 076/147] add smoketest-app.sh. --- ciscripts/smoketest-app.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 ciscripts/smoketest-app.sh diff --git a/ciscripts/smoketest-app.sh b/ciscripts/smoketest-app.sh new file mode 100755 index 0000000..f6b3631 --- /dev/null +++ b/ciscripts/smoketest-app.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x + +# required shell params + +: "${API_HOST:?"should not be empty"}" + +# + +api_url="http://${API_HOST}:8080/api/0.0.1/comments" + +curl -fs -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' ${api_url} +curl -fs -X GET ${api_url} +curl -fs -X GET ${api_url}/1 From f32412e656db70289337c9e42cd4fb0a41fc29c7 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:46:22 +0900 Subject: [PATCH 077/147] update ci script. --- ciscripts/web3layers-ci.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index f3c1d4a..5ef8165 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -6,19 +6,35 @@ set -o pipefail set -u set -x +# required shell params + +: "${YUM_HOST:?"should not be empty"}" + # run instances ## db -eval "$(./runner-db.sh)" +eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" db_id="${instance_id}" +DB_HOST="${ipaddr}" ## app -eval "$(./runner-app.sh)" +eval "$( + YUM_HOST="${YUM_HOST}" \ + DB_HOST="${DB_HOST}" \ + ${BASH_SOURCE[0]%/*}/runner-app.sh + )" app_id="${instance_id}" +APP_HOST="${ipaddr}" + +# smoketest + +## app + +APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh # cleanup instances -./instance-kill.sh "${db_id}" -./instance-kill.sh "${app_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${db_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" From f1412dd6229b7a62b303881d619c7997af17be88 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 21:48:48 +0900 Subject: [PATCH 078/147] add simple http get testing. --- ciscripts/runner-app.sh | 4 ++-- ciscripts/smoketest-app.sh | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index db4bcae..1c7a9a7 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -23,8 +23,8 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" { ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ - YUM_HOST=${YUM_HOST} \ - DB_HOST=${DB_HOST} \ + YUM_HOST="${YUM_HOST}" \ + DB_HOST="${DB_HOST}" \ bash -l < ${BASH_SOURCE[0]%/*}/provision-app.sh } >&2 diff --git a/ciscripts/smoketest-app.sh b/ciscripts/smoketest-app.sh index f6b3631..1cc9a8c 100755 --- a/ciscripts/smoketest-app.sh +++ b/ciscripts/smoketest-app.sh @@ -10,12 +10,16 @@ set -x # required shell params -: "${API_HOST:?"should not be empty"}" +: "${APP_HOST:?"should not be empty"}" # -api_url="http://${API_HOST}:8080/api/0.0.1/comments" +api_url="http://${APP_HOST}:8080/api/0.0.1/comments" curl -fs -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' ${api_url} curl -fs -X GET ${api_url} curl -fs -X GET ${api_url}/1 + +# + +curl -fs -X GEt http://${APP_HOST}/ From 6d40d92295012a78c3fc6124bfefde987ef6b0f9 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Mon, 25 May 2015 23:54:32 +0900 Subject: [PATCH 079/147] add error trap. --- ciscripts/web3layers-ci.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 5ef8165..f2d7421 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -28,10 +28,20 @@ eval "$( app_id="${instance_id}" APP_HOST="${ipaddr}" +## trap + +trap " + mussel instance destroy \"${db_id}\" + mussel instance destroy \"${app_id}\" +" ERR + # smoketest ## app +## need to wait for api to be running +## need to wait for web to be running + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh # cleanup instances From 21345eb9d69d90ceaab6e737f979c58e7042b640 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 00:21:00 +0900 Subject: [PATCH 080/147] fix typo. --- ciscripts/smoketest-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/smoketest-app.sh b/ciscripts/smoketest-app.sh index 1cc9a8c..f5f2054 100755 --- a/ciscripts/smoketest-app.sh +++ b/ciscripts/smoketest-app.sh @@ -22,4 +22,4 @@ curl -fs -X GET ${api_url}/1 # -curl -fs -X GEt http://${APP_HOST}/ +curl -fs -X GET http://${APP_HOST}/ From 28ca7860237bdc56114e2b705b3d87a8bbfba61a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 00:33:16 +0900 Subject: [PATCH 081/147] wait for expected state. --- ciscripts/provision-db.sh | 5 +++++ ciscripts/runner-app.sh | 9 +++++++++ ciscripts/web3layers-ci.sh | 3 --- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ciscripts/provision-db.sh b/ciscripts/provision-db.sh index b1dd0af..82a1359 100755 --- a/ciscripts/provision-db.sh +++ b/ciscripts/provision-db.sh @@ -7,3 +7,8 @@ set -e set -o pipefail set -u set -x + +# wait for mysqld to be ready +until mysqladmin -uroot ping; do + sleep 1 +done diff --git a/ciscripts/runner-app.sh b/ciscripts/runner-app.sh index 1c7a9a7..eb66392 100755 --- a/ciscripts/runner-app.sh +++ b/ciscripts/runner-app.sh @@ -28,5 +28,14 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" bash -l < ${BASH_SOURCE[0]%/*}/provision-app.sh } >&2 +# include + +. ${BASH_SOURCE[0]%/*}/retry.sh + +{ + wait_for_port_to_be_ready "${ipaddr}" tcp 8080 + wait_for_port_to_be_ready "${ipaddr}" tcp 80 +} >&2 + echo instance_id="${instance_id}" echo ipaddr="${ipaddr}" diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index f2d7421..70cd9f6 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -39,9 +39,6 @@ trap " ## app -## need to wait for api to be running -## need to wait for web to be running - APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh # cleanup instances From a465dfbc020520cd9e2e86de2af12a3cbd9eae6a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 10:21:38 +0900 Subject: [PATCH 082/147] disable force poweroff. --- ciscripts/instance-stop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/instance-stop.sh b/ciscripts/instance-stop.sh index d0cea36..d83aa0f 100755 --- a/ciscripts/instance-stop.sh +++ b/ciscripts/instance-stop.sh @@ -18,7 +18,7 @@ instance_id="${1}" ## create an instance -mussel instance poweroff "${instance_id}" >/dev/null +mussel instance poweroff "${instance_id}" --force false >/dev/null echo "${instance_id} is halting..." >&2 retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] From d1352e055afd3812d12f3467c6e3ff569c565897 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 10:55:39 +0900 Subject: [PATCH 083/147] create "wakame-vdc" folder. --- ciscripts/{ => wakame-vdc}/create-app.sh | 0 ciscripts/{ => wakame-vdc}/create-centos.sh | 0 ciscripts/{ => wakame-vdc}/create-db.sh | 0 ciscripts/{ => wakame-vdc}/create-imgdb.sh | 0 ciscripts/{ => wakame-vdc}/create-imgrbenv.sh | 0 ciscripts/{ => wakame-vdc}/create-lbapp.sh | 0 ciscripts/{ => wakame-vdc}/create-lbweb.sh | 0 ciscripts/{ => wakame-vdc}/demokeypair | 0 ciscripts/{ => wakame-vdc}/image-destroy.sh | 0 ciscripts/{ => wakame-vdc}/instance-backup.sh | 0 ciscripts/{ => wakame-vdc}/instance-commit.sh | 0 ciscripts/{ => wakame-vdc}/instance-exec.sh | 0 ciscripts/{ => wakame-vdc}/instance-get-ipaddr.sh | 0 ciscripts/{ => wakame-vdc}/instance-kill.sh | 0 ciscripts/{ => wakame-vdc}/instance-start.sh | 0 ciscripts/{ => wakame-vdc}/instance-stop.sh | 0 ciscripts/{ => wakame-vdc}/instance-wait4ssh.sh | 0 ciscripts/{ => wakame-vdc}/provision-app.sh | 0 ciscripts/{ => wakame-vdc}/provision-db.sh | 0 ciscripts/{ => wakame-vdc}/provision-imgdb.sh | 0 ciscripts/{ => wakame-vdc}/provision-imgrbenv.sh | 0 ciscripts/{ => wakame-vdc}/retry.sh | 0 ciscripts/{ => wakame-vdc}/runner-app.sh | 0 ciscripts/{ => wakame-vdc}/runner-db.sh | 0 ciscripts/{ => wakame-vdc}/runner-imgdb.sh | 0 ciscripts/{ => wakame-vdc}/runner-imgrbenv.sh | 0 ciscripts/{ => wakame-vdc}/smoketest-app.sh | 0 ciscripts/web3layers-ci.sh | 4 ++++ 28 files changed, 4 insertions(+) rename ciscripts/{ => wakame-vdc}/create-app.sh (100%) rename ciscripts/{ => wakame-vdc}/create-centos.sh (100%) rename ciscripts/{ => wakame-vdc}/create-db.sh (100%) rename ciscripts/{ => wakame-vdc}/create-imgdb.sh (100%) rename ciscripts/{ => wakame-vdc}/create-imgrbenv.sh (100%) rename ciscripts/{ => wakame-vdc}/create-lbapp.sh (100%) rename ciscripts/{ => wakame-vdc}/create-lbweb.sh (100%) rename ciscripts/{ => wakame-vdc}/demokeypair (100%) rename ciscripts/{ => wakame-vdc}/image-destroy.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-backup.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-commit.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-exec.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-get-ipaddr.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-kill.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-start.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-stop.sh (100%) rename ciscripts/{ => wakame-vdc}/instance-wait4ssh.sh (100%) rename ciscripts/{ => wakame-vdc}/provision-app.sh (100%) rename ciscripts/{ => wakame-vdc}/provision-db.sh (100%) rename ciscripts/{ => wakame-vdc}/provision-imgdb.sh (100%) rename ciscripts/{ => wakame-vdc}/provision-imgrbenv.sh (100%) rename ciscripts/{ => wakame-vdc}/retry.sh (100%) rename ciscripts/{ => wakame-vdc}/runner-app.sh (100%) rename ciscripts/{ => wakame-vdc}/runner-db.sh (100%) rename ciscripts/{ => wakame-vdc}/runner-imgdb.sh (100%) rename ciscripts/{ => wakame-vdc}/runner-imgrbenv.sh (100%) rename ciscripts/{ => wakame-vdc}/smoketest-app.sh (100%) diff --git a/ciscripts/create-app.sh b/ciscripts/wakame-vdc/create-app.sh similarity index 100% rename from ciscripts/create-app.sh rename to ciscripts/wakame-vdc/create-app.sh diff --git a/ciscripts/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh similarity index 100% rename from ciscripts/create-centos.sh rename to ciscripts/wakame-vdc/create-centos.sh diff --git a/ciscripts/create-db.sh b/ciscripts/wakame-vdc/create-db.sh similarity index 100% rename from ciscripts/create-db.sh rename to ciscripts/wakame-vdc/create-db.sh diff --git a/ciscripts/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh similarity index 100% rename from ciscripts/create-imgdb.sh rename to ciscripts/wakame-vdc/create-imgdb.sh diff --git a/ciscripts/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh similarity index 100% rename from ciscripts/create-imgrbenv.sh rename to ciscripts/wakame-vdc/create-imgrbenv.sh diff --git a/ciscripts/create-lbapp.sh b/ciscripts/wakame-vdc/create-lbapp.sh similarity index 100% rename from ciscripts/create-lbapp.sh rename to ciscripts/wakame-vdc/create-lbapp.sh diff --git a/ciscripts/create-lbweb.sh b/ciscripts/wakame-vdc/create-lbweb.sh similarity index 100% rename from ciscripts/create-lbweb.sh rename to ciscripts/wakame-vdc/create-lbweb.sh diff --git a/ciscripts/demokeypair b/ciscripts/wakame-vdc/demokeypair similarity index 100% rename from ciscripts/demokeypair rename to ciscripts/wakame-vdc/demokeypair diff --git a/ciscripts/image-destroy.sh b/ciscripts/wakame-vdc/image-destroy.sh similarity index 100% rename from ciscripts/image-destroy.sh rename to ciscripts/wakame-vdc/image-destroy.sh diff --git a/ciscripts/instance-backup.sh b/ciscripts/wakame-vdc/instance-backup.sh similarity index 100% rename from ciscripts/instance-backup.sh rename to ciscripts/wakame-vdc/instance-backup.sh diff --git a/ciscripts/instance-commit.sh b/ciscripts/wakame-vdc/instance-commit.sh similarity index 100% rename from ciscripts/instance-commit.sh rename to ciscripts/wakame-vdc/instance-commit.sh diff --git a/ciscripts/instance-exec.sh b/ciscripts/wakame-vdc/instance-exec.sh similarity index 100% rename from ciscripts/instance-exec.sh rename to ciscripts/wakame-vdc/instance-exec.sh diff --git a/ciscripts/instance-get-ipaddr.sh b/ciscripts/wakame-vdc/instance-get-ipaddr.sh similarity index 100% rename from ciscripts/instance-get-ipaddr.sh rename to ciscripts/wakame-vdc/instance-get-ipaddr.sh diff --git a/ciscripts/instance-kill.sh b/ciscripts/wakame-vdc/instance-kill.sh similarity index 100% rename from ciscripts/instance-kill.sh rename to ciscripts/wakame-vdc/instance-kill.sh diff --git a/ciscripts/instance-start.sh b/ciscripts/wakame-vdc/instance-start.sh similarity index 100% rename from ciscripts/instance-start.sh rename to ciscripts/wakame-vdc/instance-start.sh diff --git a/ciscripts/instance-stop.sh b/ciscripts/wakame-vdc/instance-stop.sh similarity index 100% rename from ciscripts/instance-stop.sh rename to ciscripts/wakame-vdc/instance-stop.sh diff --git a/ciscripts/instance-wait4ssh.sh b/ciscripts/wakame-vdc/instance-wait4ssh.sh similarity index 100% rename from ciscripts/instance-wait4ssh.sh rename to ciscripts/wakame-vdc/instance-wait4ssh.sh diff --git a/ciscripts/provision-app.sh b/ciscripts/wakame-vdc/provision-app.sh similarity index 100% rename from ciscripts/provision-app.sh rename to ciscripts/wakame-vdc/provision-app.sh diff --git a/ciscripts/provision-db.sh b/ciscripts/wakame-vdc/provision-db.sh similarity index 100% rename from ciscripts/provision-db.sh rename to ciscripts/wakame-vdc/provision-db.sh diff --git a/ciscripts/provision-imgdb.sh b/ciscripts/wakame-vdc/provision-imgdb.sh similarity index 100% rename from ciscripts/provision-imgdb.sh rename to ciscripts/wakame-vdc/provision-imgdb.sh diff --git a/ciscripts/provision-imgrbenv.sh b/ciscripts/wakame-vdc/provision-imgrbenv.sh similarity index 100% rename from ciscripts/provision-imgrbenv.sh rename to ciscripts/wakame-vdc/provision-imgrbenv.sh diff --git a/ciscripts/retry.sh b/ciscripts/wakame-vdc/retry.sh similarity index 100% rename from ciscripts/retry.sh rename to ciscripts/wakame-vdc/retry.sh diff --git a/ciscripts/runner-app.sh b/ciscripts/wakame-vdc/runner-app.sh similarity index 100% rename from ciscripts/runner-app.sh rename to ciscripts/wakame-vdc/runner-app.sh diff --git a/ciscripts/runner-db.sh b/ciscripts/wakame-vdc/runner-db.sh similarity index 100% rename from ciscripts/runner-db.sh rename to ciscripts/wakame-vdc/runner-db.sh diff --git a/ciscripts/runner-imgdb.sh b/ciscripts/wakame-vdc/runner-imgdb.sh similarity index 100% rename from ciscripts/runner-imgdb.sh rename to ciscripts/wakame-vdc/runner-imgdb.sh diff --git a/ciscripts/runner-imgrbenv.sh b/ciscripts/wakame-vdc/runner-imgrbenv.sh similarity index 100% rename from ciscripts/runner-imgrbenv.sh rename to ciscripts/wakame-vdc/runner-imgrbenv.sh diff --git a/ciscripts/smoketest-app.sh b/ciscripts/wakame-vdc/smoketest-app.sh similarity index 100% rename from ciscripts/smoketest-app.sh rename to ciscripts/wakame-vdc/smoketest-app.sh diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 70cd9f6..fcad57d 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -10,6 +10,10 @@ set -x : "${YUM_HOST:?"should not be empty"}" +# + +cd ${BASH_SOURCE[0]%/*}/wakame-vdc + # run instances ## db From b6fdd21aa114d07a44948c78598931dd6109bcf7 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 12:34:23 +0900 Subject: [PATCH 084/147] export musselrc generation procedure to gen-musselrc.sh. --- ciscripts/wakame-vdc/create-app.sh | 5 +---- ciscripts/wakame-vdc/create-centos.sh | 5 +---- ciscripts/wakame-vdc/create-db.sh | 5 +---- ciscripts/wakame-vdc/create-imgdb.sh | 5 +---- ciscripts/wakame-vdc/create-imgrbenv.sh | 5 +---- ciscripts/wakame-vdc/gen-musselrc.sh | 12 ++++++++++++ 6 files changed, 17 insertions(+), 20 deletions(-) create mode 100755 ciscripts/wakame-vdc/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 6ab0838..e424b4f 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -10,10 +10,7 @@ set -u # setup musselrc -cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 -account_id=a-shpoolxx -EOS +${BASH_SOURCE[0]%/*}/gen-musselrc.sh # setup vifs.json diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index c97fac7..43503f4 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -10,10 +10,7 @@ set -u # setup musselrc -cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 -account_id=a-shpoolxx -EOS +${BASH_SOURCE[0]%/*}/gen-musselrc.sh # setup vifs.json diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index fe51037..a9cf584 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -10,10 +10,7 @@ set -u # setup musselrc -cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 -account_id=a-shpoolxx -EOS +${BASH_SOURCE[0]%/*}/gen-musselrc.sh # setup vifs.json diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 9427ba8..646b47f 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -10,10 +10,7 @@ set -u # setup musselrc -cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 -account_id=a-shpoolxx -EOS +${BASH_SOURCE[0]%/*}/gen-musselrc.sh # setup vifs.json diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index 9b718d0..9426d75 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -10,10 +10,7 @@ set -u # setup musselrc -cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 -account_id=a-shpoolxx -EOS +${BASH_SOURCE[0]%/*}/gen-musselrc.sh # setup vifs.json diff --git a/ciscripts/wakame-vdc/gen-musselrc.sh b/ciscripts/wakame-vdc/gen-musselrc.sh new file mode 100755 index 0000000..4432100 --- /dev/null +++ b/ciscripts/wakame-vdc/gen-musselrc.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -u + +# setup musselrc + +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS From e19837896f365ef1b218391a6333cfd854fd85a1 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 12:48:15 +0900 Subject: [PATCH 085/147] export vifs.json generation procedure to gen-vifs.sh. --- ciscripts/wakame-vdc/create-app.sh | 6 +----- ciscripts/wakame-vdc/create-centos.sh | 6 +----- ciscripts/wakame-vdc/create-db.sh | 6 +----- ciscripts/wakame-vdc/create-imgdb.sh | 6 +----- ciscripts/wakame-vdc/create-imgrbenv.sh | 6 +----- ciscripts/wakame-vdc/gen-vifs.sh | 11 +++++++++++ 6 files changed, 16 insertions(+), 25 deletions(-) create mode 100755 ciscripts/wakame-vdc/gen-vifs.sh diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index e424b4f..5a824ed 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -18,11 +18,7 @@ network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -cat < "${vifs}" -{ - "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} -} -EOS +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh # instance-specific parameter diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 43503f4..93d3e2b 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -18,11 +18,7 @@ network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -cat < "${vifs}" -{ - "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} -} -EOS +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh # instance-specific parameter diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index a9cf584..23bae78 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -18,11 +18,7 @@ network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -cat < "${vifs}" -{ - "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} -} -EOS +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh # instance-specific parameter diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 646b47f..a7091dc 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -18,11 +18,7 @@ network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -cat < "${vifs}" -{ - "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} -} -EOS +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh # instance-specific parameter diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index 9426d75..a43b92f 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -18,11 +18,7 @@ network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -cat < "${vifs}" -{ - "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} -} -EOS +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh # instance-specific parameter diff --git a/ciscripts/wakame-vdc/gen-vifs.sh b/ciscripts/wakame-vdc/gen-vifs.sh new file mode 100755 index 0000000..71bfbe3 --- /dev/null +++ b/ciscripts/wakame-vdc/gen-vifs.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +set -e +set -o pipefail +set -u + +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS From 7f6f54d9b9c7f61474505aa06a5b23734763f28b Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 13:15:24 +0900 Subject: [PATCH 086/147] organize code layout. --- ciscripts/wakame-vdc/create-app.sh | 6 ++---- ciscripts/wakame-vdc/create-centos.sh | 6 ++---- ciscripts/wakame-vdc/create-db.sh | 6 ++---- ciscripts/wakame-vdc/create-imgdb.sh | 6 ++---- ciscripts/wakame-vdc/create-imgrbenv.sh | 6 ++---- ciscripts/wakame-vdc/create-lbapp.sh | 6 ++---- ciscripts/wakame-vdc/create-lbweb.sh | 6 ++---- ciscripts/wakame-vdc/instance-backup.sh | 6 ++---- ciscripts/wakame-vdc/instance-commit.sh | 4 ---- ciscripts/wakame-vdc/instance-kill.sh | 6 ++---- ciscripts/wakame-vdc/instance-start.sh | 6 ++---- ciscripts/wakame-vdc/instance-stop.sh | 6 ++---- ciscripts/wakame-vdc/instance-wait4ssh.sh | 6 ++---- 13 files changed, 24 insertions(+), 52 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 5a824ed..f1bfde2 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -4,10 +4,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - # setup musselrc ${BASH_SOURCE[0]%/*}/gen-musselrc.sh @@ -49,5 +45,7 @@ trap "mussel instance destroy \"${instance_id}\"" ERR ## wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 93d3e2b..10ee694 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -4,10 +4,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - # setup musselrc ${BASH_SOURCE[0]%/*}/gen-musselrc.sh @@ -49,5 +45,7 @@ trap "mussel instance destroy \"${instance_id}\"" ERR ## wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 23bae78..669cb57 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -4,10 +4,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - # setup musselrc ${BASH_SOURCE[0]%/*}/gen-musselrc.sh @@ -49,5 +45,7 @@ trap "mussel instance destroy \"${instance_id}\"" ERR ## wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index a7091dc..55b38cf 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -4,10 +4,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - # setup musselrc ${BASH_SOURCE[0]%/*}/gen-musselrc.sh @@ -49,5 +45,7 @@ trap "mussel instance destroy \"${instance_id}\"" ERR ## wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index a43b92f..d365ecf 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -4,10 +4,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - # setup musselrc ${BASH_SOURCE[0]%/*}/gen-musselrc.sh @@ -49,5 +45,7 @@ trap "mussel instance destroy \"${instance_id}\"" ERR ## wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/create-lbapp.sh b/ciscripts/wakame-vdc/create-lbapp.sh index 6eb317b..ff05b8c 100755 --- a/ciscripts/wakame-vdc/create-lbapp.sh +++ b/ciscripts/wakame-vdc/create-lbapp.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params balance_algorithm="leastconn" @@ -48,5 +44,7 @@ trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR ## wait for the load_balancer to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/wakame-vdc/create-lbweb.sh b/ciscripts/wakame-vdc/create-lbweb.sh index 6e7796c..6cf45b4 100755 --- a/ciscripts/wakame-vdc/create-lbweb.sh +++ b/ciscripts/wakame-vdc/create-lbweb.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params balance_algorithm="leastconn" @@ -48,5 +44,7 @@ trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR ## wait for the load_balancer to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: running")"' ]] echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/wakame-vdc/instance-backup.sh b/ciscripts/wakame-vdc/instance-backup.sh index 98d80e2..ead5ec8 100755 --- a/ciscripts/wakame-vdc/instance-backup.sh +++ b/ciscripts/wakame-vdc/instance-backup.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" @@ -27,5 +23,7 @@ echo "${image_id} is creating..." >&2 ## wait for the image to be available +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel image show "${image_id}" | egrep -w "^:state: available")"' ]] echo image_id="${image_id}" diff --git a/ciscripts/wakame-vdc/instance-commit.sh b/ciscripts/wakame-vdc/instance-commit.sh index 1a1c81f..180b60e 100755 --- a/ciscripts/wakame-vdc/instance-commit.sh +++ b/ciscripts/wakame-vdc/instance-commit.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" diff --git a/ciscripts/wakame-vdc/instance-kill.sh b/ciscripts/wakame-vdc/instance-kill.sh index 101eea4..72a4257 100755 --- a/ciscripts/wakame-vdc/instance-kill.sh +++ b/ciscripts/wakame-vdc/instance-kill.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" @@ -21,5 +17,7 @@ instance_id="${1}" mussel instance destroy "${instance_id}" >/dev/null echo "${instance_id} is shuttingdown..." >&2 +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: terminated")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/instance-start.sh b/ciscripts/wakame-vdc/instance-start.sh index ab93838..6497287 100755 --- a/ciscripts/wakame-vdc/instance-start.sh +++ b/ciscripts/wakame-vdc/instance-start.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" @@ -21,5 +17,7 @@ instance_id="${1}" mussel instance poweron "${instance_id}" >/dev/null echo "${instance_id} is starting..." >&2 +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/instance-stop.sh b/ciscripts/wakame-vdc/instance-stop.sh index d83aa0f..2a2690a 100755 --- a/ciscripts/wakame-vdc/instance-stop.sh +++ b/ciscripts/wakame-vdc/instance-stop.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## include - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" @@ -21,5 +17,7 @@ instance_id="${1}" mussel instance poweroff "${instance_id}" --force false >/dev/null echo "${instance_id} is halting..." >&2 +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] echo instance_id="${instance_id}" diff --git a/ciscripts/wakame-vdc/instance-wait4ssh.sh b/ciscripts/wakame-vdc/instance-wait4ssh.sh index def2c70..c6712e3 100755 --- a/ciscripts/wakame-vdc/instance-wait4ssh.sh +++ b/ciscripts/wakame-vdc/instance-wait4ssh.sh @@ -7,10 +7,6 @@ set -e set -o pipefail set -u -## functions - -. ${BASH_SOURCE[0]%/*}/retry.sh - ## shell params instance_id="${1}" @@ -18,6 +14,8 @@ instance_id="${1}" ## wait... +. ${BASH_SOURCE[0]%/*}/retry.sh + retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] ## get the instance's ipaddress From 0b7f28cd189558234865be3e47c114bf0c8eb99a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 13:27:31 +0900 Subject: [PATCH 087/147] organize code layout. --- ciscripts/wakame-vdc/create-app.sh | 11 ++++------- ciscripts/wakame-vdc/create-db.sh | 11 ++++------- ciscripts/wakame-vdc/create-imgdb.sh | 11 ++++------- ciscripts/wakame-vdc/create-imgrbenv.sh | 11 ++++------- ciscripts/wakame-vdc/create-lbapp.sh | 2 ++ ciscripts/wakame-vdc/create-lbweb.sh | 2 ++ 6 files changed, 20 insertions(+), 28 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index f1bfde2..ba17746 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -4,18 +4,12 @@ set -e set -o pipefail set -u -# setup musselrc - -${BASH_SOURCE[0]%/*}/gen-musselrc.sh - -# setup vifs.json +# vifs network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh - # instance-specific parameter cpu_cores="1" @@ -27,6 +21,9 @@ ssh_key_id="ssh-cicddemo" ## create an instance +${BASH_SOURCE[0]%/*}/gen-musselrc.sh +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh + instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 669cb57..88698c3 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -4,18 +4,12 @@ set -e set -o pipefail set -u -# setup musselrc - -${BASH_SOURCE[0]%/*}/gen-musselrc.sh - -# setup vifs.json +# vifs network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh - # instance-specific parameter cpu_cores="1" @@ -27,6 +21,9 @@ ssh_key_id="ssh-cicddemo" ## create an instance +${BASH_SOURCE[0]%/*}/gen-musselrc.sh +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh + instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 55b38cf..68999b4 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -4,18 +4,12 @@ set -e set -o pipefail set -u -# setup musselrc - -${BASH_SOURCE[0]%/*}/gen-musselrc.sh - -# setup vifs.json +# vifs network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh - # instance-specific parameter cpu_cores="1" @@ -27,6 +21,9 @@ ssh_key_id="ssh-cicddemo" ## create an instance +${BASH_SOURCE[0]%/*}/gen-musselrc.sh +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh + instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index d365ecf..b82e51e 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -4,18 +4,12 @@ set -e set -o pipefail set -u -# setup musselrc - -${BASH_SOURCE[0]%/*}/gen-musselrc.sh - -# setup vifs.json +# vifs network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh - # instance-specific parameter cpu_cores="1" @@ -27,6 +21,9 @@ ssh_key_id="ssh-cicddemo" ## create an instance +${BASH_SOURCE[0]%/*}/gen-musselrc.sh +. ${BASH_SOURCE[0]%/*}/gen-vifs.sh + instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ diff --git a/ciscripts/wakame-vdc/create-lbapp.sh b/ciscripts/wakame-vdc/create-lbapp.sh index ff05b8c..fde4beb 100755 --- a/ciscripts/wakame-vdc/create-lbapp.sh +++ b/ciscripts/wakame-vdc/create-lbapp.sh @@ -19,6 +19,8 @@ display_name="lb8080" ## create a load_balancer +${BASH_SOURCE[0]%/*}/gen-musselrc.sh + load_balancer_id="$( mussel load_balancer create \ --balance-algorithm "${balance_algorithm}" \ diff --git a/ciscripts/wakame-vdc/create-lbweb.sh b/ciscripts/wakame-vdc/create-lbweb.sh index 6cf45b4..5e4d1dc 100755 --- a/ciscripts/wakame-vdc/create-lbweb.sh +++ b/ciscripts/wakame-vdc/create-lbweb.sh @@ -19,6 +19,8 @@ display_name="lb80" ## create a load_balancer +${BASH_SOURCE[0]%/*}/gen-musselrc.sh + load_balancer_id="$( mussel load_balancer create \ --balance-algorithm "${balance_algorithm}" \ From 63d865270cbba254a8eaea029963f4c8bdf93c81 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 13:33:43 +0900 Subject: [PATCH 088/147] organize code layout. --- ciscripts/wakame-vdc/runner-app.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ciscripts/wakame-vdc/runner-app.sh b/ciscripts/wakame-vdc/runner-app.sh index eb66392..5c48cf9 100755 --- a/ciscripts/wakame-vdc/runner-app.sh +++ b/ciscripts/wakame-vdc/runner-app.sh @@ -28,11 +28,9 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" bash -l < ${BASH_SOURCE[0]%/*}/provision-app.sh } >&2 -# include - -. ${BASH_SOURCE[0]%/*}/retry.sh - { + . ${BASH_SOURCE[0]%/*}/retry.sh + wait_for_port_to_be_ready "${ipaddr}" tcp 8080 wait_for_port_to_be_ready "${ipaddr}" tcp 80 } >&2 From a5edd7bf22eaa96d50bfc7d72769589d4e533d29 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 13:41:33 +0900 Subject: [PATCH 089/147] update README. --- ciscripts/README.md | 13 +++---------- ciscripts/wakame-vdc/README.md | 8 ++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 ciscripts/wakame-vdc/README.md diff --git a/ciscripts/README.md b/ciscripts/README.md index 390b8d6..14afe68 100644 --- a/ciscripts/README.md +++ b/ciscripts/README.md @@ -1,12 +1,3 @@ -## Script Chain - -1. run `runner-app.sh` - 1. run `create-app.sh` - 2. run `provision-app.sh` -2. run `runner-db.sh` - 1. run `create-db.sh` - 2. run `provision-db.sh` - ## JenkinsCI Add the following code to JenkinsCI shell job. @@ -22,5 +13,7 @@ set -x cd ciscripts ls -l -./web3layers-ci.sh + +ipaddr="$(< /metadata/meta-data/local-ipv4)" +YUM_HOST="${ipaddr}" ./web3layers-ci.sh ``` diff --git a/ciscripts/wakame-vdc/README.md b/ciscripts/wakame-vdc/README.md new file mode 100644 index 0000000..b55952d --- /dev/null +++ b/ciscripts/wakame-vdc/README.md @@ -0,0 +1,8 @@ +## Script Chain + +1. run `runner-app.sh` + 1. run `create-app.sh` + 2. run `provision-app.sh` +2. run `runner-db.sh` + 1. run `create-db.sh` + 2. run `provision-db.sh` From 53a7b982d33bbed2fb9ba57604bbb27e71b0ed1f Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 13:43:39 +0900 Subject: [PATCH 090/147] add .gitignore. --- ciscripts/wakame-vdc/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 ciscripts/wakame-vdc/.gitignore diff --git a/ciscripts/wakame-vdc/.gitignore b/ciscripts/wakame-vdc/.gitignore new file mode 100644 index 0000000..74afec2 --- /dev/null +++ b/ciscripts/wakame-vdc/.gitignore @@ -0,0 +1 @@ +vifs.json From 234ed8e2cff26402f0996cb56dafd6a18eb12bd7 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 14:01:50 +0900 Subject: [PATCH 091/147] handle runner mode. --- ciscripts/web3layers-ci.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index fcad57d..64366c5 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -43,7 +43,14 @@ trap " ## app -APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh +if [[ -n "${JENKINS_HOME:-""}" ]]; then + # called by jenkins + # TODO + echo not implemented so far. +else + # stand alone + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh +fi # cleanup instances From 941c7433d92899b41c59bce64a3e87015b0b3717 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 14:11:14 +0900 Subject: [PATCH 092/147] mode: 644 -> 755 --- ciscripts/create-repo.sh | 0 ciscripts/rpm-build.sh | 0 ciscripts/unit-test.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 ciscripts/create-repo.sh mode change 100644 => 100755 ciscripts/rpm-build.sh mode change 100644 => 100755 ciscripts/unit-test.sh diff --git a/ciscripts/create-repo.sh b/ciscripts/create-repo.sh old mode 100644 new mode 100755 diff --git a/ciscripts/rpm-build.sh b/ciscripts/rpm-build.sh old mode 100644 new mode 100755 diff --git a/ciscripts/unit-test.sh b/ciscripts/unit-test.sh old mode 100644 new mode 100755 From 01a8e8a8cffdff8b7203d621f80f228972efa039 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 14:25:48 +0900 Subject: [PATCH 093/147] add integration-test.sh. --- ciscripts/integration-test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 ciscripts/integration-test.sh diff --git a/ciscripts/integration-test.sh b/ciscripts/integration-test.sh new file mode 100755 index 0000000..a1144a8 --- /dev/null +++ b/ciscripts/integration-test.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# +set -e +set -x +set -o pipefail + +cd spec_integration + +bundle install +cp config/webapi.conf.example config/webapi.conf +bundle exec rspec ./spec/webapi_integration_spec.rb From c7b7455d9ab59e1bfcd61b41c7140df7d9c3cdc1 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 15:13:59 +0900 Subject: [PATCH 094/147] add runner-lb*.sh. --- ciscripts/wakame-vdc/runner-lbapp.sh | 1 + ciscripts/wakame-vdc/runner-lbweb.sh | 1 + 2 files changed, 2 insertions(+) create mode 120000 ciscripts/wakame-vdc/runner-lbapp.sh create mode 120000 ciscripts/wakame-vdc/runner-lbweb.sh diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/runner-lbapp.sh new file mode 120000 index 0000000..0efc07d --- /dev/null +++ b/ciscripts/wakame-vdc/runner-lbapp.sh @@ -0,0 +1 @@ +create-lbapp.sh \ No newline at end of file diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/runner-lbweb.sh new file mode 120000 index 0000000..b653fe7 --- /dev/null +++ b/ciscripts/wakame-vdc/runner-lbweb.sh @@ -0,0 +1 @@ +create-lbweb.sh \ No newline at end of file From b0de30996d509edbca01b8cdfddf170f30c9b9a7 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 19:19:47 +0900 Subject: [PATCH 095/147] show app-instance vif. --- ciscripts/wakame-vdc/instance-get-vif.sh | 28 ++++++++++++++++++++++++ ciscripts/wakame-vdc/runner-app.sh | 2 ++ 2 files changed, 30 insertions(+) create mode 100755 ciscripts/wakame-vdc/instance-get-vif.sh diff --git a/ciscripts/wakame-vdc/instance-get-vif.sh b/ciscripts/wakame-vdc/instance-get-vif.sh new file mode 100755 index 0000000..7bddf1d --- /dev/null +++ b/ciscripts/wakame-vdc/instance-get-vif.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Usage: +# $0 instance_id +# +set -e +set -o pipefail +#set -u + +## include + +## shell params + +instance_id="${1}" +: "${instance_id:?"should not be empty"}" + +## get the instance's vifs + +vif="$( + mussel instance show "${instance_id}" | egrep :vif_id: \ + | awk '{print $3}' \ + | tr '\n' ',' +)" +: "${vif:?"should not be empty"}" + +## show the instance + +echo vif="${vif%%,}" diff --git a/ciscripts/wakame-vdc/runner-app.sh b/ciscripts/wakame-vdc/runner-app.sh index 5c48cf9..88ea123 100755 --- a/ciscripts/wakame-vdc/runner-app.sh +++ b/ciscripts/wakame-vdc/runner-app.sh @@ -19,6 +19,7 @@ eval "$( trap "mussel instance destroy \"${instance_id}\"" ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" +eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" { ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" @@ -37,3 +38,4 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" echo instance_id="${instance_id}" echo ipaddr="${ipaddr}" +echo vif="${vif}" From 4caf6efc9a3059f8aebb4a8271a6359f9cb2be5c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 19:44:39 +0900 Subject: [PATCH 096/147] add load_balancer scripts. --- .../wakame-vdc/load_balancer-get-ipaddr.sh | 32 +++++++++++++++++++ ciscripts/wakame-vdc/load_balancer-kill.sh | 29 +++++++++++++++++ .../wakame-vdc/load_balancer-register.sh | 29 +++++++++++++++++ .../wakame-vdc/load_balancer-unregister.sh | 29 +++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100755 ciscripts/wakame-vdc/load_balancer-get-ipaddr.sh create mode 100755 ciscripts/wakame-vdc/load_balancer-kill.sh create mode 100755 ciscripts/wakame-vdc/load_balancer-register.sh create mode 100755 ciscripts/wakame-vdc/load_balancer-unregister.sh diff --git a/ciscripts/wakame-vdc/load_balancer-get-ipaddr.sh b/ciscripts/wakame-vdc/load_balancer-get-ipaddr.sh new file mode 100755 index 0000000..77535a3 --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-get-ipaddr.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +set -u + +## include + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" + +## get the load_balancer's ipaddress + +ipaddr="$( + mussel load_balancer show "${load_balancer_id}" | egrep :address: \ + | awk '{print $2}' \ + | tr '\n' ',' +)" +: "${ipaddr:?"should not be empty"}" + +## show the load_balancer + +ipaddr="${ipaddr%%,}" + +echo ipaddr="${ipaddr}" +echo ipaddr_public="${ipaddr%,*}" +echo ipaddr_managed="${ipaddr#*,}" diff --git a/ciscripts/wakame-vdc/load_balancer-kill.sh b/ciscripts/wakame-vdc/load_balancer-kill.sh new file mode 100755 index 0000000..05f603d --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-kill.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +set -u + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" + +## main + +while read network_vif_id; do + ${BASH_SOURCE[0]%/*}/load_balancer-unregister.sh "${load_balancer_id}" "${network_vif_id}" >/dev/null +done < <(mussel load_balancer show "${load_balancer_id}" | egrep network_vif_id | awk '{print $3}') + +mussel load_balancer destroy "${load_balancer_id}" >/dev/null +echo "${load_balancer_id} is shuttingdown..." >&2 + +## + +. ${BASH_SOURCE[0]%/*}/retry.sh + +retry_until [[ '"$(mussel load_balancer show "${load_balancer_id}" | egrep -w "^:state: terminated")"' ]] +echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/wakame-vdc/load_balancer-register.sh b/ciscripts/wakame-vdc/load_balancer-register.sh new file mode 100755 index 0000000..5263530 --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-register.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +#set -u + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" +shift +vifs="${@:-""}" +: "${vifs:?"should not be empty"}" + +## register vifs to the load_balancer + +network_vif_id= +while [[ "${1:-""}" ]]; do + network_vif_id="${1}" + echo "registering ${network_vif_id} to ${load_balancer_id}..." >&2 + mussel load_balancer register "${load_balancer_id}" \ + --vifs "${network_vif_id}" >/dev/null + shift +done + +echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/wakame-vdc/load_balancer-unregister.sh b/ciscripts/wakame-vdc/load_balancer-unregister.sh new file mode 100755 index 0000000..430ed9f --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-unregister.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +#set -u + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" +shift +vifs="${@:-""}" +: "${vifs:?"should not be empty"}" + +## unregister vifs to the load_balancer + +network_vif_id= +while [[ "${1:-""}" ]]; do + network_vif_id="${1}" + echo "ununregistering ${network_vif_id} from ${load_balancer_id}..." >&2 + mussel load_balancer unregister "${load_balancer_id}" \ + --vifs "${network_vif_id}" >/dev/null + shift +done + +echo load_balancer_id="${load_balancer_id}" From c50fc6820b2cdc4a15f8a75342ea795fa1d182c0 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 19:52:34 +0900 Subject: [PATCH 097/147] add load_balancer-register/unregister-instance. --- .../load_balancer-register-instance.sh | 29 +++++++++++++++++++ .../load_balancer-unregister-instance.sh | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 ciscripts/wakame-vdc/load_balancer-register-instance.sh create mode 100755 ciscripts/wakame-vdc/load_balancer-unregister-instance.sh diff --git a/ciscripts/wakame-vdc/load_balancer-register-instance.sh b/ciscripts/wakame-vdc/load_balancer-register-instance.sh new file mode 100755 index 0000000..2939bd7 --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-register-instance.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +#set -u + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" +shift +instance_ids="${@:-""}" +: "${instance_ids:?"should not be empty"}" + +## register instances to the load_balancer + +instance_id= +while [[ "${1:-""}" ]]; do + instance_id="${1}" + echo "registering ${instance_id} to ${load_balancer_id}..." >&2 + eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" + ${BASH_SOURCE[0]%/*}/load_balancer-register.sh "${load_balancer_id}" ${vif} >/dev/null + shift +done + +echo load_balancer_id="${load_balancer_id}" diff --git a/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh b/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh new file mode 100755 index 0000000..9b013d9 --- /dev/null +++ b/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: +# $0 load_balancer_id +# +set -e +set -o pipefail +#set -u + +## shell params + +load_balancer_id="${1}" +: "${load_balancer_id:?"should not be empty"}" +shift +instance_ids="${@:-""}" +: "${instance_ids:?"should not be empty"}" + +## unregister instances from the load_balancer + +instance_id= +while [[ "${1:-""}" ]]; do + instance_id="${1}" + echo "unregister ${instance_id} from ${load_balancer_id}..." >&2 + eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" + ${BASH_SOURCE[0]%/*}/load_balancer-unregister.sh "${load_balancer_id}" ${vif} >/dev/null + shift +done + +echo load_balancer_id="${load_balancer_id}" From 2206da889bdac5add1e97d4c22cc97ebcda6dafd Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:01:01 +0900 Subject: [PATCH 098/147] remove vif from output. --- ciscripts/wakame-vdc/runner-app.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ciscripts/wakame-vdc/runner-app.sh b/ciscripts/wakame-vdc/runner-app.sh index 88ea123..5c48cf9 100755 --- a/ciscripts/wakame-vdc/runner-app.sh +++ b/ciscripts/wakame-vdc/runner-app.sh @@ -19,7 +19,6 @@ eval "$( trap "mussel instance destroy \"${instance_id}\"" ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" -eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" { ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" @@ -38,4 +37,3 @@ eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" echo instance_id="${instance_id}" echo ipaddr="${ipaddr}" -echo vif="${vif}" From 875d1d93314bf2992b6cb5b81cd0f9a948c4300e Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:05:17 +0900 Subject: [PATCH 099/147] add "-vif". --- ciscripts/wakame-vdc/load_balancer-kill.sh | 2 +- ciscripts/wakame-vdc/load_balancer-register-instance.sh | 2 +- ...{load_balancer-register.sh => load_balancer-register-vif.sh} | 0 ciscripts/wakame-vdc/load_balancer-unregister-instance.sh | 2 +- ...d_balancer-unregister.sh => load_balancer-unregister-vif.sh} | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename ciscripts/wakame-vdc/{load_balancer-register.sh => load_balancer-register-vif.sh} (100%) rename ciscripts/wakame-vdc/{load_balancer-unregister.sh => load_balancer-unregister-vif.sh} (100%) diff --git a/ciscripts/wakame-vdc/load_balancer-kill.sh b/ciscripts/wakame-vdc/load_balancer-kill.sh index 05f603d..d24219a 100755 --- a/ciscripts/wakame-vdc/load_balancer-kill.sh +++ b/ciscripts/wakame-vdc/load_balancer-kill.sh @@ -15,7 +15,7 @@ load_balancer_id="${1}" ## main while read network_vif_id; do - ${BASH_SOURCE[0]%/*}/load_balancer-unregister.sh "${load_balancer_id}" "${network_vif_id}" >/dev/null + ${BASH_SOURCE[0]%/*}/load_balancer-unregister-vif.sh "${load_balancer_id}" "${network_vif_id}" >/dev/null done < <(mussel load_balancer show "${load_balancer_id}" | egrep network_vif_id | awk '{print $3}') mussel load_balancer destroy "${load_balancer_id}" >/dev/null diff --git a/ciscripts/wakame-vdc/load_balancer-register-instance.sh b/ciscripts/wakame-vdc/load_balancer-register-instance.sh index 2939bd7..d5a1167 100755 --- a/ciscripts/wakame-vdc/load_balancer-register-instance.sh +++ b/ciscripts/wakame-vdc/load_balancer-register-instance.sh @@ -22,7 +22,7 @@ while [[ "${1:-""}" ]]; do instance_id="${1}" echo "registering ${instance_id} to ${load_balancer_id}..." >&2 eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" - ${BASH_SOURCE[0]%/*}/load_balancer-register.sh "${load_balancer_id}" ${vif} >/dev/null + ${BASH_SOURCE[0]%/*}/load_balancer-register-vif.sh "${load_balancer_id}" ${vif} >/dev/null shift done diff --git a/ciscripts/wakame-vdc/load_balancer-register.sh b/ciscripts/wakame-vdc/load_balancer-register-vif.sh similarity index 100% rename from ciscripts/wakame-vdc/load_balancer-register.sh rename to ciscripts/wakame-vdc/load_balancer-register-vif.sh diff --git a/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh b/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh index 9b013d9..656831c 100755 --- a/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh +++ b/ciscripts/wakame-vdc/load_balancer-unregister-instance.sh @@ -22,7 +22,7 @@ while [[ "${1:-""}" ]]; do instance_id="${1}" echo "unregister ${instance_id} from ${load_balancer_id}..." >&2 eval "$(${BASH_SOURCE[0]%/*}/instance-get-vif.sh "${instance_id}")" - ${BASH_SOURCE[0]%/*}/load_balancer-unregister.sh "${load_balancer_id}" ${vif} >/dev/null + ${BASH_SOURCE[0]%/*}/load_balancer-unregister-vif.sh "${load_balancer_id}" ${vif} >/dev/null shift done diff --git a/ciscripts/wakame-vdc/load_balancer-unregister.sh b/ciscripts/wakame-vdc/load_balancer-unregister-vif.sh similarity index 100% rename from ciscripts/wakame-vdc/load_balancer-unregister.sh rename to ciscripts/wakame-vdc/load_balancer-unregister-vif.sh From 39f4bee262e2582b145f9397e6b25f397326bfa6 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:26:07 +0900 Subject: [PATCH 100/147] add runner-lbapp/lbweb. --- ciscripts/wakame-vdc/runner-lbapp.sh | 22 +++++++++++++++++++++- ciscripts/wakame-vdc/runner-lbweb.sh | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) mode change 120000 => 100755 ciscripts/wakame-vdc/runner-lbapp.sh mode change 120000 => 100755 ciscripts/wakame-vdc/runner-lbweb.sh diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/runner-lbapp.sh deleted file mode 120000 index 0efc07d..0000000 --- a/ciscripts/wakame-vdc/runner-lbapp.sh +++ /dev/null @@ -1 +0,0 @@ -create-lbapp.sh \ No newline at end of file diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/runner-lbapp.sh new file mode 100755 index 0000000..79bd140 --- /dev/null +++ b/ciscripts/wakame-vdc/runner-lbapp.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +# + +eval "$( + ${BASH_SOURCE[0]%/*}/create-lbapp.sh + )" +trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR + +eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" + +echo load_balancer_id="${load_balancer_id}" +echo ipaddr="${ipaddr}" +echo ipaddr_public="${ipaddr%,*}" +echo ipaddr_managed="${ipaddr#*,}" diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/runner-lbweb.sh deleted file mode 120000 index b653fe7..0000000 --- a/ciscripts/wakame-vdc/runner-lbweb.sh +++ /dev/null @@ -1 +0,0 @@ -create-lbweb.sh \ No newline at end of file diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/runner-lbweb.sh new file mode 100755 index 0000000..4b83a51 --- /dev/null +++ b/ciscripts/wakame-vdc/runner-lbweb.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +# + +eval "$( + ${BASH_SOURCE[0]%/*}/create-lbweb.sh + )" +trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR + +eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" + +echo load_balancer_id="${load_balancer_id}" +echo ipaddr="${ipaddr}" +echo ipaddr_public="${ipaddr%,*}" +echo ipaddr_managed="${ipaddr#*,}" From ede187ba3d4b013c08cc54b57771dec1bcceaed5 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:38:56 +0900 Subject: [PATCH 101/147] add web3layers-lite.sh. --- ciscripts/web3layers-lite.sh | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 ciscripts/web3layers-lite.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh new file mode 100755 index 0000000..64366c5 --- /dev/null +++ b/ciscripts/web3layers-lite.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x + +# required shell params + +: "${YUM_HOST:?"should not be empty"}" + +# + +cd ${BASH_SOURCE[0]%/*}/wakame-vdc + +# run instances + +## db + +eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" +db_id="${instance_id}" +DB_HOST="${ipaddr}" + +## app + +eval "$( + YUM_HOST="${YUM_HOST}" \ + DB_HOST="${DB_HOST}" \ + ${BASH_SOURCE[0]%/*}/runner-app.sh + )" +app_id="${instance_id}" +APP_HOST="${ipaddr}" + +## trap + +trap " + mussel instance destroy \"${db_id}\" + mussel instance destroy \"${app_id}\" +" ERR + +# smoketest + +## app + +if [[ -n "${JENKINS_HOME:-""}" ]]; then + # called by jenkins + # TODO + echo not implemented so far. +else + # stand alone + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh +fi + +# cleanup instances + +${BASH_SOURCE[0]%/*}/instance-kill.sh "${db_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" From 80a0f42ab7a318991e133527aaaf279dc15d0f38 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:43:38 +0900 Subject: [PATCH 102/147] add lbapp. --- ciscripts/web3layers-ci.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 64366c5..0892bb2 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -32,9 +32,20 @@ eval "$( app_id="${instance_id}" APP_HOST="${ipaddr}" +# run load balancers + +## lbapp + +eval "$(${BASH_SOURCE[0]%/*}/runner-lbapp.sh)" +lbapp_id="${load_balancer_id}" +LBAPP_HOST="${ipaddr_public}" + +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbapp_id}" "${app_id}" + ## trap trap " + ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbapp_id}\" mussel instance destroy \"${db_id}\" mussel instance destroy \"${app_id}\" " ERR @@ -52,6 +63,10 @@ else APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh fi +# cleanup load balancers + +${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbapp_id}" + # cleanup instances ${BASH_SOURCE[0]%/*}/instance-kill.sh "${db_id}" From 2b87b592fdaef58b464fc0812b8ccdef1782d12c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 20:54:50 +0900 Subject: [PATCH 103/147] wait for lb-port to be ready. --- ciscripts/wakame-vdc/runner-lbapp.sh | 10 ++++++++-- ciscripts/wakame-vdc/runner-lbweb.sh | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/runner-lbapp.sh index 79bd140..6869a5f 100755 --- a/ciscripts/wakame-vdc/runner-lbapp.sh +++ b/ciscripts/wakame-vdc/runner-lbapp.sh @@ -15,7 +15,13 @@ trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" +{ + . ${BASH_SOURCE[0]%/*}/retry.sh + + wait_for_port_to_be_ready "${ipaddr_public}" tcp 8080 +} >&2 + echo load_balancer_id="${load_balancer_id}" echo ipaddr="${ipaddr}" -echo ipaddr_public="${ipaddr%,*}" -echo ipaddr_managed="${ipaddr#*,}" +echo ipaddr_public="${ipaddr_public}" +echo ipaddr_managed="${ipaddr_managed}" diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/runner-lbweb.sh index 4b83a51..ad6c087 100755 --- a/ciscripts/wakame-vdc/runner-lbweb.sh +++ b/ciscripts/wakame-vdc/runner-lbweb.sh @@ -15,7 +15,13 @@ trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" +{ + . ${BASH_SOURCE[0]%/*}/retry.sh + + wait_for_port_to_be_ready "${ipaddr_public}" tcp 80 +} >&2 + echo load_balancer_id="${load_balancer_id}" echo ipaddr="${ipaddr}" -echo ipaddr_public="${ipaddr%,*}" -echo ipaddr_managed="${ipaddr#*,}" +echo ipaddr_public="${ipaddr_public}" +echo ipaddr_managed="${ipaddr_managed}" From 6e3e77780a8bec1d8fb1228fd7bb9c503c50b048 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:01:23 +0900 Subject: [PATCH 104/147] remove testing for web. --- ciscripts/wakame-vdc/smoketest-app.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ciscripts/wakame-vdc/smoketest-app.sh b/ciscripts/wakame-vdc/smoketest-app.sh index f5f2054..b0a7ffd 100755 --- a/ciscripts/wakame-vdc/smoketest-app.sh +++ b/ciscripts/wakame-vdc/smoketest-app.sh @@ -19,7 +19,3 @@ api_url="http://${APP_HOST}:8080/api/0.0.1/comments" curl -fs -X POST --data-urlencode display_name='webapi test' --data-urlencode comment='sample message.' ${api_url} curl -fs -X GET ${api_url} curl -fs -X GET ${api_url}/1 - -# - -curl -fs -X GET http://${APP_HOST}/ From 5eacd2335f824a391eeff6c7333cda21afb68e3d Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:19:00 +0900 Subject: [PATCH 105/147] add smoketest-web.sh. --- ciscripts/wakame-vdc/smoketest-web.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 ciscripts/wakame-vdc/smoketest-web.sh diff --git a/ciscripts/wakame-vdc/smoketest-web.sh b/ciscripts/wakame-vdc/smoketest-web.sh new file mode 100755 index 0000000..6919fc9 --- /dev/null +++ b/ciscripts/wakame-vdc/smoketest-web.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x + +# required shell params + +: "${WEB_HOST:?"should not be empty"}" + +# + +curl -fs -X GET http://${WEB_HOST}/ From fbce1d6ce9d6d20fb3255345f8b49e06d123bc56 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:20:45 +0900 Subject: [PATCH 106/147] replace lbapp with lbweb. --- ciscripts/web3layers-ci.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 0892bb2..6201383 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -34,18 +34,18 @@ APP_HOST="${ipaddr}" # run load balancers -## lbapp +## lbweb -eval "$(${BASH_SOURCE[0]%/*}/runner-lbapp.sh)" -lbapp_id="${load_balancer_id}" -LBAPP_HOST="${ipaddr_public}" +eval "$(${BASH_SOURCE[0]%/*}/runner-lbweb.sh)" +lbweb_id="${load_balancer_id}" +LBWEB_HOST="${ipaddr_public}" -${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbapp_id}" "${app_id}" +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbweb_id}" "${app_id}" ## trap trap " - ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbapp_id}\" + ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbweb_id}\" mussel instance destroy \"${db_id}\" mussel instance destroy \"${app_id}\" " ERR @@ -60,12 +60,14 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then echo not implemented so far. else # stand alone - APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh + WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh + WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh fi # cleanup load balancers -${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbapp_id}" +${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbweb_id}" # cleanup instances From 69bc1b95f8993c3665ea836ca71478e988d72364 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:21:08 +0900 Subject: [PATCH 107/147] remove "-x". --- ciscripts/web3layers-ci.sh | 1 - ciscripts/web3layers-lite.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 6201383..a4121e4 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -4,7 +4,6 @@ set -e set -o pipefail set -u -set -x # required shell params diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 64366c5..3ef4660 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -4,7 +4,6 @@ set -e set -o pipefail set -u -set -x # required shell params From 8a41c942604af0476a6bc362fd291ba52c62c4c0 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:45:57 +0900 Subject: [PATCH 108/147] run smoketest-web.sh. --- ciscripts/web3layers-lite.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 3ef4660..09a3a81 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -49,6 +49,7 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh + WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh fi # cleanup instances From 82a4881d92260b872ab7b689e8fe8b86981e7d55 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Tue, 26 May 2015 21:58:47 +0900 Subject: [PATCH 109/147] disable mode handling by caller. --- ciscripts/web3layers-ci.sh | 12 ++++++------ ciscripts/web3layers-lite.sh | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index a4121e4..7026101 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -53,16 +53,16 @@ trap " ## app -if [[ -n "${JENKINS_HOME:-""}" ]]; then - # called by jenkins - # TODO - echo not implemented so far. -else +#if [[ -n "${JENKINS_HOME:-""}" ]]; then +# # called by jenkins +# # TODO +# echo not implemented so far. +#else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh -fi +#fi # cleanup load balancers diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 09a3a81..a4497a9 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -42,15 +42,15 @@ trap " ## app -if [[ -n "${JENKINS_HOME:-""}" ]]; then - # called by jenkins - # TODO - echo not implemented so far. -else +#if [[ -n "${JENKINS_HOME:-""}" ]]; then +# # called by jenkins +# # TODO +# echo not implemented so far. +#else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh -fi +#fi # cleanup instances From 6e651063630bc4fc6ed2d7161a46780045249836 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:03:46 +0900 Subject: [PATCH 110/147] db_id -> DB_ID --- ciscripts/web3layers-ci.sh | 6 +++--- ciscripts/web3layers-lite.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 7026101..1b1b739 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -18,7 +18,7 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc ## db eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" -db_id="${instance_id}" +DB_ID="${instance_id}" DB_HOST="${ipaddr}" ## app @@ -45,7 +45,7 @@ ${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbweb_id}" "${app_id} trap " ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbweb_id}\" - mussel instance destroy \"${db_id}\" + mussel instance destroy \"${DB_ID}\" mussel instance destroy \"${app_id}\" " ERR @@ -70,5 +70,5 @@ ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbweb_id}" # cleanup instances -${BASH_SOURCE[0]%/*}/instance-kill.sh "${db_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" ${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index a4497a9..1b8cf5b 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -18,7 +18,7 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc ## db eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" -db_id="${instance_id}" +DB_ID="${instance_id}" DB_HOST="${ipaddr}" ## app @@ -34,7 +34,7 @@ APP_HOST="${ipaddr}" ## trap trap " - mussel instance destroy \"${db_id}\" + mussel instance destroy \"${DB_ID}\" mussel instance destroy \"${app_id}\" " ERR @@ -54,5 +54,5 @@ trap " # cleanup instances -${BASH_SOURCE[0]%/*}/instance-kill.sh "${db_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" ${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" From 56785d56cf0f5fe332f91ae08ec903685b5b7b6e Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:04:11 +0900 Subject: [PATCH 111/147] app_id -> APP_ID --- ciscripts/web3layers-ci.sh | 8 ++++---- ciscripts/web3layers-lite.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 1b1b739..a89e9b6 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -28,7 +28,7 @@ eval "$( DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/runner-app.sh )" -app_id="${instance_id}" +APP_ID="${instance_id}" APP_HOST="${ipaddr}" # run load balancers @@ -39,14 +39,14 @@ eval "$(${BASH_SOURCE[0]%/*}/runner-lbweb.sh)" lbweb_id="${load_balancer_id}" LBWEB_HOST="${ipaddr_public}" -${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbweb_id}" "${app_id}" +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbweb_id}" "${APP_ID}" ## trap trap " ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbweb_id}\" mussel instance destroy \"${DB_ID}\" - mussel instance destroy \"${app_id}\" + mussel instance destroy \"${APP_ID}\" " ERR # smoketest @@ -71,4 +71,4 @@ ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbweb_id}" # cleanup instances ${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" -${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${APP_ID}" diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 1b8cf5b..243cd6a 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -28,14 +28,14 @@ eval "$( DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/runner-app.sh )" -app_id="${instance_id}" +APP_ID="${instance_id}" APP_HOST="${ipaddr}" ## trap trap " mussel instance destroy \"${DB_ID}\" - mussel instance destroy \"${app_id}\" + mussel instance destroy \"${APP_ID}\" " ERR # smoketest @@ -55,4 +55,4 @@ trap " # cleanup instances ${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" -${BASH_SOURCE[0]%/*}/instance-kill.sh "${app_id}" +${BASH_SOURCE[0]%/*}/instance-kill.sh "${APP_ID}" From fcc10e9df895c12f1118a637d28041b05c993a5a Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:04:44 +0900 Subject: [PATCH 112/147] ldweb_id -> LDWEB_ID --- ciscripts/web3layers-ci.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index a89e9b6..eaaf9a7 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -36,15 +36,15 @@ APP_HOST="${ipaddr}" ## lbweb eval "$(${BASH_SOURCE[0]%/*}/runner-lbweb.sh)" -lbweb_id="${load_balancer_id}" +LDWEB_ID="${load_balancer_id}" LBWEB_HOST="${ipaddr_public}" -${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${lbweb_id}" "${APP_ID}" +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${LDWEB_ID}" "${APP_ID}" ## trap trap " - ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${lbweb_id}\" + ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${LDWEB_ID}\" mussel instance destroy \"${DB_ID}\" mussel instance destroy \"${APP_ID}\" " ERR @@ -66,7 +66,7 @@ trap " # cleanup load balancers -${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${lbweb_id}" +${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${LDWEB_ID}" # cleanup instances From fb46461f2647f1b65e5fba017046c48fce3823fb Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:36:01 +0900 Subject: [PATCH 113/147] improve trap quote. --- ciscripts/wakame-vdc/create-app.sh | 2 +- ciscripts/wakame-vdc/create-centos.sh | 2 +- ciscripts/wakame-vdc/create-db.sh | 2 +- ciscripts/wakame-vdc/create-imgdb.sh | 2 +- ciscripts/wakame-vdc/create-imgrbenv.sh | 2 +- ciscripts/wakame-vdc/runner-app.sh | 2 +- ciscripts/wakame-vdc/runner-db.sh | 2 +- ciscripts/wakame-vdc/runner-imgdb.sh | 2 +- ciscripts/wakame-vdc/runner-imgrbenv.sh | 2 +- ciscripts/wakame-vdc/runner-lbapp.sh | 2 +- ciscripts/wakame-vdc/runner-lbweb.sh | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index ba17746..c29ee18 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -38,7 +38,7 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR ## wait for the instance to be running diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 10ee694..31e8939 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -41,7 +41,7 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR ## wait for the instance to be running diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 88698c3..6aaf389 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -38,7 +38,7 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR ## wait for the instance to be running diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 68999b4..19c8cf8 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -38,7 +38,7 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR ## wait for the instance to be running diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index b82e51e..651a0a8 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -38,7 +38,7 @@ instance_id="$( : "${instance_id:?"should not be empty"}" echo "${instance_id} is initializing..." >&2 -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR ## wait for the instance to be running diff --git a/ciscripts/wakame-vdc/runner-app.sh b/ciscripts/wakame-vdc/runner-app.sh index 5c48cf9..b6ff870 100755 --- a/ciscripts/wakame-vdc/runner-app.sh +++ b/ciscripts/wakame-vdc/runner-app.sh @@ -16,7 +16,7 @@ set -x eval "$( ${BASH_SOURCE[0]%/*}/create-app.sh )" -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" diff --git a/ciscripts/wakame-vdc/runner-db.sh b/ciscripts/wakame-vdc/runner-db.sh index 24ff8c4..a20eb3b 100755 --- a/ciscripts/wakame-vdc/runner-db.sh +++ b/ciscripts/wakame-vdc/runner-db.sh @@ -9,7 +9,7 @@ set -x eval "$( ${BASH_SOURCE[0]%/*}/create-db.sh )" -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" diff --git a/ciscripts/wakame-vdc/runner-imgdb.sh b/ciscripts/wakame-vdc/runner-imgdb.sh index 2784d07..78a33a3 100755 --- a/ciscripts/wakame-vdc/runner-imgdb.sh +++ b/ciscripts/wakame-vdc/runner-imgdb.sh @@ -10,7 +10,7 @@ eval "$( ${BASH_SOURCE[0]%/*}/create-imgdb.sh )" -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" diff --git a/ciscripts/wakame-vdc/runner-imgrbenv.sh b/ciscripts/wakame-vdc/runner-imgrbenv.sh index e321152..875582d 100755 --- a/ciscripts/wakame-vdc/runner-imgrbenv.sh +++ b/ciscripts/wakame-vdc/runner-imgrbenv.sh @@ -9,7 +9,7 @@ set -x eval "$( ${BASH_SOURCE[0]%/*}/create-imgrbenv.sh )" -trap "mussel instance destroy \"${instance_id}\"" ERR +trap 'mussel instance destroy "${instance_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/runner-lbapp.sh index 6869a5f..fe3a581 100755 --- a/ciscripts/wakame-vdc/runner-lbapp.sh +++ b/ciscripts/wakame-vdc/runner-lbapp.sh @@ -11,7 +11,7 @@ set -x eval "$( ${BASH_SOURCE[0]%/*}/create-lbapp.sh )" -trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR +trap 'mussel load_balancer destroy "${load_balancer_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/runner-lbweb.sh index ad6c087..9c72818 100755 --- a/ciscripts/wakame-vdc/runner-lbweb.sh +++ b/ciscripts/wakame-vdc/runner-lbweb.sh @@ -11,7 +11,7 @@ set -x eval "$( ${BASH_SOURCE[0]%/*}/create-lbweb.sh )" -trap "mussel load_balancer destroy \"${load_balancer_id}\"" ERR +trap 'mussel load_balancer destroy "${load_balancer_id}"' ERR eval "$(${BASH_SOURCE[0]%/*}/load_balancer-get-ipaddr.sh "${load_balancer_id}")" From 6ed548393ac54118d36283e2dd558d537422097c Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:40:12 +0900 Subject: [PATCH 114/147] move common procedures to setup-*.sh. --- ciscripts/wakame-vdc/setup-app.sh | 15 +++++++++ ciscripts/wakame-vdc/setup-db.sh | 13 ++++++++ ciscripts/wakame-vdc/setup-lbweb.sh | 15 +++++++++ ciscripts/web3layers-ci.sh | 47 +++++------------------------ ciscripts/web3layers-lite.sh | 30 ++++-------------- 5 files changed, 57 insertions(+), 63 deletions(-) create mode 100755 ciscripts/wakame-vdc/setup-app.sh create mode 100755 ciscripts/wakame-vdc/setup-db.sh create mode 100755 ciscripts/wakame-vdc/setup-lbweb.sh diff --git a/ciscripts/wakame-vdc/setup-app.sh b/ciscripts/wakame-vdc/setup-app.sh new file mode 100755 index 0000000..18d0b7c --- /dev/null +++ b/ciscripts/wakame-vdc/setup-app.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u + +eval "$( + YUM_HOST="${YUM_HOST}" \ + DB_HOST="${DB_HOST}" \ + ${BASH_SOURCE[0]%/*}/runner-app.sh +)" + +APP_ID="${instance_id}" +APP_HOST="${ipaddr}" diff --git a/ciscripts/wakame-vdc/setup-db.sh b/ciscripts/wakame-vdc/setup-db.sh new file mode 100755 index 0000000..8dd0894 --- /dev/null +++ b/ciscripts/wakame-vdc/setup-db.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u + +eval "$( + ${BASH_SOURCE[0]%/*}/runner-db.sh +)" + +DB_ID="${instance_id}" +DB_HOST="${ipaddr}" diff --git a/ciscripts/wakame-vdc/setup-lbweb.sh b/ciscripts/wakame-vdc/setup-lbweb.sh new file mode 100755 index 0000000..d24c830 --- /dev/null +++ b/ciscripts/wakame-vdc/setup-lbweb.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u + +eval "$( + ${BASH_SOURCE[0]%/*}/runner-lbweb.sh +)" + +LDWEB_ID="${load_balancer_id}" +LBWEB_HOST="${ipaddr_public}" + +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${LDWEB_ID}" "${APP_ID}" >&2 diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index eaaf9a7..d7ece8b 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -15,39 +15,17 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # run instances -## db - -eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" -DB_ID="${instance_id}" -DB_HOST="${ipaddr}" - -## app - -eval "$( - YUM_HOST="${YUM_HOST}" \ - DB_HOST="${DB_HOST}" \ - ${BASH_SOURCE[0]%/*}/runner-app.sh - )" -APP_ID="${instance_id}" -APP_HOST="${ipaddr}" - -# run load balancers - -## lbweb - -eval "$(${BASH_SOURCE[0]%/*}/runner-lbweb.sh)" -LDWEB_ID="${load_balancer_id}" -LBWEB_HOST="${ipaddr_public}" - -${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${LDWEB_ID}" "${APP_ID}" +. ${BASH_SOURCE[0]%/*}/setup-db.sh +. ${BASH_SOURCE[0]%/*}/setup-app.sh +. ${BASH_SOURCE[0]%/*}/setup-lbweb.sh ## trap -trap " - ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh \"${LDWEB_ID}\" - mussel instance destroy \"${DB_ID}\" - mussel instance destroy \"${APP_ID}\" -" ERR +trap ' + mussel instance destroy "${DB_ID}" + mussel instance destroy "${APP_ID}" + ${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${LDWEB_ID}" +' ERR EXIT # smoketest @@ -63,12 +41,3 @@ trap " WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh #fi - -# cleanup load balancers - -${BASH_SOURCE[0]%/*}/load_balancer-kill.sh "${LDWEB_ID}" - -# cleanup instances - -${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" -${BASH_SOURCE[0]%/*}/instance-kill.sh "${APP_ID}" diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 243cd6a..ed30d97 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -15,28 +15,15 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # run instances -## db - -eval "$(${BASH_SOURCE[0]%/*}/runner-db.sh)" -DB_ID="${instance_id}" -DB_HOST="${ipaddr}" - -## app - -eval "$( - YUM_HOST="${YUM_HOST}" \ - DB_HOST="${DB_HOST}" \ - ${BASH_SOURCE[0]%/*}/runner-app.sh - )" -APP_ID="${instance_id}" -APP_HOST="${ipaddr}" +. ${BASH_SOURCE[0]%/*}/setup-db.sh +. ${BASH_SOURCE[0]%/*}/setup-app.sh ## trap -trap " - mussel instance destroy \"${DB_ID}\" - mussel instance destroy \"${APP_ID}\" -" ERR +trap ' + mussel instance destroy "${DB_ID}" + mussel instance destroy "${APP_ID}" +' ERR EXIT # smoketest @@ -51,8 +38,3 @@ trap " APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh #fi - -# cleanup instances - -${BASH_SOURCE[0]%/*}/instance-kill.sh "${DB_ID}" -${BASH_SOURCE[0]%/*}/instance-kill.sh "${APP_ID}" From f8501945af466c257f7615bdc92b6294311f427b Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 14:52:14 +0900 Subject: [PATCH 115/147] add parameter validation. --- ciscripts/wakame-vdc/setup-app.sh | 7 +++++-- ciscripts/wakame-vdc/setup-db.sh | 4 ++-- ciscripts/wakame-vdc/setup-lbweb.sh | 8 +++++--- ciscripts/web3layers-ci.sh | 16 +++++++++++++--- ciscripts/web3layers-lite.sh | 15 +++++++++++++-- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ciscripts/wakame-vdc/setup-app.sh b/ciscripts/wakame-vdc/setup-app.sh index 18d0b7c..f93f92b 100755 --- a/ciscripts/wakame-vdc/setup-app.sh +++ b/ciscripts/wakame-vdc/setup-app.sh @@ -5,11 +5,14 @@ set -e set -o pipefail set -u +: "${YUM_HOST:?"should not be empty"}" +: "${DB_HOST:?"should not be empty"}" + eval "$( YUM_HOST="${YUM_HOST}" \ DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/runner-app.sh )" -APP_ID="${instance_id}" -APP_HOST="${ipaddr}" +echo APP_ID="${instance_id}" +echo APP_HOST="${ipaddr}" diff --git a/ciscripts/wakame-vdc/setup-db.sh b/ciscripts/wakame-vdc/setup-db.sh index 8dd0894..b5c8526 100755 --- a/ciscripts/wakame-vdc/setup-db.sh +++ b/ciscripts/wakame-vdc/setup-db.sh @@ -9,5 +9,5 @@ eval "$( ${BASH_SOURCE[0]%/*}/runner-db.sh )" -DB_ID="${instance_id}" -DB_HOST="${ipaddr}" +echo DB_ID="${instance_id}" +echo DB_HOST="${ipaddr}" diff --git a/ciscripts/wakame-vdc/setup-lbweb.sh b/ciscripts/wakame-vdc/setup-lbweb.sh index d24c830..4d3af9d 100755 --- a/ciscripts/wakame-vdc/setup-lbweb.sh +++ b/ciscripts/wakame-vdc/setup-lbweb.sh @@ -5,11 +5,13 @@ set -e set -o pipefail set -u +: "${APP_ID:?"should not be empty"}" + eval "$( ${BASH_SOURCE[0]%/*}/runner-lbweb.sh )" -LDWEB_ID="${load_balancer_id}" -LBWEB_HOST="${ipaddr_public}" +${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${load_balancer_id}" "${APP_ID}" >&2 -${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${LDWEB_ID}" "${APP_ID}" >&2 +echo LDWEB_ID="${load_balancer_id}" +echo LBWEB_HOST="${ipaddr_public}" diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index d7ece8b..e0a4505 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -15,9 +15,19 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # run instances -. ${BASH_SOURCE[0]%/*}/setup-db.sh -. ${BASH_SOURCE[0]%/*}/setup-app.sh -. ${BASH_SOURCE[0]%/*}/setup-lbweb.sh +eval "$( + ${BASH_SOURCE[0]%/*}/setup-db.sh +)" + +eval "$( + YUM_HOST="${YUM_HOST}" DB_HOST="${DB_HOST}" \ + ${BASH_SOURCE[0]%/*}/setup-app.sh +)" + +eval "$( + APP_ID="${APP_ID}" \ + ${BASH_SOURCE[0]%/*}/setup-lbweb.sh +)" ## trap diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index ed30d97..679eb77 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -15,8 +15,19 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # run instances -. ${BASH_SOURCE[0]%/*}/setup-db.sh -. ${BASH_SOURCE[0]%/*}/setup-app.sh +eval "$( + ${BASH_SOURCE[0]%/*}/setup-db.sh +)" + +eval "$( + YUM_HOST="${YUM_HOST}" DB_HOST="${DB_HOST}" \ + ${BASH_SOURCE[0]%/*}/setup-app.sh +)" + +eval "$( + APP_ID="${APP_ID}" \ + ${BASH_SOURCE[0]%/*}/setup-lbweb.sh +)" ## trap From 5de0e317df8a4e5edb3861b2a596792a434acf54 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 15:00:14 +0900 Subject: [PATCH 116/147] remove unnecessary lbweb setup. --- ciscripts/web3layers-lite.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 679eb77..9610d13 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -24,11 +24,6 @@ eval "$( ${BASH_SOURCE[0]%/*}/setup-app.sh )" -eval "$( - APP_ID="${APP_ID}" \ - ${BASH_SOURCE[0]%/*}/setup-lbweb.sh -)" - ## trap trap ' From 9b54146c62283010f516f032132918268fc6be59 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 15:02:11 +0900 Subject: [PATCH 117/147] runner-* -> run-*. --- ciscripts/wakame-vdc/README.md | 4 ++-- ciscripts/wakame-vdc/{runner-app.sh => run-app.sh} | 0 ciscripts/wakame-vdc/{runner-db.sh => run-db.sh} | 0 ciscripts/wakame-vdc/{runner-imgdb.sh => run-imgdb.sh} | 0 ciscripts/wakame-vdc/{runner-imgrbenv.sh => run-imgrbenv.sh} | 0 ciscripts/wakame-vdc/{runner-lbapp.sh => run-lbapp.sh} | 0 ciscripts/wakame-vdc/{runner-lbweb.sh => run-lbweb.sh} | 0 ciscripts/wakame-vdc/setup-app.sh | 2 +- ciscripts/wakame-vdc/setup-db.sh | 2 +- ciscripts/wakame-vdc/setup-lbweb.sh | 2 +- 10 files changed, 5 insertions(+), 5 deletions(-) rename ciscripts/wakame-vdc/{runner-app.sh => run-app.sh} (100%) rename ciscripts/wakame-vdc/{runner-db.sh => run-db.sh} (100%) rename ciscripts/wakame-vdc/{runner-imgdb.sh => run-imgdb.sh} (100%) rename ciscripts/wakame-vdc/{runner-imgrbenv.sh => run-imgrbenv.sh} (100%) rename ciscripts/wakame-vdc/{runner-lbapp.sh => run-lbapp.sh} (100%) rename ciscripts/wakame-vdc/{runner-lbweb.sh => run-lbweb.sh} (100%) diff --git a/ciscripts/wakame-vdc/README.md b/ciscripts/wakame-vdc/README.md index b55952d..55557ba 100644 --- a/ciscripts/wakame-vdc/README.md +++ b/ciscripts/wakame-vdc/README.md @@ -1,8 +1,8 @@ ## Script Chain -1. run `runner-app.sh` +1. run `run-app.sh` 1. run `create-app.sh` 2. run `provision-app.sh` -2. run `runner-db.sh` +2. run `run-db.sh` 1. run `create-db.sh` 2. run `provision-db.sh` diff --git a/ciscripts/wakame-vdc/runner-app.sh b/ciscripts/wakame-vdc/run-app.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-app.sh rename to ciscripts/wakame-vdc/run-app.sh diff --git a/ciscripts/wakame-vdc/runner-db.sh b/ciscripts/wakame-vdc/run-db.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-db.sh rename to ciscripts/wakame-vdc/run-db.sh diff --git a/ciscripts/wakame-vdc/runner-imgdb.sh b/ciscripts/wakame-vdc/run-imgdb.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-imgdb.sh rename to ciscripts/wakame-vdc/run-imgdb.sh diff --git a/ciscripts/wakame-vdc/runner-imgrbenv.sh b/ciscripts/wakame-vdc/run-imgrbenv.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-imgrbenv.sh rename to ciscripts/wakame-vdc/run-imgrbenv.sh diff --git a/ciscripts/wakame-vdc/runner-lbapp.sh b/ciscripts/wakame-vdc/run-lbapp.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-lbapp.sh rename to ciscripts/wakame-vdc/run-lbapp.sh diff --git a/ciscripts/wakame-vdc/runner-lbweb.sh b/ciscripts/wakame-vdc/run-lbweb.sh similarity index 100% rename from ciscripts/wakame-vdc/runner-lbweb.sh rename to ciscripts/wakame-vdc/run-lbweb.sh diff --git a/ciscripts/wakame-vdc/setup-app.sh b/ciscripts/wakame-vdc/setup-app.sh index f93f92b..bd4700b 100755 --- a/ciscripts/wakame-vdc/setup-app.sh +++ b/ciscripts/wakame-vdc/setup-app.sh @@ -11,7 +11,7 @@ set -u eval "$( YUM_HOST="${YUM_HOST}" \ DB_HOST="${DB_HOST}" \ - ${BASH_SOURCE[0]%/*}/runner-app.sh + ${BASH_SOURCE[0]%/*}/run-app.sh )" echo APP_ID="${instance_id}" diff --git a/ciscripts/wakame-vdc/setup-db.sh b/ciscripts/wakame-vdc/setup-db.sh index b5c8526..9048566 100755 --- a/ciscripts/wakame-vdc/setup-db.sh +++ b/ciscripts/wakame-vdc/setup-db.sh @@ -6,7 +6,7 @@ set -o pipefail set -u eval "$( - ${BASH_SOURCE[0]%/*}/runner-db.sh + ${BASH_SOURCE[0]%/*}/run-db.sh )" echo DB_ID="${instance_id}" diff --git a/ciscripts/wakame-vdc/setup-lbweb.sh b/ciscripts/wakame-vdc/setup-lbweb.sh index 4d3af9d..650a456 100755 --- a/ciscripts/wakame-vdc/setup-lbweb.sh +++ b/ciscripts/wakame-vdc/setup-lbweb.sh @@ -8,7 +8,7 @@ set -u : "${APP_ID:?"should not be empty"}" eval "$( - ${BASH_SOURCE[0]%/*}/runner-lbweb.sh + ${BASH_SOURCE[0]%/*}/run-lbweb.sh )" ${BASH_SOURCE[0]%/*}/load_balancer-register-instance.sh "${load_balancer_id}" "${APP_ID}" >&2 From f93f455ace17946b2d8178df414ef5efae59f167 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 15:49:09 +0900 Subject: [PATCH 118/147] replace source with fork. --- ciscripts/wakame-vdc/create-app.sh | 3 ++- ciscripts/wakame-vdc/create-centos.sh | 10 ++++------ ciscripts/wakame-vdc/create-db.sh | 3 ++- ciscripts/wakame-vdc/create-imgdb.sh | 3 ++- ciscripts/wakame-vdc/create-imgrbenv.sh | 3 ++- ciscripts/wakame-vdc/gen-vifs.sh | 4 ++++ 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index c29ee18..00d8d1a 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -22,7 +22,8 @@ ssh_key_id="ssh-cicddemo" ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh instance_id="$( mussel instance create \ diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 31e8939..9d85c6e 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -4,18 +4,12 @@ set -e set -o pipefail set -u -# setup musselrc - -${BASH_SOURCE[0]%/*}/gen-musselrc.sh - # setup vifs.json network_id="nw-demo1" security_group_id="sg-cicddemo" vifs="vifs.json" -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh - # instance-specific parameter cpu_cores="1" @@ -27,6 +21,10 @@ ssh_key_id="ssh-cicddemo" ## create an instance +${BASH_SOURCE[0]%/*}/gen-musselrc.sh +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh + instance_id="$( mussel instance create \ --cpu-cores "${cpu_cores}" \ diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 6aaf389..543d508 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -22,7 +22,8 @@ ssh_key_id="ssh-cicddemo" ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh instance_id="$( mussel instance create \ diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 19c8cf8..e457960 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -22,7 +22,8 @@ ssh_key_id="ssh-cicddemo" ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh instance_id="$( mussel instance create \ diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index 651a0a8..78e4520 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -22,7 +22,8 @@ ssh_key_id="ssh-cicddemo" ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh -. ${BASH_SOURCE[0]%/*}/gen-vifs.sh +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh instance_id="$( mussel instance create \ diff --git a/ciscripts/wakame-vdc/gen-vifs.sh b/ciscripts/wakame-vdc/gen-vifs.sh index 71bfbe3..66672b4 100755 --- a/ciscripts/wakame-vdc/gen-vifs.sh +++ b/ciscripts/wakame-vdc/gen-vifs.sh @@ -4,6 +4,10 @@ set -e set -o pipefail set -u +: "${vifs:?"should not be empty"}" +: "${network_id:?"should not be empty"}" +: "${security_group_id:?"should not be empty"}" + cat < "${vifs}" { "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} From 361af3d0dae21cae37de6c0af928b4de1c8db655 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 16:03:11 +0900 Subject: [PATCH 119/147] use proper message. --- ciscripts/web3layers-ci.sh | 4 ++-- ciscripts/web3layers-lite.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index e0a4505..3d44d03 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -13,7 +13,7 @@ set -u cd ${BASH_SOURCE[0]%/*}/wakame-vdc -# run instances +# setup instances eval "$( ${BASH_SOURCE[0]%/*}/setup-db.sh @@ -29,7 +29,7 @@ eval "$( ${BASH_SOURCE[0]%/*}/setup-lbweb.sh )" -## trap +# cleanup trap ' mussel instance destroy "${DB_ID}" diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 9610d13..8ab08d5 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -13,7 +13,7 @@ set -u cd ${BASH_SOURCE[0]%/*}/wakame-vdc -# run instances +# setup instances eval "$( ${BASH_SOURCE[0]%/*}/setup-db.sh @@ -24,7 +24,7 @@ eval "$( ${BASH_SOURCE[0]%/*}/setup-app.sh )" -## trap +# cleanup trap ' mussel instance destroy "${DB_ID}" From a5b0b20356f478eddf839129b7b9bf8cbae6b5e8 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 16:42:05 +0900 Subject: [PATCH 120/147] reenable mode handling. --- ciscripts/web3layers-ci.sh | 10 +++++----- ciscripts/web3layers-lite.sh | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 3d44d03..a50ea56 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -41,11 +41,11 @@ trap ' ## app -#if [[ -n "${JENKINS_HOME:-""}" ]]; then -# # called by jenkins -# # TODO -# echo not implemented so far. -#else +if [[ -n "${JENKINS_HOME:-""}" ]]; then + # called by jenkins + # TODO + echo not implemented so far. +else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 8ab08d5..b13021a 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -35,12 +35,12 @@ trap ' ## app -#if [[ -n "${JENKINS_HOME:-""}" ]]; then -# # called by jenkins -# # TODO -# echo not implemented so far. -#else +if [[ -n "${JENKINS_HOME:-""}" ]]; then + # called by jenkins + # TODO + echo not implemented so far. +else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh -#fi +fi From 8a1c15fda165719bfdc12dff7c82dac6c0f75fda Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 16:44:27 +0900 Subject: [PATCH 121/147] enable to set specified app host. --- ciscripts/integration-test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ciscripts/integration-test.sh b/ciscripts/integration-test.sh index a1144a8..036bffb 100755 --- a/ciscripts/integration-test.sh +++ b/ciscripts/integration-test.sh @@ -9,4 +9,9 @@ cd spec_integration bundle install cp config/webapi.conf.example config/webapi.conf + +if [[ -n "${APP_HOST:-""}" ]]; then + sed -i s,localhost,${APP_HOST}, config/webapi.conf +fi + bundle exec rspec ./spec/webapi_integration_spec.rb From 9fdfdc0ffd72a68808eb5203ef5e6dca1bc434c3 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 16:46:17 +0900 Subject: [PATCH 122/147] run rspec based integration test. --- ciscripts/web3layers-ci.sh | 3 +-- ciscripts/web3layers-lite.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index a50ea56..f4f6dac 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -43,8 +43,7 @@ trap ' if [[ -n "${JENKINS_HOME:-""}" ]]; then # called by jenkins - # TODO - echo not implemented so far. + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/../integration-test.sh else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index b13021a..5ddc3f0 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -37,8 +37,7 @@ trap ' if [[ -n "${JENKINS_HOME:-""}" ]]; then # called by jenkins - # TODO - echo not implemented so far. + APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/../integration-test.sh else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh From 6e8442622971bf68829c382c4f61029e93940ed7 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 16:57:10 +0900 Subject: [PATCH 123/147] change directory before running integration-test.sh. --- ciscripts/web3layers-ci.sh | 5 ++++- ciscripts/web3layers-lite.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index f4f6dac..e816345 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -43,7 +43,10 @@ trap ' if [[ -n "${JENKINS_HOME:-""}" ]]; then # called by jenkins - APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/../integration-test.sh + ( + cd ${BASH_SOURCE[0]%/*}/../../ + APP_HOST="${APP_HOST}" ./ciscripts/integration-test.sh + ) else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 5ddc3f0..a85ecc9 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -37,7 +37,10 @@ trap ' if [[ -n "${JENKINS_HOME:-""}" ]]; then # called by jenkins - APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/../integration-test.sh + ( + cd ${BASH_SOURCE[0]%/*}/../../ + APP_HOST="${APP_HOST}" ./ciscripts/integration-test.sh + ) else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh From 37a3b3f6b1a50f294dbf23ee0dadbed0fd2ccc8d Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 17:02:03 +0900 Subject: [PATCH 124/147] fix syntax error. --- ciscripts/web3layers-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index e816345..6afc032 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -52,4 +52,4 @@ else APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh -#fi +fi From 9c018f7c37123b8afb590b190d232045fccffa4d Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 17:04:22 +0900 Subject: [PATCH 125/147] move web smoketest. --- ciscripts/web3layers-ci.sh | 5 +++-- ciscripts/web3layers-lite.sh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 6afc032..710a6c9 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -50,6 +50,7 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh - WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh - WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh fi + +WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh +WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index a85ecc9..258013a 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -44,5 +44,6 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then else # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh - WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh fi + +WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh From f849c14df414ca92e094abdd1c4810b447268ca6 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 17:05:38 +0900 Subject: [PATCH 126/147] update comment. --- ciscripts/web3layers-ci.sh | 3 ++- ciscripts/web3layers-lite.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 710a6c9..8c22a08 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -48,9 +48,10 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then APP_HOST="${APP_HOST}" ./ciscripts/integration-test.sh ) else - # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh fi +## web + WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh WEB_HOST="${LBWEB_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 258013a..485f1af 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -42,8 +42,9 @@ if [[ -n "${JENKINS_HOME:-""}" ]]; then APP_HOST="${APP_HOST}" ./ciscripts/integration-test.sh ) else - # stand alone APP_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-app.sh fi +## web + WEB_HOST="${APP_HOST}" ${BASH_SOURCE[0]%/*}/smoketest-web.sh From ef10babf511a6cce3782dbdad32b56710dd07487 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 17:16:27 +0900 Subject: [PATCH 127/147] update readme. --- ciscripts/wakame-vdc/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ciscripts/wakame-vdc/README.md b/ciscripts/wakame-vdc/README.md index 55557ba..31a28f5 100644 --- a/ciscripts/wakame-vdc/README.md +++ b/ciscripts/wakame-vdc/README.md @@ -1,8 +1,13 @@ ## Script Chain -1. run `run-app.sh` - 1. run `create-app.sh` - 2. run `provision-app.sh` -2. run `run-db.sh` - 1. run `create-db.sh` - 2. run `provision-db.sh` +1. run `setup-db.sh` + 1. run `run-db.sh` + 1. run `create-db.sh` + 2. run `provision-db.sh` +2. run `setup-app.sh` + 1. run `run-app.sh` + 1. run `create-app.sh` + 2. run `provision-app.sh` +3. run `setup-lbweb.sh` + 1. run `run-lbweb.sh` + 1. run `create-lbweb.sh` From 5f2d166f5aa173618605b7ece0c3239519c6607e Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:09:46 +0900 Subject: [PATCH 128/147] remove static image_id. --- ciscripts/wakame-vdc/create-app.sh | 6 +++++- ciscripts/wakame-vdc/create-db.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 00d8d1a..9cc0be5 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -15,10 +15,14 @@ vifs="vifs.json" cpu_cores="1" hypervisor="kvm" memory_size="1024" -image_id="wmi-43n0y4mk" +#image_id="wmi-***" display_name="app" ssh_key_id="ssh-cicddemo" +# + +: "${image_id:?"should not be empty"}" + ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 543d508..0a4dd0f 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -15,10 +15,14 @@ vifs="vifs.json" cpu_cores="1" hypervisor="kvm" memory_size="512" -image_id="wmi-xrjtduc4" +#image_id="wmi-***" display_name="db" ssh_key_id="ssh-cicddemo" +# + +: "${image_id:?"should not be empty"}" + ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh From c15b3b3b80a1e11a18e98b6b0e9c4e39fc4a0547 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:13:01 +0900 Subject: [PATCH 129/147] add config/.gitkeep. --- ciscripts/wakame-vdc/config/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ciscripts/wakame-vdc/config/.gitkeep diff --git a/ciscripts/wakame-vdc/config/.gitkeep b/ciscripts/wakame-vdc/config/.gitkeep new file mode 100644 index 0000000..e69de29 From 218168465f12aa9515a01bdad4dc5a1fa529ecad Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:18:16 +0900 Subject: [PATCH 130/147] enable to load instance specific params. --- ciscripts/wakame-vdc/create-app.sh | 6 ++++++ ciscripts/wakame-vdc/create-centos.sh | 6 ++++++ ciscripts/wakame-vdc/create-db.sh | 6 ++++++ ciscripts/wakame-vdc/create-imgdb.sh | 6 ++++++ ciscripts/wakame-vdc/create-imgrbenv.sh | 6 ++++++ ciscripts/wakame-vdc/create-lbapp.sh | 6 ++++++ ciscripts/wakame-vdc/create-lbweb.sh | 6 ++++++ 7 files changed, 42 insertions(+) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 9cc0be5..332842d 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -21,6 +21,12 @@ ssh_key_id="ssh-cicddemo" # +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + +# + : "${image_id:?"should not be empty"}" ## create an instance diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 9d85c6e..543fa61 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -19,6 +19,12 @@ image_id="wmi-centos1d64" display_name="centos" ssh_key_id="ssh-cicddemo" +# + +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 0a4dd0f..3e4160d 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -21,6 +21,12 @@ ssh_key_id="ssh-cicddemo" # +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + +# + : "${image_id:?"should not be empty"}" ## create an instance diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index e457960..4e893f2 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -19,6 +19,12 @@ image_id="wmi-centos1d64" display_name="imgdb" ssh_key_id="ssh-cicddemo" +# + +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index 78e4520..415fbd8 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -19,6 +19,12 @@ image_id="wmi-centos1d64" display_name="imgrbenv" ssh_key_id="ssh-cicddemo" +# + +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-lbapp.sh b/ciscripts/wakame-vdc/create-lbapp.sh index fde4beb..7c2154e 100755 --- a/ciscripts/wakame-vdc/create-lbapp.sh +++ b/ciscripts/wakame-vdc/create-lbapp.sh @@ -17,6 +17,12 @@ instance_protocol="http" port_maps="8080:http" display_name="lb8080" +# + +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + ## create a load_balancer ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-lbweb.sh b/ciscripts/wakame-vdc/create-lbweb.sh index 5e4d1dc..d7cf774 100755 --- a/ciscripts/wakame-vdc/create-lbweb.sh +++ b/ciscripts/wakame-vdc/create-lbweb.sh @@ -17,6 +17,12 @@ instance_protocol="http" port_maps="80:http" display_name="lb80" +# + +if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then + . ${BASH_SOURCE[0]%/*}/config/${display_name} +fi + ## create a load_balancer ${BASH_SOURCE[0]%/*}/gen-musselrc.sh From 11bc375bd4b24d12f01f2d5209ade8e8b310a047 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:18:47 +0900 Subject: [PATCH 131/147] update display_name for lb. --- ciscripts/wakame-vdc/create-lbapp.sh | 2 +- ciscripts/wakame-vdc/create-lbweb.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/wakame-vdc/create-lbapp.sh b/ciscripts/wakame-vdc/create-lbapp.sh index 7c2154e..792b419 100755 --- a/ciscripts/wakame-vdc/create-lbapp.sh +++ b/ciscripts/wakame-vdc/create-lbapp.sh @@ -15,7 +15,7 @@ max_connection="1000" instance_port="8080" instance_protocol="http" port_maps="8080:http" -display_name="lb8080" +display_name="lbapp" # diff --git a/ciscripts/wakame-vdc/create-lbweb.sh b/ciscripts/wakame-vdc/create-lbweb.sh index d7cf774..780783a 100755 --- a/ciscripts/wakame-vdc/create-lbweb.sh +++ b/ciscripts/wakame-vdc/create-lbweb.sh @@ -15,7 +15,7 @@ max_connection="1000" instance_port="80" instance_protocol="http" port_maps="80:http" -display_name="lb80" +display_name="lbweb" # From 7067073f100ab3cb05697b0320ecef16bc25b88b Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:27:10 +0900 Subject: [PATCH 132/147] add IMAGE_ID. --- ciscripts/wakame-vdc/create-app.sh | 8 +++----- ciscripts/wakame-vdc/create-db.sh | 8 +++----- ciscripts/wakame-vdc/setup-app.sh | 2 ++ ciscripts/wakame-vdc/setup-db.sh | 3 +++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 332842d..35ea137 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -4,6 +4,8 @@ set -e set -o pipefail set -u +: "${IMAGE_ID:?"should not be empty"}" + # vifs network_id="nw-demo1" @@ -15,7 +17,7 @@ vifs="vifs.json" cpu_cores="1" hypervisor="kvm" memory_size="1024" -#image_id="wmi-***" +image_id="${IMAGE_ID}" display_name="app" ssh_key_id="ssh-cicddemo" @@ -25,10 +27,6 @@ if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then . ${BASH_SOURCE[0]%/*}/config/${display_name} fi -# - -: "${image_id:?"should not be empty"}" - ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index 3e4160d..bedd2d2 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -4,6 +4,8 @@ set -e set -o pipefail set -u +: "${IMAGE_ID:?"should not be empty"}" + # vifs network_id="nw-demo1" @@ -15,7 +17,7 @@ vifs="vifs.json" cpu_cores="1" hypervisor="kvm" memory_size="512" -#image_id="wmi-***" +image_id="${IMAGE_ID}" display_name="db" ssh_key_id="ssh-cicddemo" @@ -25,10 +27,6 @@ if [[ -f ${BASH_SOURCE[0]%/*}/config/${display_name} ]]; then . ${BASH_SOURCE[0]%/*}/config/${display_name} fi -# - -: "${image_id:?"should not be empty"}" - ## create an instance ${BASH_SOURCE[0]%/*}/gen-musselrc.sh diff --git a/ciscripts/wakame-vdc/setup-app.sh b/ciscripts/wakame-vdc/setup-app.sh index bd4700b..d763d56 100755 --- a/ciscripts/wakame-vdc/setup-app.sh +++ b/ciscripts/wakame-vdc/setup-app.sh @@ -5,10 +5,12 @@ set -e set -o pipefail set -u +: "${IMAGE_ID:?"should not be empty"}" : "${YUM_HOST:?"should not be empty"}" : "${DB_HOST:?"should not be empty"}" eval "$( + IMAGE_ID="${IMAGE_ID}" \ YUM_HOST="${YUM_HOST}" \ DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/run-app.sh diff --git a/ciscripts/wakame-vdc/setup-db.sh b/ciscripts/wakame-vdc/setup-db.sh index 9048566..de711e4 100755 --- a/ciscripts/wakame-vdc/setup-db.sh +++ b/ciscripts/wakame-vdc/setup-db.sh @@ -5,7 +5,10 @@ set -e set -o pipefail set -u +: "${IMAGE_ID:?"should not be empty"}" + eval "$( + IMAGE_ID="${IMAGE_ID}" \ ${BASH_SOURCE[0]%/*}/run-db.sh )" From 6d37c3d0cc45ecff5a69a76441579fc6957a1cd1 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:33:12 +0900 Subject: [PATCH 133/147] add DB_IMAGE_ID APP_IMAGE_ID. --- ciscripts/web3layers-ci.sh | 4 ++++ ciscripts/web3layers-lite.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ciscripts/web3layers-ci.sh b/ciscripts/web3layers-ci.sh index 8c22a08..839ccbb 100755 --- a/ciscripts/web3layers-ci.sh +++ b/ciscripts/web3layers-ci.sh @@ -8,6 +8,8 @@ set -u # required shell params : "${YUM_HOST:?"should not be empty"}" +: "${DB_IMAGE_ID:?"should not be empty"}" +: "${APP_IMAGE_ID:?"should not be empty"}" # @@ -16,10 +18,12 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # setup instances eval "$( + IMAGE_ID="${DB_IMAGE_ID}" \ ${BASH_SOURCE[0]%/*}/setup-db.sh )" eval "$( + IMAGE_ID="${APP_IMAGE_ID}" \ YUM_HOST="${YUM_HOST}" DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/setup-app.sh )" diff --git a/ciscripts/web3layers-lite.sh b/ciscripts/web3layers-lite.sh index 485f1af..91c0aa9 100755 --- a/ciscripts/web3layers-lite.sh +++ b/ciscripts/web3layers-lite.sh @@ -8,6 +8,8 @@ set -u # required shell params : "${YUM_HOST:?"should not be empty"}" +: "${DB_IMAGE_ID:?"should not be empty"}" +: "${APP_IMAGE_ID:?"should not be empty"}" # @@ -16,10 +18,12 @@ cd ${BASH_SOURCE[0]%/*}/wakame-vdc # setup instances eval "$( + IMAGE_ID="${DB_IMAGE_ID}" \ ${BASH_SOURCE[0]%/*}/setup-db.sh )" eval "$( + IMAGE_ID="${APP_IMAGE_ID}" \ YUM_HOST="${YUM_HOST}" DB_HOST="${DB_HOST}" \ ${BASH_SOURCE[0]%/*}/setup-app.sh )" From 8a5a7fb265a034b237e1c422ca7fa6924f67ca51 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:42:40 +0900 Subject: [PATCH 134/147] update readme. --- ciscripts/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ciscripts/README.md b/ciscripts/README.md index 14afe68..ecd1830 100644 --- a/ciscripts/README.md +++ b/ciscripts/README.md @@ -1,6 +1,7 @@ ## JenkinsCI -Add the following code to JenkinsCI shell job. +$B%7%'%k%8%g%V$K2<5-FbMF$rDj5A$7$F2<$5$$!#(B +$B$J$*!"(B`APP_IMAGE_ID`$B$H(B`DB_IMAGE_ID`$B$K$O!"$=$l$>$l?75,:n@.$7$?%^%7%s%$%a!<%8(BID$B$GCV$-49$($F2<$5$$!#(B ``` #!/bin/bash @@ -15,5 +16,9 @@ cd ciscripts ls -l ipaddr="$(< /metadata/meta-data/local-ipv4)" -YUM_HOST="${ipaddr}" ./web3layers-ci.sh + +APP_IMAGE_ID="wmi-********" \ + DB_IMAGE_ID="wmi-********" \ + YUM_HOST="${ipaddr}" \ + ./web3layers-ci.sh ``` From 4e272d13ac23ee690e359cde9868272dad89b091 Mon Sep 17 00:00:00 2001 From: Masahito Yoshida Date: Wed, 27 May 2015 18:44:06 +0900 Subject: [PATCH 135/147] Update README.md --- ciscripts/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/README.md b/ciscripts/README.md index ecd1830..5bb8769 100644 --- a/ciscripts/README.md +++ b/ciscripts/README.md @@ -1,7 +1,7 @@ ## JenkinsCI -$B%7%'%k%8%g%V$K2<5-FbMF$rDj5A$7$F2<$5$$!#(B -$B$J$*!"(B`APP_IMAGE_ID`$B$H(B`DB_IMAGE_ID`$B$K$O!"$=$l$>$l?75,:n@.$7$?%^%7%s%$%a!<%8(BID$B$GCV$-49$($F2<$5$$!#(B +シェルジョブに下記内容を定義して下さい。 +なお、`APP_IMAGE_ID`と`DB_IMAGE_ID`には、それぞれ新規作成したマシンイメージIDで置き換えて下さい。 ``` #!/bin/bash From 83125d8d46a1c0fb56037eed08c0702d1b59bc77 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Thu, 28 May 2015 22:53:56 +0900 Subject: [PATCH 136/147] Remove duplication code. --- ciscripts/wakame-vdc/provision-app.sh | 47 --------------------------- 1 file changed, 47 deletions(-) diff --git a/ciscripts/wakame-vdc/provision-app.sh b/ciscripts/wakame-vdc/provision-app.sh index a54da3a..f697297 100755 --- a/ciscripts/wakame-vdc/provision-app.sh +++ b/ciscripts/wakame-vdc/provision-app.sh @@ -13,53 +13,6 @@ set -x : "${YUM_HOST:?"should not be empty"}" : "${DB_HOST:?"should not be empty"}" -# install tiny-web-example.repo -cat <<-EOS > /etc/yum.repos.d/tiny-web-example.repo - [tin-web-example] - name=tiny-web-example - baseurl=http://${YUM_HOST}/pub/ - enabled=1 - gpgcheck=0 - EOS - -# show available repo list -yum repolist - -# install tiny-web-example.rpm -yum install -y tiny-web-example - -## /etc/default/tiny-web-example-webapi -cat <<-'EOS' > /etc/default/tiny-web-example-webapi - # tiny-web-example - EXAMPLE_ROOT=/opt/axsh/tiny-web-example - PATH=/root/.rbenv/shims:$PATH - - # Commnet out to run the vdc init script. - #RUN=yes - - ## rack params - RACK_ENV=development - BIND_ADDR=0.0.0.0 - PORT=8080 - UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf - EOS - -## /etc/default/tiny-web-example-webapp -cat <<-'EOS' > /etc/default/tiny-web-example-webapp - # tiny-web-example - EXAMPLE_ROOT=/opt/axsh/tiny-web-example - PATH=/root/.rbenv/shims:$PATH - - # Commnet out to run the vdc init script. - #RUN=yes - - ## rack params - RACK_ENV=development - BIND_ADDR=0.0.0.0 - PORT=80 - UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf - EOS - # configure db host for config in /etc/tiny-web-example/webapi.conf /etc/tiny-web-example/webapp.yml; do sed -i "s,localhost,${DB_HOST}," "${config}" From a7b8905d64488984af67e61b811837ae27556ab8 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Thu, 28 May 2015 22:54:24 +0900 Subject: [PATCH 137/147] Added image build scripts. --- ciscripts/image-build.sh | 124 +++++++++++++++++++++++ ciscripts/wakame-vdc/provision-imgapp.sh | 99 ++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100755 ciscripts/image-build.sh create mode 100755 ciscripts/wakame-vdc/provision-imgapp.sh diff --git a/ciscripts/image-build.sh b/ciscripts/image-build.sh new file mode 100755 index 0000000..ebda2fc --- /dev/null +++ b/ciscripts/image-build.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# +# +set -e +set -o pipefail +set -u + +# required shell params + +: "${IMAGE_ID:?"should not be empty"}" +: "${YUM_HOST:?"should not be empty"}" + +cd ${BASH_SOURCE[0]%/*}/wakame-vdc + +# wait for the instance to be running +. ${BASH_SOURCE[0]%/*}/retry.sh + +# vifs +network_id="nw-demo1" +security_group_id="sg-cicddemo" +vifs="vifs.json" + +# instance-specific parameter +cpu_cores="1" +hypervisor="kvm" +memory_size="512" +image_id="${IMAGE_ID}" +ssh_key_id="ssh-cicddemo" + +# create an musselrc +${BASH_SOURCE[0]%/*}/gen-musselrc.sh + +# create an vifs +vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ + ${BASH_SOURCE[0]%/*}/gen-vifs.sh + +## create database image + +# db display name +display_name="db" + +# create an instance +instance_id="$( + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +trap 'mussel instance destroy "${instance_id}"' ERR + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] + +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" + +{ + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh +} >&2 + +mussel instance poweroff --force false ${instance_id} + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] + +DB_IMAGE_ID="$(mussel instance backup ${instance_id} | egrep ^:image_id: | awk '{print $2}')" +echo "database image id: ${DB_IMAGE_ID}" + +retry_until [[ '"$(mussel image show "${DB_IMAGE_ID}" | egrep -w "^:state: available")"' ]] + +mussel instance destroy "${instance_id}" + +## create app image + +# app display name +display_name="app" + +# create an instance +instance_id="$( + mussel instance create \ + --cpu-cores "${cpu_cores}" \ + --hypervisor "${hypervisor}" \ + --image-id "${image_id}" \ + --memory-size "${memory_size}" \ + --ssh-key-id "${ssh_key_id}" \ + --vifs "${vifs}" \ + --display-name "${display_name}" \ + | egrep ^:id: | awk '{print $2}' +)" +: "${instance_id:?"should not be empty"}" +echo "${instance_id} is initializing..." >&2 + +trap 'mussel instance destroy "${instance_id}"' ERR + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] + +eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" + +{ + ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ + YUM_HOST="${YUM_HOST}" \ + bash -l < ${BASH_SOURCE[0]%/*}/provision-imgapp.sh +} >&2 + +mussel instance poweroff --force false ${instance_id} + +retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] + +APP_IMAGE_ID="$(mussel instance backup ${instance_id} | egrep ^:image_id: | awk '{print $2}')" +echo "app image id: ${APP_IMAGE_ID}" + +RETRY_WAIT_SEC=180 retry_until [[ '"$(mussel image show "${APP_IMAGE_ID}" | egrep -w "^:state: available")"' ]] + +mussel instance destroy "${instance_id}" + +echo DB_IMAGE_ID="${DB_IMAGE_ID}" +echo APP_IMAGE_ID="${APP_IMAGE_ID}" diff --git a/ciscripts/wakame-vdc/provision-imgapp.sh b/ciscripts/wakame-vdc/provision-imgapp.sh new file mode 100755 index 0000000..91c595f --- /dev/null +++ b/ciscripts/wakame-vdc/provision-imgapp.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# +# requires: +# bash +# +set -e +set -o pipefail +set -u +set -x + +# required shell params +: "${YUM_HOST:?"should not be empty"}" + +# git +yum install -y git + +# epel +rpm -qa epel-release* | egrep -q epel-release || { + rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm + sed -i \ + -e 's,^#baseurl,baseurl,' \ + -e 's,^mirrorlist=,#mirrorlist=,' \ + -e 's,http://download.fedoraproject.org/pub/epel/,http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/,' \ + /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo + yum install -y ca-certificates +} +yum repolist + +# install rbenv +git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +# setup rbenv +echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +echo 'eval "$(rbenv init -)"' >> ~/.bash_profile +exec $SHELL -l + +# install build require for ruby-build +yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel + +# install ruby-build +git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build + +# install ruby +ruby_version="2.0.0-p598" + +rbenv install -v "${ruby_version}" +rbenv rehash +rbenv versions +rbenv global "${ruby_version}" +ruby -v + +# install bundler +gem install bundler --no-ri --no-rdoc + +# install tiny-web-example.repo +cat <<-EOS > /etc/yum.repos.d/tiny-web-example.repo +[tin-web-example] +name=tiny-web-example +baseurl=http://${YUM_HOST}/pub/ +enabled=1 +gpgcheck=0 +EOS + +# show available repo list +yum repolist + +# install tiny-web-example.rpm +yum install -y tiny-web-example + +## /etc/default/tiny-web-example-webapi +cat <<-'EOS' > /etc/default/tiny-web-example-webapi + # tiny-web-example + EXAMPLE_ROOT=/opt/axsh/tiny-web-example + PATH=/root/.rbenv/shims:$PATH + + # Commnet out to run the vdc init script. + #RUN=yes + + ## rack params + RACK_ENV=development + BIND_ADDR=0.0.0.0 + PORT=8080 + UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf + EOS + +## /etc/default/tiny-web-example-webapp +cat <<-'EOS' > /etc/default/tiny-web-example-webapp + # tiny-web-example + EXAMPLE_ROOT=/opt/axsh/tiny-web-example + PATH=/root/.rbenv/shims:$PATH + + # Commnet out to run the vdc init script. + #RUN=yes + + ## rack params + RACK_ENV=development + BIND_ADDR=0.0.0.0 + PORT=80 + UNICORN_CONF=/etc/tiny-web-example/unicorn-common.conf + EOS From 964fcafddc36b65df9ce45d7d4875f44e9d8d6cc Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 29 May 2015 16:43:20 +0900 Subject: [PATCH 138/147] Remove yum host check. --- ciscripts/wakame-vdc/provision-app.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ciscripts/wakame-vdc/provision-app.sh b/ciscripts/wakame-vdc/provision-app.sh index f697297..8f87843 100755 --- a/ciscripts/wakame-vdc/provision-app.sh +++ b/ciscripts/wakame-vdc/provision-app.sh @@ -10,7 +10,6 @@ set -x # required shell params -: "${YUM_HOST:?"should not be empty"}" : "${DB_HOST:?"should not be empty"}" # configure db host From a6f6e5c36159b016b589f1be6f9262bce62ccfad Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 29 May 2015 16:44:50 +0900 Subject: [PATCH 139/147] Fixed image-build.sh. --- ciscripts/image-build.sh | 51 ++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/ciscripts/image-build.sh b/ciscripts/image-build.sh index ebda2fc..9e616e1 100755 --- a/ciscripts/image-build.sh +++ b/ciscripts/image-build.sh @@ -28,11 +28,17 @@ image_id="${IMAGE_ID}" ssh_key_id="ssh-cicddemo" # create an musselrc -${BASH_SOURCE[0]%/*}/gen-musselrc.sh +cat < ~/.musselrc +DCMGR_HOST=10.0.2.2 +account_id=a-shpoolxx +EOS # create an vifs -vifs="${vifs}" network_id="${network_id}" security_group_id="${security_group_id}" \ - ${BASH_SOURCE[0]%/*}/gen-vifs.sh +cat < "${vifs}" +{ + "eth0":{"network":"${network_id}","security_groups":"${security_group_id}"} +} +EOS ## create database image @@ -58,18 +64,24 @@ trap 'mussel instance destroy "${instance_id}"' ERR retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] -eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" +ipaddr="$( + mussel instance show "${instance_id}" \ + | egrep :address: \ + | awk '{print $2}' \ + | tr '\n' ',' +)" +: "${ipaddr:?"should not be empty"}" +ipaddr="${ipaddr%%,}" + +${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" +${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh -{ - ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" - ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh -} >&2 mussel instance poweroff --force false ${instance_id} retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] -DB_IMAGE_ID="$(mussel instance backup ${instance_id} | egrep ^:image_id: | awk '{print $2}')" +DB_IMAGE_ID="$(mussel instance backup ${instance_id} --display-name db | egrep ^:image_id: | awk '{print $2}')" echo "database image id: ${DB_IMAGE_ID}" retry_until [[ '"$(mussel image show "${DB_IMAGE_ID}" | egrep -w "^:state: available")"' ]] @@ -100,20 +112,25 @@ trap 'mussel instance destroy "${instance_id}"' ERR retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] -eval "$(${BASH_SOURCE[0]%/*}/instance-get-ipaddr.sh "${instance_id}")" +ipaddr="$( + mussel instance show "${instance_id}" \ + | egrep :address: \ + | awk '{print $2}' \ + | tr '\n' ',' +)" +: "${ipaddr:?"should not be empty"}" +ipaddr="${ipaddr%%,}" -{ - ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" - ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ - YUM_HOST="${YUM_HOST}" \ - bash -l < ${BASH_SOURCE[0]%/*}/provision-imgapp.sh -} >&2 +${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" +${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ + YUM_HOST="${YUM_HOST}" \ + bash -l < ${BASH_SOURCE[0]%/*}/provision-imgapp.sh mussel instance poweroff --force false ${instance_id} retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] -APP_IMAGE_ID="$(mussel instance backup ${instance_id} | egrep ^:image_id: | awk '{print $2}')" +APP_IMAGE_ID="$(mussel instance backup ${instance_id} --display-name app | egrep ^:image_id: | awk '{print $2}')" echo "app image id: ${APP_IMAGE_ID}" RETRY_WAIT_SEC=180 retry_until [[ '"$(mussel image show "${APP_IMAGE_ID}" | egrep -w "^:state: available")"' ]] From 8f544a28b5df4b90f9fc04336c216fab17f6cbe3 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 29 May 2015 17:27:38 +0900 Subject: [PATCH 140/147] Added description. --- ciscripts/image-build.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/ciscripts/image-build.sh b/ciscripts/image-build.sh index 9e616e1..de29a2f 100755 --- a/ciscripts/image-build.sh +++ b/ciscripts/image-build.sh @@ -58,12 +58,15 @@ instance_id="$( | egrep ^:id: | awk '{print $2}' )" : "${instance_id:?"should not be empty"}" -echo "${instance_id} is initializing..." >&2 +echo "${instance_id} is initializing..." trap 'mussel instance destroy "${instance_id}"' ERR +# wait for the instance to be running retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] +echo "${instance_id} is running" +# get instance ipaddr ipaddr="$( mussel instance show "${instance_id}" \ | egrep :address: \ @@ -72,21 +75,33 @@ ipaddr="$( )" : "${ipaddr:?"should not be empty"}" ipaddr="${ipaddr%%,}" +echo "${instance_id} ipaddr: ${ipaddr}" +# wait for ssh to be ready ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" -${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh +# install package +${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" < ${BASH_SOURCE[0]%/*}/provision-imgdb.sh +# instance state: running -> halted mussel instance poweroff --force false ${instance_id} +echo "${instance_id} is halting" +# wait for the instance to be halted retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] +echo "${instance_id} is halted" +# instance backup DB_IMAGE_ID="$(mussel instance backup ${instance_id} --display-name db | egrep ^:image_id: | awk '{print $2}')" echo "database image id: ${DB_IMAGE_ID}" +# wait for the image to be available retry_until [[ '"$(mussel image show "${DB_IMAGE_ID}" | egrep -w "^:state: available")"' ]] +echo "${DB_IMAGE_ID} is available" +# instance destroy mussel instance destroy "${instance_id}" +echo "${instance_id} is deleted" ## create app image @@ -106,12 +121,15 @@ instance_id="$( | egrep ^:id: | awk '{print $2}' )" : "${instance_id:?"should not be empty"}" -echo "${instance_id} is initializing..." >&2 +echo "${instance_id} is initializing..." trap 'mussel instance destroy "${instance_id}"' ERR +# wait for the instance to be running retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]] +echo "${instance_id} is running" +# get instance ipaddr ipaddr="$( mussel instance show "${instance_id}" \ | egrep :address: \ @@ -120,22 +138,35 @@ ipaddr="$( )" : "${ipaddr:?"should not be empty"}" ipaddr="${ipaddr%%,}" +echo "${instance_id} ipaddr: ${ipaddr}" +# wait for ssh to be ready ${BASH_SOURCE[0]%/*}/instance-wait4ssh.sh "${instance_id}" + +# install package ${BASH_SOURCE[0]%/*}/instance-exec.sh "${instance_id}" \ YUM_HOST="${YUM_HOST}" \ bash -l < ${BASH_SOURCE[0]%/*}/provision-imgapp.sh +# instance state: running -> halted mussel instance poweroff --force false ${instance_id} +echo "${instance_id} is halting" +# wait for the instance to be halted retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: halted")"' ]] +echo "${instance_id} is halted" +# instance backup APP_IMAGE_ID="$(mussel instance backup ${instance_id} --display-name app | egrep ^:image_id: | awk '{print $2}')" echo "app image id: ${APP_IMAGE_ID}" +# wait for the image to be available RETRY_WAIT_SEC=180 retry_until [[ '"$(mussel image show "${APP_IMAGE_ID}" | egrep -w "^:state: available")"' ]] +echo "${DB_IMAGE_ID} is available" +# instance destroy mussel instance destroy "${instance_id}" +echo "${instance_id} is deleted" echo DB_IMAGE_ID="${DB_IMAGE_ID}" echo APP_IMAGE_ID="${APP_IMAGE_ID}" From b8cd02feb978d1bf96fcc357289b63c34d125018 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 29 May 2015 21:01:51 +0900 Subject: [PATCH 141/147] Added file write. --- ciscripts/image-build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ciscripts/image-build.sh b/ciscripts/image-build.sh index de29a2f..d1d5c22 100755 --- a/ciscripts/image-build.sh +++ b/ciscripts/image-build.sh @@ -9,6 +9,7 @@ set -u : "${IMAGE_ID:?"should not be empty"}" : "${YUM_HOST:?"should not be empty"}" +: "${WRITE_FILE:?"shoud not be empty"}" cd ${BASH_SOURCE[0]%/*}/wakame-vdc @@ -170,3 +171,6 @@ echo "${instance_id} is deleted" echo DB_IMAGE_ID="${DB_IMAGE_ID}" echo APP_IMAGE_ID="${APP_IMAGE_ID}" + +echo "DB_IMAGE_ID=${DB_IMAGE_ID}" > ${WRITE_FILE} +echo "APP_IMAGE_ID=${APP_IMAGE_ID}" >> ${WRITE_FILE} From 66932c0659f908605bbe6d83eb5a4957a78a6d7b Mon Sep 17 00:00:00 2001 From: t-iwano Date: Fri, 29 May 2015 21:02:25 +0900 Subject: [PATCH 142/147] Added README for Image Build. --- ciscripts/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ciscripts/README.md b/ciscripts/README.md index 5bb8769..498134e 100644 --- a/ciscripts/README.md +++ b/ciscripts/README.md @@ -1,3 +1,20 @@ +## Image Build + +シェルスクリプトに下記内容を定義してください。 + +``` +#!/bin/bash +# +# +set -e +set -o pipefail +set -u +set -x +cd ciscripts + +WRITE_FILE=${WORKSPACE}/${BUILD_TAG} IMAGE_ID=${image_id} YUM_HOST=${yum_host} ./image-build.sh +``` + ## JenkinsCI シェルジョブに下記内容を定義して下さい。 From 0616f18fffbbbf0de561246afe66c12abf93738f Mon Sep 17 00:00:00 2001 From: zonomasa Date: Sat, 30 May 2015 06:14:50 -0700 Subject: [PATCH 143/147] Fix explanation of integration-test --- spec_integration/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_integration/README.md b/spec_integration/README.md index ba3024e..fec44fe 100644 --- a/spec_integration/README.md +++ b/spec_integration/README.md @@ -45,7 +45,7 @@ CentOS-6.6にて動作確認を行いました。それよりも古い環境の # cp webapi.conf.example webapi.conf ``` -webapiに接続するDataBaseのIPアドレスを記述します +webapiに接続するWebサーバーのIPアドレスを記述します ``` # vi webapi.conf ``` From 9a7c96b1f067ee4adaa0ec7f45548d5c95f4b542 Mon Sep 17 00:00:00 2001 From: toros11 Date: Tue, 1 Mar 2016 22:20:10 +0900 Subject: [PATCH 144/147] Use openvz as hypervisor --- ciscripts/image-build.sh | 2 +- ciscripts/wakame-vdc/create-app.sh | 2 +- ciscripts/wakame-vdc/create-centos.sh | 2 +- ciscripts/wakame-vdc/create-db.sh | 2 +- ciscripts/wakame-vdc/create-imgdb.sh | 2 +- ciscripts/wakame-vdc/create-imgrbenv.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ciscripts/image-build.sh b/ciscripts/image-build.sh index d1d5c22..9520c10 100755 --- a/ciscripts/image-build.sh +++ b/ciscripts/image-build.sh @@ -23,7 +23,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="512" image_id="${IMAGE_ID}" ssh_key_id="ssh-cicddemo" diff --git a/ciscripts/wakame-vdc/create-app.sh b/ciscripts/wakame-vdc/create-app.sh index 35ea137..63e7318 100755 --- a/ciscripts/wakame-vdc/create-app.sh +++ b/ciscripts/wakame-vdc/create-app.sh @@ -15,7 +15,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="1024" image_id="${IMAGE_ID}" display_name="app" diff --git a/ciscripts/wakame-vdc/create-centos.sh b/ciscripts/wakame-vdc/create-centos.sh index 543fa61..71608b6 100755 --- a/ciscripts/wakame-vdc/create-centos.sh +++ b/ciscripts/wakame-vdc/create-centos.sh @@ -13,7 +13,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="1024" image_id="wmi-centos1d64" display_name="centos" diff --git a/ciscripts/wakame-vdc/create-db.sh b/ciscripts/wakame-vdc/create-db.sh index bedd2d2..691671a 100755 --- a/ciscripts/wakame-vdc/create-db.sh +++ b/ciscripts/wakame-vdc/create-db.sh @@ -15,7 +15,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="512" image_id="${IMAGE_ID}" display_name="db" diff --git a/ciscripts/wakame-vdc/create-imgdb.sh b/ciscripts/wakame-vdc/create-imgdb.sh index 4e893f2..43ae80e 100755 --- a/ciscripts/wakame-vdc/create-imgdb.sh +++ b/ciscripts/wakame-vdc/create-imgdb.sh @@ -13,7 +13,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="512" image_id="wmi-centos1d64" display_name="imgdb" diff --git a/ciscripts/wakame-vdc/create-imgrbenv.sh b/ciscripts/wakame-vdc/create-imgrbenv.sh index 415fbd8..fb88ac5 100755 --- a/ciscripts/wakame-vdc/create-imgrbenv.sh +++ b/ciscripts/wakame-vdc/create-imgrbenv.sh @@ -13,7 +13,7 @@ vifs="vifs.json" # instance-specific parameter cpu_cores="1" -hypervisor="kvm" +hypervisor="openvz" memory_size="1024" image_id="wmi-centos1d64" display_name="imgrbenv" From 901e323ee797e1b2ea2a0b719cba6c14ab8e9424 Mon Sep 17 00:00:00 2001 From: toros11 Date: Fri, 13 May 2016 18:04:57 +0900 Subject: [PATCH 145/147] Changed host settings to work with 1box --- ciscripts/wakame-vdc/gen-musselrc.sh | 2 +- ciscripts/wakame-vdc/provision-imgdb.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/wakame-vdc/gen-musselrc.sh b/ciscripts/wakame-vdc/gen-musselrc.sh index 4432100..fdd480a 100755 --- a/ciscripts/wakame-vdc/gen-musselrc.sh +++ b/ciscripts/wakame-vdc/gen-musselrc.sh @@ -7,6 +7,6 @@ set -u # setup musselrc cat < ~/.musselrc -DCMGR_HOST=10.0.2.2 +DCMGR_HOST=10.0.2.15 account_id=a-shpoolxx EOS diff --git a/ciscripts/wakame-vdc/provision-imgdb.sh b/ciscripts/wakame-vdc/provision-imgdb.sh index 4e4c966..a454d6b 100755 --- a/ciscripts/wakame-vdc/provision-imgdb.sh +++ b/ciscripts/wakame-vdc/provision-imgdb.sh @@ -31,7 +31,7 @@ done # db params dbname="tiny_web_example" dbuser="root" -dbacl="10.0.22.%" +dbacl="10.0.2.%" # grant db mysql -u${dbuser} mysql < Date: Tue, 23 May 2017 20:04:14 +0900 Subject: [PATCH 146/147] Added libcurl package --- ciscripts/wakame-vdc/provision-imgapp.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ciscripts/wakame-vdc/provision-imgapp.sh b/ciscripts/wakame-vdc/provision-imgapp.sh index 91c595f..812241c 100755 --- a/ciscripts/wakame-vdc/provision-imgapp.sh +++ b/ciscripts/wakame-vdc/provision-imgapp.sh @@ -26,6 +26,11 @@ rpm -qa epel-release* | egrep -q epel-release || { } yum repolist +# update libcurl +rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm +sed -i "s,enabled=1,enabled=0," /etc/yum.repos.d/city-fan.org.repo +yum update -y --enablerepo=city-fan.org libcurl + # install rbenv git clone https://github.com/sstephenson/rbenv.git ~/.rbenv # setup rbenv From ba1d15fe4e5833db5ed6bcdaad0c1698803da764 Mon Sep 17 00:00:00 2001 From: t-iwano Date: Tue, 23 May 2017 20:05:05 +0900 Subject: [PATCH 147/147] Fixed ruby version --- ciscripts/wakame-vdc/provision-imgapp.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciscripts/wakame-vdc/provision-imgapp.sh b/ciscripts/wakame-vdc/provision-imgapp.sh index 812241c..b2a9348 100755 --- a/ciscripts/wakame-vdc/provision-imgapp.sh +++ b/ciscripts/wakame-vdc/provision-imgapp.sh @@ -39,13 +39,13 @@ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile exec $SHELL -l # install build require for ruby-build -yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel +yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel libffi-devel # install ruby-build git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # install ruby -ruby_version="2.0.0-p598" +ruby_version="2.2.2" rbenv install -v "${ruby_version}" rbenv rehash