Skip to content

Commit

Permalink
Tests for the Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Dec 30, 2020
1 parent cab0399 commit f254af9
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 35 deletions.
90 changes: 90 additions & 0 deletions .github/test_playground.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

set -e

error=0

function pr_bold() {
echo -e "\033[1m$@\033[0m"
}

function run_on() {
set +e
docker-compose exec -T $1 bash -c "$2"

if [ $? -eq 0 ]; then
res="OK"
else
res="Failed"
error=1
fi

set -e

pr_bold "$1: $2 $res"
}

docker-compose version

cd tools/playground

if [ "$CI" == "true" ]; then
export INSTALL_FROM_SRC=1
fi

docker-compose build

docker-compose up -d

# Let run.sh configure ARouteServer...
echo -n "Waiting a bit till run.sh configures everything... "
sleep 60
echo "OK, let's move now!"

run_on rs 'birdc show protocols | grep BGP | grep Established | wc -l | grep 2'

run_on alice_lg 'curl -L http://10.0.0.2:29184/protocols/bgp'

run_on client_2 'birdc show route count | grep "2 of 2 routes for 2 networks"'
run_on client_2 'birdc show route | grep 193.0.0.0/21 | grep "via 10.0.0.11"'

# Valid routes on the RS.
run_on rs 'birdc show route count | grep "3 of 3 routes for 3 networks"'

for prefix in \
192.136.136.0/24 \
193.0.0.0/21 \
193.0.22.0/23
do
run_on rs "birdc show route $prefix | grep $prefix"
done

# Filtered routes on the RS.
run_on rs 'birdc show route filtered count | grep "4 of 4 routes for 4 networks"'

for prefix in \
10.0.0.0/24 \
192.168.0.0/24 \
193.0.0.1/32 \
202.12.29.0/24
do
run_on rs "birdc show route filtered $prefix | grep $prefix"
done

run_on rs "birdc show route filtered 10.0.0.0/24 all | grep '(64500, 65520, 3)'"
run_on rs "birdc show route filtered 202.12.29.0/24 all | grep '(64500, 65520, 9)'"

pr_bold "Testing localhost, Alice at port 8080..."
curl -L http://127.0.0.1:8080 | grep 'Alice - The friendly BGP looking glass'
pr_bold "Testing localhost, Alice at port 8080... OK"

echo ""
echo ""

if [ $error -eq 0 ]; then
pr_bold "Tests completed successfully!"
exit 0
else:
pr_bold "Tests failed :-("
exit 1
fi
18 changes: 18 additions & 0 deletions .github/workflows/test_playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Playground tests

on: push

jobs:
test-playground:
name: Playground tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run Playground tests
run: .github/test_playground.sh
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 8 additions & 5 deletions tools/playground/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ARouteServer playground

