Commit f0628422 authored by Stefan van den Oord's avatar Stefan van den Oord

Removed pulse-swiftSystemTests; they are no longer needed as we can completely...

Removed pulse-swiftSystemTests; they are no longer needed as we can completely unit-test Greeter now
parent eaff8d86
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES"
buildForTesting = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E8855C1ACF1E1B0071B9B6"
BuildableName = "PulseSystemTests.xctest"
BlueprintName = "PulseSystemTests"
ReferencedContainer = "container:pulse-swift.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E8855C1ACF1E1B0071B9B6"
BuildableName = "PulseSystemTests.xctest"
BlueprintName = "PulseSystemTests"
ReferencedContainer = "container:pulse-swift.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
import Foundation
import Pulse
import Quick
import Nimble
class GreeterDelegateSpy : GreeterDelegate {
var greetingReceived = false
func greeter(greeter:Greeter, didReceiveAnnouncement:Announcement) {
greetingReceived = true
}
}
class DiscoveryTests : QuickSpec {
override func spec() {
it ("should receive announcement") {
var greeter = Greeter()
var greeterDelegateSpy = GreeterDelegateSpy()
greeter.delegate = greeterDelegateSpy
let exampleIdentity = SecIdentity.example
greeter.deviceId = exampleIdentity.deviceId
var error:NSError?
expect(greeter.start()).to(beTrue())
if let e = error {
fail(e.description)
}
else {
expect(greeterDelegateSpy.greetingReceived).toEventually(beTrue(), timeout:30)
}
self.wait(30) // make sure that there's enough time for Greeter to send a second announcement
}
}
func wait(timeInterval:NSTimeInterval) {
let now:NSDate = NSDate()
let until:NSDate = now.dateByAddingTimeInterval(timeInterval)
NSRunLoop.currentRunLoop().runUntilDate(until)
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>ie.ind.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
About This Folder
=================
This folder contains files needed for system testing. The difference between the integration tests and these system tests, is that the integration tests run on the development machine itself, whereas the system tests run inside a virtual machine. Because the virtual machine has its own network interfaces, this allows it to use the same ports as the development machine is using. The discovery tests require this for example, because discovery listens on the same ports as it sends.
The system tests are run by executing `run-tests.sh` inside this folder.
Please note that these tests take quite some time to run!
How does it work
----------------
The system tests are built on top of [Kitchen](http://kitchen.ci). The setup phase of the tests involves creating the Kitchen virtual machine and converging it. The second phase runs the tests, which consists of two steps: (a) executing the test action of the Xcode scheme `PulseSystemTests`, and (b) running `kitchen verify`. Finally, the teardown phase destroys the Kitchen virtual machine again.
The setup phase is performed by `pre-tests.sh`. The teardown phase is performed by `post-tests.sh`. When you run the tests using `run-tests.sh` it will automatically call `pre-tests.sh` and `post-tests.sh`.
If you don't want to wait for the virtual machine to be setup all the time while you are developing system tests, you can call `run-tests.sh -r` (or `--run-only`). When you do that, `pre-tests.sh` and `post-tests.sh` will not be run. **Please note** that the tests will no longer be independent! This is because pulse is running in the virtual machine and writing output to `/tmp/pulse.log`. So the output of previous test runs will still be in that log file. The way to work around that is by logging into the virtual machine and resetting the system there:
kitchen login default-ubuntu-1204
Inside the virtual machine:
sudo -s
cd /tmp
./post-test.sh
rm pulse.log
./pre-test.sh >& /tmp/pulse.log
exit
exit
Prerequisites
-------------
These system tests require you to install the following software on your Mac:
* [Virtual Box](https://www.virtualbox.org): download the installer and run it.
* [Vagrant](https://www.vagrantup.com): download the installer and run it.
* [Kitchen](http://kitchen.ci): run `gem install test-kitchen`.
Index of Files
--------------
* `DiscoveryTests.swift` : Source code file that contains the Xcode part of the tests.
* `Info.plist` : Required for Xcode test target.
* `pre-test.sh` : Sets up the test environment: creates and converges the Kitchen virtual machine.
* `run-test.sh` : Runs the system tests (pass `-r` or `--run-only` to skip setup and teardown).
* `post-test.sh` : Tears down the test environment: destroys the Kitchen virtual machine.
* `pulse-cookbook` : The Chef cookbook executed by Kitchen to run the Kitchen side of the tests.
#!/bin/sh
fatal() {
echo "[fatal] $1" 1>&2
exit 1
}
checkPreconditions() {
test -d /Applications/VirtualBox.app || fatal "Please install Virtual Box from https://www.virtualbox.org/wiki/Downloads"
which vagrant > /dev/null || fatal "Please install Vagrant (including command line support) from https://www.vagrantup.com/downloads.html"
which kitchen > /dev/null || fatal "Please install KitchenCI using 'gem install test-kitchen'"
}
main() {
cd pulse-cookbook
kitchen destroy default-ubuntu-1204 || fatal "Failed to destroy vm"
}
checkPreconditions || fatal "Please fix the above errors and try again."
main $*
#!/bin/sh
fatal() {
echo "[fatal] $1" 1>&2
exit 1
}
checkPreconditions() {
test -d /Applications/VirtualBox.app || fatal "Please install Virtual Box from https://www.virtualbox.org/wiki/Downloads"
test -d /Applications/VirtualBox.app/Contents/MacOS/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack || fatal "Please install the Virtual Box Extension Pack from https://www.virtualbox.org/wiki/Downloads"
which vagrant > /dev/null || fatal "Please install Vagrant (including command line support) from https://www.vagrantup.com/downloads.html"
which kitchen > /dev/null || fatal "Please install KitchenCI using 'gem install test-kitchen'"
}
main() {
cd pulse-cookbook
kitchen list default-ubuntu-1204 |tail -n +2 |grep -v "Not Created" || kitchen create default-ubuntu-1204 || fatal "Failed to create vm"
kitchen list default-ubuntu-1204 |tail -n +2 |grep -v "Created" || kitchen converge default-ubuntu-1204 || fatal "Failed to converge vm"
}
checkPreconditions || fatal "Please fix the above errors and try again."
main $*
---
driver:
name: vagrant
network:
- ["public_network", {bridge: 'en0: Wi-Fi (AirPort)', ipv6: true, auto_config: false}] # auto_config:true should also work again (using VirtualBox 5.0.2)
provisioner:
name: chef_solo
platforms:
- name: ubuntu-14.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 syncthing 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-st"
syncthingDir="$testRoot/src/github.com/syncthing"
syncthingAddress="http://127.0.0.1:59296"
syncthingapikey="jobt7d8klok5l8n818q1noq2t683nu"
testDeviceId="3XGRA4E-SSXHXPF-UA6V3L2-6IOJHHZ-5AOGWGJ-VOHWDPM-TTYWREL-Z56XNA7"
syncthingDeviceId="7KFYRQE-T3RQFPT-JD372NX-P6MSISE-J3KYWXR-QJQZSM2-TGZFXT7-MZSULQR"
################################################################################
### 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`"
absSyncthingDir="`absPath $syncthingDir`"
gopath=""
syncthing=""
syncthinghome=""
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 "$syncthingDir" ); then
echo "Syncthing folder $syncthingDir already exists [ok]"
else
echo "syncthing doesn't already exist [ok]"
fi
export GOROOT="$testRoot/go"
if ( ! test -x "$GOROOT/bin/go" ); then
echo "go executable not found; downloading go... \c"
installGo
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 $absSyncthingDir | sed \"s,/src/github.com/syncthing,,\"`"
if ( test "$gopath" = "" ); then
fatal "Could not determine correct go path for building syncthing"
else
echo "path for building syncthing [ok]"
fi
syncthinghome="$gopath/sthome"
syncthing="$absSyncthingDir/syncthing/bin/syncthing"
}
cloneSyncThing() {
logStep "Clone syncthing"
(
export GOPATH="$gopath"
mkdir -p "$syncthingDir" || fatal "Could not create syncthing folder"
cd "$syncthingDir" || fatal "Could not change to syncthing folder"
echo "Cloning syncthing... \c"
( git clone https://github.com/syncthing/syncthing > $testRoot/syncthing-clone.log 2>&1 ) || fatal "Could not clone syncthing; check log file $testRoot/syncthing-clone.log"
echo "[ok]"
(
cd syncthing || fatal "Could not change to cloned syncthing"
echo "Building syncthing...\c "
( $GO run build.go > $testRoot/syncthing-build.log 2>&1 ) || fatal "Could not build syncthing; check log file $testRoot/syncthing-build.log"
echo "[ok]"
)
)
}
configureSyncThing() {
logStep "Configure syncthing"
mkdir -p "$syncthinghome"
${syncthing} -generate="${syncthinghome}" > /dev/null
cp -f /tmp/cert.pem "${syncthinghome}"
cp -f /tmp/key.pem "${syncthinghome}"
deviceId="${syncthingDeviceId}"
(echo "$deviceId" | egrep "^([0-9A-Z]{7}-){7}[0-9A-Z]{7}$" > /dev/null) || fatal "Device id $deviceId does not have expected format"
config="$syncthinghome/config.xml"
newconfig="$config.new"
head -1 $config > $newconfig || fatal "Error modifying config: head"
echo " <folder id=\"pulse-integrationTests\" path=\"$syncthinghome/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$syncthingapikey\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]"
echo "Syncthing config check...\c "
(
sleep 20
curl -s -H "X-API-Key:$syncthingapikey" -X POST $syncthingAddress/rest/system/shutdown > /dev/null
) &
$syncthing -home="$syncthinghome" -no-browser -gui-apikey="$syncthingapikey" -gui-address="$syncthingAddress" > $testRoot/syncthingcheck.log || fatal "Syncthing config check error; check log file $testRoot/syncthingcheck.log"
echo "[ok]"
}
main() {
checkPreconditions
cloneSyncThing
configureSyncThing
echo ""
echo "Bootstrap done. Syncthing available at: $syncthing"
echo ""
}
main $*
-----BEGIN CERTIFICATE-----
MIID5TCCAk+gAwIBAgIIWeAarbD848cwCwYJKoZIhvcNAQELMBQxEjAQBgNVBAMT
CXN5bmN0aGluZzAeFw0x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76X2f5EftL4fTyz/7zXTzgT/FlLbMhhDd3gh53hXzxsIh
x2mjT6E+jMKqJ3YFUvCY/HJywGvy8snlRBhAS6PmUWkW+w2IRFWfIxW0qQD3htXN
Cg3wKfudjuTUKsvuRz/deO8XFZTWPC5PdS99iUHxGGrjMKsN8R62X1XxQ7HxVtv1
IDElWii92FoKQ2/a/3msx1OZ5a+YdKZfW3SdAXaTS8TxVYECgcB3guaLfrOOMal+
+xAiopsjh+6/VhmQrvr4/FPo6y14+MoF8iR8YHK8044zudoOYnDc8okfEEzDZRuN
KBubVI1Fog+Kz9u09pPhHueaXQ/yLPy6EdkNeFT9E12kpS3jilyTFc1s+pMxGitk
RFMpUbl4A8tRhlaU8aq92Tflm5qIzv+zWnt7Ce5x6UdW/BxoqVSq1IKXaXKp3q7W
hoje+FPQczGwgABWjcfL/XOBYxIhzQaM65+9t3HkKyKag9kc1YA=
-----END RSA PRIVATE KEY-----
#!/bin/sh
testRoot="/tmp/pulse-swift-st"
if ( test -z "$BUILD_ROOT" || test -f "$testRoot/started-by-build-script" ); then
curl -s -H "X-API-Key:jobt7d8klok5l8n818q1noq2t683nu" -X POST http://127.0.0.1:59296/rest/system/shutdown
sleep 3
rm -f "$testRoot/started-by-build-script"
fi
#!/bin/sh
testRoot="/tmp/pulse-swift-st"
# Setup syncthing if not already done
if ( ! test -d "$testRoot" ); then
(
d="`dirname $0`"
cd "$d"
"./bootstrap.sh"
)
fi
if ( test -z "$HOME" ); then
echo "No HOME; setting HOME to $testRoot/sthome"
export HOME="$testRoot/sthome"
fi
# Start syncthing if it is not already running
if ( ! curl -s -H "X-API-Key:jobt7d8klok5l8n818q1noq2t683nu" -X POST http://127.0.0.1:59296/rest/system/ping > /dev/null ); then
export STTRACE=discover
"$testRoot/src/github.com/syncthing/syncthing/bin/syncthing" -home="$testRoot/sthome" -no-browser -gui-apikey="jobt7d8klok5l8n818q1noq2t683nu" -gui-address="http://127.0.0.1:59296" $* &
if ( test -n "$BUILD_ROOT" ); then
touch "$testRoot/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 "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
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
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
./bootstrap.sh &> #{pulselog}
ifconfig eth1 0.0.0.0 0.0.0.0
dhclient eth1
./pre-test.sh &>> #{pulselog}
EOH
end
#!/usr/bin/env bats
@test "pulse log file is present" {
run test -f /tmp/pulse.log
[ "$status" -eq 0 ]
}
require 'serverspec'
# Required by serverspec
set :backend, :exec
describe command("cat /tmp/pulse.log") do
its(:stdout) { should match /discover.*register.*R7R33FF-MP337M2-HEN63VU-SWFM7LS-U2CLBLY-T6L56SJ-JHDXDT6-55ZVRAM/ }
end
describe command("grep \"discover.*register.*R7R33FF-MP337M2-HEN63VU-SWFM7LS-U2CLBLY-T6L56SJ-JHDXDT6-55ZVRAM\" /tmp/pulse.log | wc -l") do
its(:stdout) { should match /(2|3)/ }
end
#!/bin/sh
fatal() {
echo
echo "[fatal] $1" 1>&2
exit 1
}
absPath() {
case "$1" in
/*)
printf "%s\n" "$1"
;;
*)
printf "%s\n" "$PWD/$1"
;;
esac;
}
scriptDir="`dirname $0`"
scriptName="`basename $0`"
absScriptDir="`cd $scriptDir; pwd`"
runTest() {
pushd .
cd pulse-cookbook
kitchen list default-ubuntu-1204 |tail -n +2 |grep -E "(Converged|Verified)" || fatal "Kitchen is not converged; run pre-test.sh"
popd
pushd .
xcodebuild -workspace ../pulse-swift.xcworkspace -scheme PulseSystemTests test || fatal "Xcode system test failed"
cd pulse-cookbook
kitchen verify default-ubuntu-1204 || fatal "Kitchen verify failed"
popd
}
main() {
cd ${absScriptDir}
runOnly="no"
if test "$1" = "-r" -o "$1" = "--run-only"; then
runOnly="yes"
fi
if test "$runOnly" = "no"; then
./pre-test.sh
fi
runTest || fatal "exiting without cleaning up."
if test "$runOnly" = "no"; then
./post-test.sh
fi
}
main $*
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