<commit_before>#!/usr/bin/env bash

set -e

export INTEGRATION_ROOT=./integration-tmp
export TMPC_ROOT=./integration-tmp/tmpc

declare -A cmap

trap "cleanup_containers" EXIT SIGINT

function cleanup_containers() {
    for c in "${!cmap[@]}";
    do
	docker stop $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
	if [ -z "$CIRCLECI" ]; then
	    docker rm -f $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
	fi
    done

    unset cmap
}

function run_bridge_tests() {
    ## Setup
    start_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-bridge]=dnet-1-bridge

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/bridge.bats

    ## Teardown
    stop_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-bridge]
}

function run_overlay_local_tests() {
    ## Test overlay network in local scope
    ## Setup
    start_dnet 1 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-local]=dnet-1-local
    start_dnet 2 local:$(dnet_container_ip 1 local) 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-local]=dnet-2-local
    start_dnet 3 local:$(dnet_container_ip 1 local) 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-local]=dnet-3-local

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-local.bats

    ## Teardown
    stop_dnet 1 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-local]
    stop_dnet 2 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-local]
    stop_dnet 3 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-local]
}

function run_overlay_consul_tests() {
    ## Test overlay network with consul
    ## Setup
    start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-consul]=dnet-1-consul
    start_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-consul]=dnet-2-consul
    start_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-consul]=dnet-3-consul

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul.bats

    ## Teardown
    stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-consul]
    stop_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-consul]
    stop_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-consul]
}

function run_overlay_consul_host_tests() {
    export _OVERLAY_HOST_MODE="true"
    ## Setup
    start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-consul]=dnet-1-consul

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul-host.bats

    ## Teardown
    stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-consul]
    unset _OVERLAY_HOST_MODE
}

function run_overlay_zk_tests() {
    ## Test overlay network with zookeeper
    start_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-zookeeper]=dnet-1-zookeeper
    start_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-zookeeper]=dnet-2-zookeeper
    start_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-zookeeper]=dnet-3-zookeeper

    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-zookeeper.bats

    stop_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-zookeeper]
    stop_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-zookeeper]
    stop_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-zookeeper]
}

function run_overlay_etcd_tests() {
    ## Test overlay network with etcd
    start_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-etcd]=dnet-1-etcd
    start_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-etcd]=dnet-2-etcd
    start_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-etcd]=dnet-3-etcd

    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-etcd.bats

    stop_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-etcd]
    stop_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-etcd]
    stop_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-etcd]
}

function run_dnet_tests() {
    # Test dnet configuration options
    ./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats
}

function run_simple_consul_tests() {
    # Test a single node configuration with a global scope test driver
    ## Setup
    start_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-simple]=dnet-1-simple

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/simple.bats

    ## Teardown
    stop_dnet 1 simple 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-simple]
}

function run_multi_consul_tests() {
    # Test multi node configuration with a global scope test driver backed by consul

    ## Setup<commit_msg>Removed unused integration test code<commit_after>#!/usr/bin/env bash

set -e

export INTEGRATION_ROOT=./integration-tmp
export TMPC_ROOT=./integration-tmp/tmpc

declare -A cmap

trap "cleanup_containers" EXIT SIGINT

function cleanup_containers() {
    for c in "${!cmap[@]}";
    do
	docker stop $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
	if [ -z "$CIRCLECI" ]; then
	    docker rm -f $c 1>>${INTEGRATION_ROOT}/test.log 2>&1 || true
	fi
    done

    unset cmap
}

function run_bridge_tests() {
    ## Setup
    start_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-bridge]=dnet-1-bridge

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/bridge.bats

    ## Teardown
    stop_dnet 1 bridge 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-bridge]
}

function run_overlay_local_tests() {
    ## Test overlay network in local scope
    ## Setup
    start_dnet 1 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-local]=dnet-1-local
    start_dnet 2 local:$(dnet_container_ip 1 local) 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-local]=dnet-2-local
    start_dnet 3 local:$(dnet_container_ip 1 local) 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-local]=dnet-3-local

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-local.bats

    ## Teardown
    stop_dnet 1 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-local]
    stop_dnet 2 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-local]
    stop_dnet 3 local 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-local]
}

function run_overlay_consul_tests() {
    ## Test overlay network with consul
    ## Setup
    start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-consul]=dnet-1-consul
    start_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-consul]=dnet-2-consul
    start_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-consul]=dnet-3-consul

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul.bats

    ## Teardown
    stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-consul]
    stop_dnet 2 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-consul]
    stop_dnet 3 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-consul]
}

function run_overlay_consul_host_tests() {
    export _OVERLAY_HOST_MODE="true"
    ## Setup
    start_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-consul]=dnet-1-consul

    ## Run the test cases
    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-consul-host.bats

    ## Teardown
    stop_dnet 1 consul 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-consul]
    unset _OVERLAY_HOST_MODE
}

function run_overlay_zk_tests() {
    ## Test overlay network with zookeeper
    start_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-zookeeper]=dnet-1-zookeeper
    start_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-zookeeper]=dnet-2-zookeeper
    start_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-zookeeper]=dnet-3-zookeeper

    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-zookeeper.bats

    stop_dnet 1 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-zookeeper]
    stop_dnet 2 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-zookeeper]
    stop_dnet 3 zookeeper 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-zookeeper]
}

function run_overlay_etcd_tests() {
    ## Test overlay network with etcd
    start_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-1-etcd]=dnet-1-etcd
    start_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-2-etcd]=dnet-2-etcd
    start_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    cmap[dnet-3-etcd]=dnet-3-etcd

    ./integration-tmp/bin/bats ./test/integration/dnet/overlay-etcd.bats

    stop_dnet 1 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-1-etcd]
    stop_dnet 2 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-2-etcd]
    stop_dnet 3 etcd 1>>${INTEGRATION_ROOT}/test.log 2>&1
    unset cmap[dnet-3-etcd]
}

function run_dnet_tests() {
    # Test dnet configuration options
    ./integration-tmp/bin/bats ./test/integration/dnet/dnet.bats
}

function run_multi_consul_tests() {
    # Test multi node configuration with a global scope test driver backed by consul

    ## Setup
{'fraction_non_alphanumeric': 0.13766830184740633, 'fraction_numerical': 0.03496503496503497, 'mean_word_length': 3.582496413199426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 189, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2011261', 'n_tokens_mistral': 3994, 'n_tokens_neox': 3814, 'n_words': 689}