[![Playground tests status](https://github.com/pierky/arouteserver/workflows/Playground%20tests/badge.svg)](https://github.com/pierky/arouteserver/actions?query=workflow%3A%22Playground+tests%22)

This is a Docker-based playground that can be use to experiment with ARouteServer.

It offers and environment with several actors, configured to represents specific scenarios that can often be found on a real IX platform: a route server, some clients that announce some good and some bad routes, a looking glass.
Expand All @@ -18,11 +20,12 @@ $ git clone https://github.com/pierky/arouteserver.git
$ cd arouteserver/tools/playground
$ docker-compose build
[... omitted...]
$ docker-compose up
$ docker-compose up -d
Creating network "playground_peering_fabric" with the default driver
Creating arouteserver_playground_client_2 ... done
Creating arouteserver_playground_client_1 ... done
Creating arouteserver_playground_rs ... done
Creating arouteserver_playground_client_1 ... done
Creating arouteserver_playground_alicelg ... done
Creating arouteserver_playground_client_2 ... done
```

This will spin up the a BIRD-based route server and some clients, and once the route server will be configured and ready to work, also an instance of [Alice-LG](https://github.com/alice-lg/alice-lg) will be executed and connected to the route server.
Expand All @@ -36,7 +39,7 @@ Users willing to simulate more "weird" situations are strongly encouraged to use
Expectations can be checked by "logging in" into the route server or client instances and querying the local BGP daemon:

```
docker-compose exec client_2 bash
$ docker-compose exec client_2 bash
root@ee27954906b9:~# birdc show route
BIRD 1.6.3 ready.
192.136.136.0/24 unreachable [own_prefixes 16:24:32] * (200)
Expand All @@ -46,7 +49,7 @@ BIRD 1.6.3 ready.
Also, the Alice-LG WEB interface can be used to check the routes received by the route server, and their status: http://127.0.0.1:8080/routeservers/rs1-example-com/protocols/AS3333_1/routes?ne=0&q=202.12.29.0

**Please note:** the route server that is spun up will be automatically configured by the provisioning script *rs/run.sh*.
If the user desires to manually setup and configure ARouteServer and build a BIRD configuration from scratch (which is strongly recommended for the actual end goal of this playground), the *docker-compose.yml* file can be edited and the environment variable `SETUP_AND_CONFIGURE_AROUTESERVER` set to 0. The playground can then be recreated using `docker-compose down` / `docker-compose up`: at this point, the *rs* instance will only have a running *vanilla* BIRD instance and all the required dependencies setup. The users will be able to connect to it (`docker-compose exec rs bash`) and work on it. [SETUP_GUIDELINES.md](SETUP_GUIDELINES.md) contains some hints on how to configure it.
If the user desires to manually setup and configure ARouteServer and build a BIRD configuration from scratch (which is strongly recommended for the actual end goal of this playground), the *docker-compose.yml* file can be edited and the environment variable `SETUP_AND_CONFIGURE_AROUTESERVER` set to 0. The playground can then be recreated using `docker-compose down` / `docker-compose up -d`: at this point, the *rs* instance will only have a running *vanilla* BIRD instance and all the required dependencies setup. The users will be able to connect to it (`docker-compose exec rs bash`) and work on it. [SETUP_GUIDELINES.md](SETUP_GUIDELINES.md) contains some hints on how to configure it.

## Actors

Expand Down
22 changes: 11 additions & 11 deletions tools/playground/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
services:
rs:
build: ./rs
build:
context: ./rs
args:
# Only used by the GitHub Actions workflow.
INSTALL_FROM_GITHUB_SHA: ${GITHUB_SHA:-}

container_name: arouteserver_playground_rs

networks:
peering_fabric:
ipv4_address: 10.0.0.2
healthcheck:
test: ["CMD", "curl", "-L", "http://10.0.0.2:29184/protocols/bgp"]
interval: 10s
timeout: 5s
retries: 99999
start_period: 5s

# Set the following variable to 0 to prevent
# the run.sh script to automatically configure
# ARouteServer. More details can be found in
# the rs/run.sh file.
#
environment:
SETUP_AND_CONFIGURE_AROUTESERVER: 1

Expand All @@ -40,14 +40,14 @@ services:
alice_lg:
image: pierky/alice-lg
container_name: arouteserver_playground_alicelg
depends_on:
rs:
condition: service_healthy

networks:
peering_fabric:
ipv4_address: 10.0.0.3

volumes:
- ./alice-lg/alice.conf:/etc/alice-lg/alice.conf

ports:
- 8080:80

Expand Down
42 changes: 27 additions & 15 deletions tools/playground/rs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ RUN apt-get update && \
python3-dev && \
rm -rf /var/lib/apt/lists/*

# Installing AliceLG birdwatcher
# ------------------------------

RUN curl \
-OL https://golang.org/dl/go1.15.6.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz

ENV PATH=$PATH:/usr/local/go/bin

RUN go get github.com/alice-lg/birdwatcher

RUN mkdir -p /etc/birdwatcher

COPY birdwatcher.conf /etc/birdwatcher/birdwatcher.conf

# ARouteServer dependencies: bgpq3
# --------------------------------

Expand All @@ -25,23 +40,20 @@ RUN mkdir /bgpq3 && \
# Installing ARouteServer
# -----------------------

RUN pip3 install --upgrade pip setuptools wheel
RUN pip3 install arouteserver

# Installing AliceLG birdwatcher
# ------------------------------

RUN curl \
-OL https://golang.org/dl/go1.15.6.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz
ARG INSTALL_FROM_GITHUB_SHA

ENV PATH=$PATH:/usr/local/go/bin

RUN go get github.com/alice-lg/birdwatcher

RUN mkdir -p /etc/birdwatcher
RUN pip3 install --upgrade pip setuptools wheel

COPY birdwatcher.conf /etc/birdwatcher/birdwatcher.conf
# INSTALL_FROM_GITHUB_SHA is used by the
# test suite to perform the installation of
# ARouteServer from source. If can be ignored
# for the regular use of this playground.
RUN if [ -z "$INSTALL_FROM_GITHUB_SHA" ]; \
then \
pip3 install arouteserver; \
else \
pip3 install git+https://github.com/pierky/arouteserver.git@$INSTALL_FROM_GITHUB_SHA; \
fi;

# Environment setup
# -----------------
Expand Down
12 changes: 8 additions & 4 deletions tools/playground/rs/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# configured and executes Alice-LG birdwatcher.
nohup /root/run_birdwatcher_when_ready.sh &

# Run BIRD - the route server daemon.
bird -c /etc/bird/bird.conf

# ARouteServer setup and configuration
# ------------------------------------

Expand Down Expand Up @@ -65,9 +68,10 @@ if [ ${SETUP_AND_CONFIGURE_AROUTESERVER} -eq 1 ]; then
arouteserver \
bird --ip-ver 4 -o /etc/bird/bird.conf

echo "ARouteServer setup and configure complete."
fi
echo "Reloading BIRD config... "
birdc "configure"

# Run BIRD - the route server daemon.
bird -c /etc/bird/bird.conf -f
echo "ARouteServer setup and configure completed."
fi

sleep 365d

0 comments on commit f254af9

Please sign in to comment.