<commit_before>#! /bin/bash

. ./config.sh

C1=10.2.1.4
C2=10.2.1.7

direct_peers() {
  weave_on $1 status | sed -n -e 's|^Direct Peers: \(.*\)|\1|p' | tr -s ' ' '\n'
}

assert_peers() {
  assert "direct_peers $1 | sort" "$(echo "$2" | sort)"
}

start_suite "Connecting and forgetting routers after launch"

weave_on $HOST1 launch-router
weave_on $HOST2 launch-router

start_container $HOST1 $C1/24 --name=c1
start_container $HOST2 $C2/24 --name=c2

# Connect to some bogus hosts
assert_raises "weave_on $HOST2 connect 10.2.2.1 10.2.2.2"
assert_peers $HOST2 "10.2.2.1\n10.2.2.2"

# Replace bogus hosts with real hosts
assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'"
assert_raises "weave_on $HOST2 connect --replace $HOST1 $HOST2"
assert_peers $HOST2 "$HOST1\n$HOST2"
assert_raises "exec_on $HOST1 c1 $PING $C2"

# Forget everyone and disonnect
assert_raises "weave_on $HOST2 forget $HOST1 $HOST2"
assert_raises "weave_on $HOST1 stop-router"
assert_raises "weave_on $HOST1 launch-router"<commit_msg>cosmetic: fix typo in comment<commit_after>#! /bin/bash

. ./config.sh

C1=10.2.1.4
C2=10.2.1.7

direct_peers() {
  weave_on $1 status | sed -n -e 's|^Direct Peers: \(.*\)|\1|p' | tr -s ' ' '\n'
}

assert_peers() {
  assert "direct_peers $1 | sort" "$(echo "$2" | sort)"
}

start_suite "Connecting and forgetting routers after launch"

weave_on $HOST1 launch-router
weave_on $HOST2 launch-router

start_container $HOST1 $C1/24 --name=c1
start_container $HOST2 $C2/24 --name=c2

# Connect to some bogus hosts
assert_raises "weave_on $HOST2 connect 10.2.2.1 10.2.2.2"
assert_peers $HOST2 "10.2.2.1\n10.2.2.2"

# Replace bogus hosts with real hosts
assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'"
assert_raises "weave_on $HOST2 connect --replace $HOST1 $HOST2"
assert_peers $HOST2 "$HOST1\n$HOST2"
assert_raises "exec_on $HOST1 c1 $PING $C2"

# Forget everyone and disconnect
assert_raises "weave_on $HOST2 forget $HOST1 $HOST2"
assert_raises "weave_on $HOST1 stop-router"
assert_raises "weave_on $HOST1 launch-router"
{'fraction_non_alphanumeric': 0.1437037037037037, 'fraction_numerical': 0.06617283950617284, 'mean_word_length': 4.431635388739946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, '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': '4988581', 'n_tokens_mistral': 883, 'n_tokens_neox': 848, 'n_words': 221}