Ind.ie is now Small Technology Foundation.
Commit aae55f31 authored by Stefan van den Oord's avatar Stefan van den Oord

Created cookbook for Pulse integration testing

parent 53b5e6a1
......@@ -5,3 +5,6 @@ build
docs
.ruby-gemset
.ruby-version
.kitchen/
.kitchen.local.yml
---
driver:
name: vagrant
network:
- ["public_network", {bridge: 'en0: Wi-Fi (AirPort)'}]
provisioner:
name: chef_solo
platforms:
- name: ubuntu-12.04
suites:
- name: default
run_list:
- recipe[apt]
- recipe[pulse-cookbook::default]
attributes:
source "https://api.berkshelf.com"
metadata
DEPENDENCIES
pulse-cookbook
path: .
metadata: true
GRAPH
apt (2.7.0)
build-essential (2.2.2)
chef_handler (1.1.6)
curl (2.0.1)
dmg (2.2.2)
git (4.1.0)
build-essential (>= 0.0.0)
dmg (>= 0.0.0)
runit (>= 1.0)
windows (>= 0.0.0)
yum (~> 3.0)
yum-epel (>= 0.0.0)
pulse-cookbook (0.1.1)
apt (~> 2.7.0)
curl (~> 2.0.1)
git (~> 4.1.0)
runit (1.5.18)
build-essential (>= 0.0.0)
yum (~> 3.0)
yum-epel (>= 0.0.0)
windows (1.36.6)
chef_handler (>= 0.0.0)
yum (3.5.3)
yum-epel (0.6.0)
yum (~> 3.0)
#!/bin/sh
#
# This script sets up an instance of pulse that can be used to run the integration
# tests. You should have to run this only once for your development setup.
#
################################################################################
### CONFIGURATION
################################################################################
testRoot="/tmp/pulse-swift"
pulseDir="$testRoot/src/source.ind.ie/project"
pulseAddress="http://127.0.0.1:59296"
pulseapikey="jobt7d8klok5l8n818q1noq2t683nu"
testDeviceId="R7R33FF-MP337M2-HEN63VU-SWFM7LS-U2CLBLY-T6L56SJ-JHDXDT6-55ZVRAM"
################################################################################
### DON'T CHANGE BELOW
################################################################################
fatal() {
echo "[fatal] $1" 1>&2
exit 1
}
absPath() {
case "$1" in
/*)
printf "%s\n" "$1"
;;
*)
printf "%s\n" "$PWD/$1"
;;
esac;
}
logStep() {
echo ""
echo "$1"
echo "$1" | sed "s/./-/g"
}
scriptDir="`dirname $0`"
scriptName="`basename $0`"
absScriptDir="`cd $scriptDir; pwd`"
absPulseDir="`absPath $pulseDir`"
gopath=""
pulse=""
pulsehome=""
GO="$GOROOT/bin/go"
installGo() {
mkdir -p "$testRoot"
goArch="https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz"
curl -s -o "$testRoot/go.tar.gz" "$goArch" || fatal "Could not download go archive"
(
cd "$testRoot"
tar xzf go.tar.gz || fatal "Could not expand go archive"
rm go.tar.gz
)
}
checkPreconditions() {
logStep "Check preconditions"
if ( test "$PWD" != "$absScriptDir" ); then
fatal "This script must be run from the directory where it is stored."
else
echo "current dir [ok]"
fi
if ( test -d "$pulseDir" ); then
fatal "Pulse folder $pulseDir already exists."
else
echo "pulse doesn't already exist [ok]"
fi
if ( test -z "$GOROOT" || ! test -x "$GOROOT/bin/go" ); then
echo "go executable not found; downloading go... \c"
installGo
export GOROOT="$testRoot/go"
export PATH=$GOROOT/bin:$PATH
export GO=$GOROOT/bin/go
echo "[ok]"
fi
if ( test -z "$GOROOT" || ! test -x "$GOROOT/bin/go" ); then
fatal "GOROOT must be set and contain executable go"
else
echo "GOROOT [ok]"
fi
gopath="`echo $absPulseDir | sed \"s,/src/source.ind.ie/project,,\"`"
if ( test "$gopath" == "" ); then
fatal "Could not determine correct go path for building pulse"
else
echo "path for building pulse [ok]"
fi
pulsehome="$gopath/pulsehome"
pulse="$absPulseDir/pulse/bin/pulse"
}
clonePulse() {
logStep "Clone pulse"
(
export GOPATH="$gopath"
mkdir -p "$pulseDir" || fatal "Could not create pulse folder"
cd "$pulseDir" || fatal "Could not change to pulse folder"
echo "Cloning pulse... \c"
( git clone https://source.ind.ie/project/pulse.git > $testRoot/pulse-clone.log 2>&1 ) || fatal "Could not clone pulse; check log file $testRoot/pulse-clone.log"
echo "[ok]"
(
cd pulse || fatal "Could not change to cloned pulse"
echo "Building pulse...\c "
( $GO run build.go > $testRoot/pulse-build.log 2>&1 ) || fatal "Could not build pulse; check log file $testRoot/pulse-build.log"
echo "[ok]"
)
)
}
configurePulse() {
logStep "Configure pulse"
mkdir -p "$pulsehome"
deviceId=`"$pulse" -generate="$pulsehome" | grep "Device ID:" | awk '{print $NF}'`
(echo "$deviceId" | egrep "^([0-9A-Z]{7}-){7}[0-9A-Z]{7}$" > /dev/null) || fatal "Device id $deviceId does not have expected format"
config="$pulsehome/config.xml"
newconfig="$config.new"
head -1 $config > $newconfig || fatal "Error modifying config: head"
echo " <folder id=\"pulse-integrationTests\" path=\"$pulsehome/Sync\" ro=\"false\" rescanIntervalS=\"60\" ignorePerms=\"false\">" >> $newconfig || fatal "Error modifying config: folder"
echo " <device id=\"$deviceId\"></device>" >> $newconfig || fatal "Error modifying config: deviceid"
echo " <versioning></versioning>" >> $newconfig || fatal "Error modifying config: versioning"
echo " <lenientMtimes>false</lenientMtimes>" >> $newconfig || fatal "Error modifying config: lenientMtimes"
echo " <copiers>0</copiers>" >> $newconfig || fatal "Error modifying config: copiers"
echo " <pullers>0</pullers>" >> $newconfig || fatal "Error modifying config: pullers"
echo " <finishers>0</finishers>" >> $newconfig || fatal "Error modifying config: finishers"
echo " </folder>" >> $newconfig || fatal "Error modifying config: /folder"
echo " <device id=\"$testDeviceId\" name=\"pulse-swiftIntegration\" compression=\"false\" introducer=\"false\">" >> $newconfig || fatal "Error modifying config: test device id"
echo " <address>dynamic</address>" >> $newconfig || fatal "Error modifying config: test device id addr"
echo " </device>" >> $newconfig || fatal "Error modifying config: /test device id"
tail -n +2 $config | sed "s,^\(.*<apikey>\).*\(</apikey>.*\)$,\1$pulseapikey\2," | sed "s,\(<versioning>.*</versioning>\),<device id=\"$testDeviceId\"></device>\1," >> $newconfig || fatal "Error modifying config: tail"
mv -f $newconfig $config || fatal "Error modifying config: mv"
echo "config created [ok]"
cp "$absScriptDir"/cert.pem $pulsehome || fatal "Failed to replace cert"
cp "$absScriptDir"/key.pem $pulsehome || fatal "Failed to replace key"
echo "Pulse config check...\c "
(
sleep 20
curl -s -H "X-API-Key:$pulseapikey" -X POST $pulseAddress/rest/shutdown > /dev/null
) &
$pulse -home="$pulsehome" -no-browser -gui-address="$pulseAddress" > $testRoot/pulsecheck.log || fatal "Pulse config check error; check log file $testRoot/pulsecheck.log"
echo "[ok]"
}
main() {
checkPreconditions
clonePulse
configurePulse
echo ""
echo "Bootstrap done. Pulse available at: $pulse"
echo ""
}
main $*
-----BEGIN CERTIFICATE-----
MIID5TCCAk+gAwIBAgIIFtpk9F3lnTwwCwYJKoZIhvcNAQELMBQxEjAQBgNVBAMT
CXN5bmN0aGluZzAeFw0xNTAxMjExNjUwNDhaFw00OTEyMzEyMzU5NTlaMBQxEjAQ
BgNVBAMTCXN5bmN0aGluZzCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGB
AMU7pN0Yrl+NoAfLgxIfe6V8JCFihaQr1721WiCwIW0oV8mbO2cbsJKweNsiw3uZ
62AkSSfvATbnyklAQ6LGHUDWvlzN7HJQrfLB35WXw5uiC49eDpZB+vuLdieNvihc
s+MhgqqeiHQdf4NaPbLN1Vsp8ZXmGt7dSke2jiC3hc3XIpdDOehG3PKR5N9HhT11
LvI+twiXj5lEEYSRHKZ4BtHvk4n6sFlT9H+1koXQ0pDmNRBngBUI5ridziG/970O
o1Rq8e2/1C+GAOv/oDlYDzu8fNb9wObRG+VvHyzlOdolrU8asUj/CDXi1RISJ0TR
L34ulf9yBlnRnqIP46HpX4Rr9/sLFF235rC25IP25dKPE6Dc2zSk48ExBHWpSxIV
Wa8bYll83tJ6Z4gC2LmkbVRJWbX1ll2PibaLB3QJp1uCzlWPwclcQ19qcalv+6if
4wZ7RpEoqy59hxwXcBex8sKpVqZ9hqVnGzMCqtHrfA3LtfpVIzNTXXvbfWjuON5F
VwIDAQABoz8wPTAOBgNVHQ8BAf8EBAMCAKAwHQYDVR0lBBYwFAYIKwYBBQUHAwEG
CCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwCwYJKoZIhvcNAQELA4IBgQBunQOV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byYIvnezkXDse7J+dFAm
0iQifP5OapqVPNRF6nJT62t1L4SGMlRkcx2yNMKNqvLr38xlUZiUg/slA+N9n825
eKqepqFNbi3icqBiv7ojZcfLF9Nrx6rdlilb1qqgixnmx2m5CqanQyBaTLEoQS9O
6AcbBWR2JXRe7yO+X8+NX4ZIGIOSQiXMMZid5Q+HMEkeds6BPbqoSMajBataYlWX
o3aT0QPO5ZNjNFQn2fiTIljTFCDJVa7OCJv5aJF241X3AoHAVEKwp2AEWXWaG+NB
QfSKs9UXwRoLOgA8+dh5w6SKl3XGndt2s27jMsHZ6BfoANyeYFyF+GbubZvPY9iO
eNayuR1h+m/0Ug1oQoH0zh+5pb5NJWEjHmDu+ritaZRt7Tht83XflFYoczkinSg0
EJQN0ExifRQ0vRFIwDL1q1mgv16zmR1N+MgfrcBH/DZ+V8HMYgbHZqD63hRYWQPK
KkxYo2/stA0/Hj15dvdnAzGNjx7IGYZvapkvOWoO3kj/I/MBAoHBAKxjlLc2JGWi
4bjF18LCCLdEuxHQqPTOonRX496szw1xMeqEfUVoFFTSlt7xYqoI2wGM8U2soVaV
n6YgPzUuf2+/pgq6ux1z8LhWM+YmQ8RTgIZYZJr9ZhRhEBxHr2/lutybjta/yEBD
Aj9o72n31yFs2yg4/ky4fYmTgF4iU5xsOSqjcnoDEKhIeba/8n4joWusi1dvUscA
L1FqKSxLHMLdRHZiBsximAdTloolnOLR8RhBYSj44Aq3HZlEX2ERTQ==
-----END RSA PRIVATE KEY-----
#!/bin/sh
if ( test -z "$BUILD_ROOT" || test -f /tmp/pulse-swift/started-by-build-script ); then
curl -s -H "X-API-Key:jobt7d8klok5l8n818q1noq2t683nu" -X POST http://127.0.0.1:59296/rest/shutdown
sleep 3
rm -f /tmp/pulse-swift/started-by-build-script
fi
#!/bin/sh
# Setup pulse if not already done
if ( ! test -d /tmp/pulse-swift ); then
(
d="`dirname $0`"
cd "$d"
"./bootstrap.sh"
)
fi
if ( test -z "$HOME" ); then
echo "No HOME; setting HOME to /tmp/pulse-swift/pulsehome"
export HOME=/tmp/pulse-swift/pulsehome
fi
# Start pulse if it is not already running
if ( ! curl -s -H "X-API-Key:jobt7d8klok5l8n818q1noq2t683nu" -X POST http://127.0.0.1:59296/rest/ping > /dev/null ); then
/tmp/pulse-swift/src/source.ind.ie/project/pulse/bin/pulse -home=/tmp/pulse-swift/pulsehome -no-browser -gui-address="http://127.0.0.1:59296" $* &
if ( test -n "$BUILD_ROOT" ); then
touch /tmp/pulse-swift/started-by-build-script
fi
sleep 10
fi
name 'pulse-cookbook'
version '0.1.1'
depends 'apt', '~> 2.7.0'
depends 'git', '~> 4.1.0'
depends 'curl', '~> 2.0.1'
#depends 'golang', '~> 1.5.0'
#package "golang"
package "curl"
package "git"
log "Pulse Cookbook for Integration Testing"
cookbook_file "bootstrap.sh" do
path "/tmp/bootstrap.sh"
mode "700"
action :create
end
cookbook_file "cert.pem" do
path "/tmp/cert.pem"
mode "600"
action :create
end
cookbook_file "key.pem" do
path "/tmp/key.pem"
mode "600"
action :create
end
cookbook_file "pre-test.sh" do
path "/tmp/pre-test.sh"
mode "700"
action :create
end
cookbook_file "post-test.sh" do
path "/tmp/post-test.sh"
mode "700"
action :create
end
bash "stop pulse" do
cwd '/tmp'
code <<-EOH
./post-test.sh
EOH
end
pulselog = "/tmp/pulse.log"
file pulselog do
action :delete
end
bash "start pulse" do
cwd '/tmp'
code <<-EOH
./pre-test.sh &> #{pulselog}
EOH
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment