<commit_before>#!/usr/bin/env bash
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

set -e

function node_run {
	NODE=$1
	shift

	vagrant ssh $NODE -- -t "$*"
}

function cleanup {
	node_run cilium-master 'docker rm -f server 2> /dev/null' || true
	node_run cilium-node-2 'docker rm -f client 2> /dev/null' || true
}

trap cleanup EXIT

function init {
    "${dir}/../contrib/vagrant/start.sh" 1

	cleanup

	node_run cilium-master 'docker network create --driver cilium --ipam-driver cilium cilium 2> /dev/null' || true
	node_run cilium-node-2 'docker network create --driver cilium --ipam-driver cilium cilium 2> /dev/null' || true
}

function test_run {
	SERVER=$(node_run cilium-master 'docker run -d --net cilium -l io.cilium.server --name server noironetworks/netperf')
	CLIENT=$(node_run cilium-node-2 'docker run -d --net cilium -l io.cilium.client --name client noironetworks/netperf')
	sleep 5s

	SERVER_IP=$(node_run cilium-master "docker inspect --format '{{ .NetworkSettings.Networks.cilium.GlobalIPv6Address }}' server" | tr -d '\r')
	echo "Server IPv6: $SERVER_IP"

	node_run cilium-node-2 "docker exec -i client ping6 -c 5 $SERVER_IP"
	node_run cilium-node-2 "docker exec -i client netperf -t TCP_STREAM -H $SERVER_IP"

	SERVER_IP4=$(node_run cilium-master "docker inspect --format '{{ .NetworkSettings.Networks.cilium.IPAddress }}' server" | tr -d '\r')
	echo "Server IPv4: $SERVER_IP4"
	node_run cilium-node-2 "docker exec -i client ping -c 5 $SERVER_IP4"
	node_run cilium-node-2 "docker exec -i client netperf -t TCP_STREAM -H $SERVER_IP4"

	cleanup
}

function test_nodes {
	OPTS=$*

	echo "Setting up nodes with options: $OPTS"

	node_run cilium-master "sudo cp /etc/init/cilium-net-daemon.conf tmp; sudo sed -i '/exec/d' tmp; echo \"exec cilium -D daemon run -n fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:210b:0:0 --ipv4-range 10.1.0.1 $OPTS\" | sudo tee -a tmp; sudo cp tmp /etc/init/cilium-net-daemon.conf; sudo service cilium-net-daemon restart"
	node_run cilium-node-2 "sudo cp /etc/init/cilium-net-daemon.conf tmp; sudo sed -i '/exec/d' tmp; echo \"exec cilium -D daemon run -n fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:210c:0:0 --ipv4-range 10.2.0.1 $OPTS -c 192.168.33.11:8500\" | sudo tee -a tmp; sudo cp tmp /etc/init/cilium-net-daemon.conf; sudo service cilium-net-daemon restart"

	echo "Waiting for daemon to start up..."
	sleep 5s

	node_run cilium-master 'cilium policy import ~/go/src/github.com/noironetworks/cilium-net/examples/policy/default/'
	node_run cilium-node-2 'cilium policy import ~/go/src/github.com/noironetworks/cilium-net/examples/policy/default/'

	test_run
}

init
test_nodes "-t vxlan --ipv4"
test_nodes "-d eth1"<commit_msg>tests: multi-node: Only run IPv4 test for overlay configuration for now<commit_after>#!/usr/bin/env bash
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

set -e

function node_run {
	NODE=$1
	shift

	vagrant ssh $NODE -- -t "$*"
}

function cleanup {
	node_run cilium-master 'docker rm -f server 2> /dev/null' || true
	node_run cilium-node-2 'docker rm -f client 2> /dev/null' || true
}

trap cleanup EXIT

function init {
    "${dir}/../contrib/vagrant/start.sh" 1

	cleanup

	node_run cilium-master 'docker network create --driver cilium --ipam-driver cilium cilium 2> /dev/null' || true
	node_run cilium-node-2 'docker network create --driver cilium --ipam-driver cilium cilium 2> /dev/null' || true
}

function test_run {
	SERVER=$(node_run cilium-master 'docker run -d --net cilium -l io.cilium.server --name server noironetworks/netperf')
	CLIENT=$(node_run cilium-node-2 'docker run -d --net cilium -l io.cilium.client --name client noironetworks/netperf')
	sleep 5s

	SERVER_IP=$(node_run cilium-master "docker inspect --format '{{ .NetworkSettings.Networks.cilium.GlobalIPv6Address }}' server" | tr -d '\r')
	echo "Server IPv6: $SERVER_IP"

	node_run cilium-node-2 "docker exec -i client ping6 -c 5 $SERVER_IP"
	node_run cilium-node-2 "docker exec -i client netperf -t TCP_STREAM -H $SERVER_IP"

	if [ ! -z "$IPV4" ]; then
		SERVER_IP4=$(node_run cilium-master "docker inspect --format '{{ .NetworkSettings.Networks.cilium.IPAddress }}' server" | tr -d '\r')
		echo "Server IPv4: $SERVER_IP4"
		node_run cilium-node-2 "docker exec -i client ping -c 5 $SERVER_IP4"
		node_run cilium-node-2 "docker exec -i client netperf -t TCP_STREAM -H $SERVER_IP4"
	fi

	cleanup
}

function test_nodes {
	OPTS=$*

	echo "Setting up nodes with options: $OPTS"

	node_run cilium-master "sudo cp /etc/init/cilium-net-daemon.conf tmp; sudo sed -i '/exec/d' tmp; echo \"exec cilium -D daemon run -n fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:210b:0:0 --ipv4-range 10.1.0.1 $OPTS\" | sudo tee -a tmp; sudo cp tmp /etc/init/cilium-net-daemon.conf; sudo service cilium-net-daemon restart"
	node_run cilium-node-2 "sudo cp /etc/init/cilium-net-daemon.conf tmp; sudo sed -i '/exec/d' tmp; echo \"exec cilium -D daemon run -n fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:210c:0:0 --ipv4-range 10.2.0.1 $OPTS -c 192.168.33.11:8500\" | sudo tee -a tmp; sudo cp tmp /etc/init/cilium-net-daemon.conf; sudo service cilium-net-daemon restart"

	echo "Waiting for daemon to start up..."
	sleep 5s

	node_run cilium-master 'cilium policy import ~/go/src/github.com/noironetworks/cilium-net/examples/policy/default/'
	node_run cilium-node-2 'cilium policy import ~/go/src/github.com/noironetworks/cilium-net/examples/policy/default/'

	test_run
}

init
IPV4=1 test_nodes "-t vxlan --ipv4"
test_nodes "-d eth1"
{'fraction_non_alphanumeric': 0.14243866715488832, 'fraction_numerical': 0.038813621384108384, 'mean_word_length': 3.8259717314487633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4712241', 'n_tokens_mistral': 2308, 'n_tokens_neox': 2135, 'n_words': 575}