Skip to content
Snippets Groups Projects
Commit bb1808bc authored by ale's avatar ale
Browse files

Remove obsolete Vagrant test harness

parent acc06257
Branches
No related tags found
No related merge requests found
......@@ -247,23 +247,7 @@ started in the whole cluster.
# Testing
There's a [Vagrant](http://www.vagrantup.com/) environment in the
`vagrant-test` subdirectory that will set up a test three-node cluster
(with Debian Jessie as the base system) using pre-packaged binaries.
To run it:
The [streampunk/ansible](https://git.autistici.org/streampunk/ansible)
project offers a Vagrant test environment that can be used to easily
test changes to the software.
$ cd vagrant-test
$ vagrant up
It will take a while to download the base image the first time, then
it will turn up three nodes called **node1**, **node2** and **node3**.
Use `vagrant ssh` to inspect them.
If you want to test a locally-built package, copy the `autoradio` and
`etcd` Debian packages in the `vagrant-test` directory and, in that
same directory, run
$ dpkg-scanpackages -m . >Packages
the provisioning process will automatically use the local packages if
they are available.
.vagrant
*.deb
song*.ogg
# Vagrantfile for a test 3-node autoradio cluster.
#
# By default it will pull autoradio packages from the public
# repository. If you want to use locally-built packages, copy the
# 'etcd' and 'autoradio-server' packages to this directory and run
# 'dpkg-scanpackages -m . >Packages'.
#
# If you have an APT proxy available, you can set the APT_PROXY
# environment variable to its host:port address, and the VMs will use
# it to retrieve Debian packages. This will make the setup step
# faster.
API_VERSION = "2"
# Note: we shouldn't need to create a host entry for 'etcd' but it is
# faster to set up the cluster this way.
$setup_host_file = <<SCRIPT
cat >/etc/hosts <<EOF
127.0.0.1 localhost
192.168.50.2 node1.autora.dio etcd.autora.dio node1
192.168.50.3 node2.autora.dio node2
192.168.50.4 node3.autora.dio node3
EOF
SCRIPT
# Setup apt proxy.
$setup_apt_proxy = <<SCRIPT
cat >/etc/apt/apt.conf.d/000apt-proxy <<EOF
Acquire::http::Proxy "http://#{ENV['APT_PROXY']}/";
Acquire::http::Pipeline-Depth "23";
EOF
SCRIPT
Vagrant.configure(API_VERSION) do |config|
config.vm.box = "jessie"
config.vm.box_url = "http://www.incal.net/ale/debian-jessie-64.box"
config.vm.provision "shell", inline: $setup_host_file
if !ENV['APT_PROXY'].nil?
config.vm.provision "shell", inline: $setup_apt_proxy
end
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
s.args = "autora.dio"
end
config.vm.define "node1" do |m|
m.vm.hostname = "node1"
m.vm.network "private_network", ip: "192.168.50.2"
end
config.vm.define "node2" do |m|
m.vm.hostname = "node2"
m.vm.network "private_network", ip: "192.168.50.3"
end
config.vm.define "node3" do |m|
m.vm.hostname = "node3"
m.vm.network "private_network", ip: "192.168.50.4"
# Create a test mountpoint.
m.vm.provision "shell",
inline: "sleep 3 && radioctl create-mount /stream.ogg"
# Start streaming, add a transcoded stream.
m.vm.provision "shell", path: "start-source"
m.vm.provision "shell",
inline: "sleep 1 && radioctl create-transcoding-mount --bitrate=64 --codec=mp3 --source=/stream.ogg /stream.mp3"
end
end
#!/bin/bash
set -e
# If there is a /vagrant/Packages file, pull packages from there
# (assuming they have been built locally). Otherwise, use the default
# public repository.
default_repo="deb http://www.incal.net/ale/debian autoradio/"
local_repo="deb file:///vagrant ./"
if [ -e /vagrant/Packages ]; then
echo "Using local package repository from /vagrant" >&2
repo="${local_repo}"
else
echo "Using default package repository" >&2
repo="${default_repo}"
fi
# Install our Debian apt repository.
echo "${repo}" > /etc/apt/sources.list.d/autoradio.list
# Install the configuration.
DOMAIN="${DOMAIN:-$1}"
if [ -z "${DOMAIN}" ]; then
echo "Must set \$DOMAIN" >&2
exit 1
fi
cat >/etc/default/autoradio <<EOF
DOMAIN="--domain=${DOMAIN}"
EOF
cat >/etc/default/icecast2 <<EOF
CONFIGFILE="/etc/icecast2/icecast.xml"
USERID=icecast2
GROUPID=icecast
ENABLE=true
EOF
cat >/etc/default/etcd <<EOF
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://$(hostname -s):2380
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS=http://$(hostname -s):2379
ETCD_INITIAL_CLUSTER_STATE=new
#ETCD_INITIAL_CLUSTER=node1=http://192.168.50.2:2380,node2=http://192.168.50.3:2380,node3=http://192.168.50.4:2380
ETCD_INITIAL_CLUSTER=node1=http://node1:2380,node2=http://node2:2380,node3=http://node3:2380
EOF
# Install the required packages.
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
yes n | apt-get install -y --force-yes -q etcd autoradio-server
echo "All done (?)" 1>&2
exit 0
<?xml version="1.0"?>
<ices>
<!-- run in background -->
<background>0</background>
<!-- where logs, etc go. -->
<logpath>/tmp</logpath>
<logfile>ices.log</logfile>
<!-- 1=error,2=warn,3=info,4=debug -->
<loglevel>4</loglevel>
<!-- set this to 1 to log to the console instead of to the file above -->
<consolelog>1</consolelog>
<!-- optional filename to write process id to -->
<!-- <pidfile>/home/ices/ices.pid</pidfile> -->
<stream>
<!-- metadata used for stream listing (not currently used) -->
<metadata>
<name>Jesus</name>
<genre>Example genre</genre>
<description>A short description of your stream</description>
</metadata>
<!-- input module
The module used here is the playlist module - it has
'submodules' for different types of playlist. There are
two currently implemented, 'basic', which is a simple
file-based playlist, and 'script' which invokes a command
to returns a filename to start playing. -->
<input>
<module>playlist</module>
<param name="type">basic</param>
<param name="file">ices-playlist.txt</param>
<!-- random play -->
<param name="random">0</param>
<!-- if the playlist get updated that start at the beginning -->
<param name="restart-after-reread">1</param>
<!-- if set to 1 , plays once through, then exits. -->
<param name="once">0</param>
</input>
<!-- Stream instance
You may have one or more instances here. This allows you to
send the same input data to one or more servers (or to different
mountpoints on the same server). Each of them can have different
parameters. This is primarily useful for a) relaying to multiple
independent servers, and b) encoding/reencoding to multiple
bitrates.
If one instance fails (for example, the associated server goes
down, etc), the others will continue to function correctly.
This example defines two instances as two mountpoints on the
same server. -->
<instance>
<!-- Server details:
You define hostname and port for the server here, along with
the source password and mountpoint. -->
<hostname>192.168.50.3</hostname>
<port>80</port>
<username>@USERNAME@</username>
<password>@PASSWORD@</password>
<mount>/stream.ogg</mount>
<!-- Reconnect parameters:
When something goes wrong (e.g. the server crashes, or the
network drops) and ices disconnects from the server, these
control how often it tries to reconnect, and how many times
it tries to reconnect. Delay is in seconds.
If you set reconnectattempts to -1, it will continue
indefinately. Suggest setting reconnectdelay to a large value
if you do this.
-->
<reconnectdelay>1</reconnectdelay>
<reconnectattempts>100000</reconnectattempts>
<!-- maxqueuelength:
This describes how long the internal data queues may be. This
basically lets you control how much data gets buffered before
ices decides it can't send to the server fast enough, and
either shuts down or flushes the queue (dropping the data)
and continues.
For advanced users only.
-->
<maxqueuelength>80</maxqueuelength>
<!-- Live encoding/reencoding:
Currrently, the parameters given here for encoding MUST
match the input data for channels and sample rate. That
restriction will be relaxed in the future.
-->
<encode>
<nominal-bitrate>64000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
<samplerate>44100</samplerate>
<channels>2</channels>
</encode>
</instance>
</stream>
</ices>
#!/bin/sh
#
# Test that the running autoradio cluster on Vagrant is performing
# as expected.
#
expected_dns="192.168.50.2 192.168.50.3 192.168.50.4"
dns=$(dig +short stream.autora.dio @192.168.50.3 | sort | tr '\n' ' ' | sed -e 's/ $//')
if [ "$dns" != "$expected_dns" ]; then
echo "DNS query for stream.autora.dio did not return expected results: ${expected_dns}" >&2
exit 1
fi
echo "Vagrant autoradio cluster looks ok." >&2
exit 0
#!/bin/sh
#
# Stream data to the test mountpoint, using 'ices2'.
#
stream=${1:-/stream.ogg}
# Download a couple of test songs.
for song in song1.ogg song2.ogg ; do
test -e /vagrant/${song} || wget -O /vagrant/${song} http://www.incal.net/ale/test-songs/${song}
done
# Install Ices2.
sudo apt-get -q -y install ices2
# Create the Ices2 config file.
username=$(radioctl show-mount ${stream} | awk -F= '/^username/ {print $2}')
password=$(radioctl show-mount ${stream} | awk -F= '/^password/ {print $2}')
if [ -z "${username}" ]; then
echo "ERROR: stream ${stream} not found"
exit 1
fi
sed -e s/@USERNAME@/${username}/ -e s/@PASSWORD@/${password}/ \
< /vagrant/ices.xml.tmpl > /tmp/ices.xml
cat > /tmp/ices-playlist.txt <<EOF
/vagrant/song1.ogg
/vagrant/song2.ogg
EOF
cd /tmp
ices2 /tmp/ices.xml >/tmp/ices.log 2>&1 &
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment