<commit_before>#!/bin/sh
set -e
set -x

# Set it up
docker rm -f node1 node2 etcd || true
docker run -d --net=host --name etcd quay.io/coreos/etcd:v2.0.10
dist/calicoctl reset || true

# Run various commands with invalid IPs.
! dist/calicoctl node --ip=127.a.0.1
! dist/calicoctl node --ip=fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b
! dist/calicoctl node --ip=127.0.0.1 --ip6=127.0.0.1
! dist/calicoctl node --ip=127.0.0.1 --ip6=aa:bb::zz
! dist/calicoctl bgppeer rr add 127.a.0.1
! dist/calicoctl bgppeer rr add aa:bb::zz
! dist/calicoctl pool add 127.a.0.1
! dist/calicoctl pool add aa:bb::zz
! dist/calicoctl container node1 ip add 127.a.0.1
! dist/calicoctl container node1 ip add aa:bb::zz
! dist/calicoctl container add node1 127.a.0.1
! dist/calicoctl container add node1 aa:bb::zz

# Add some pools and BGP peers and check the show commands
dist/calicoctl bgppeer rr add 172.16.58.3
dist/calicoctl bgppeer rr show
dist/calicoctl bgppeer rr show --ipv4
dist/calicoctl bgppeer rr show --ipv6
dist/calicoctl bgppeer rr show | grep 172.16.58.3
dist/calicoctl bgppeer rr show --ipv4 | grep 172.16.58.3
! dist/calicoctl bgppeer rr show --ipv6 | grep 172.16.58.3
dist/calicoctl bgppeer rr remove 172.16.58.3
! dist/calicoctl bgppeer rr show | grep 172.16.58.3

dist/calicoctl bgppeer rr add fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr show
dist/calicoctl bgppeer rr show --ipv4
dist/calicoctl bgppeer rr show --ipv6
dist/calicoctl bgppeer rr show | grep fdf8:f53e:61e4::18
! dist/calicoctl bgppeer rr show --ipv4 | grep fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr show --ipv6 | grep fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr remove fdf8:f53e:61e4::18
! dist/calicoctl bgppeer rr show | grep fdf8:f53e:61e4::18

dist/calicoctl pool add 1.2.3.4
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep 1.2.3.4/32
dist/calicoctl pool show --ipv4 | grep 1.2.3.4/32
! dist/calicoctl pool show --ipv6 | grep 1.2.3.4/32
dist/calicoctl pool remove 1.2.3.4
! dist/calicoctl pool show | grep 1.2.3.4/32

dist/calicoctl pool add 1.2.3.0/24
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep 1.2.3.0/24
dist/calicoctl pool show --ipv4 | grep 1.2.3.0/24
! dist/calicoctl pool show --ipv6 | grep 1.2.3.0/24
dist/calicoctl pool remove 1.2.3.0/24
! dist/calicoctl pool show | grep 1.2.3.0/24

dist/calicoctl pool add fdf8:f53e:61e4::18
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep aa:bb::ff/128
! dist/calicoctl pool show --ipv4 | grep aa:fc00:db20:35b:7399::5/128
dist/calicoctl pool show --ipv6 | grep aa:fc00:db20:35b:7399::5/128
dist/calicoctl pool remove aa:bb::ff/128
! dist/calicoctl pool show | grep aa:fc00:db20:35b:7399::5/128


echo "Tests completed successfully"
<commit_msg>Test running profile commands for completeness.<commit_after>#!/bin/sh
set -e
set -x

# Set it up
docker rm -f node1 node2 etcd || true
docker run -d --net=host --name etcd quay.io/coreos/etcd:v2.0.10
dist/calicoctl reset || true

# Run various commands with invalid IPs.
! dist/calicoctl node --ip=127.a.0.1
! dist/calicoctl node --ip=aa:fc00:db20:35b:7399::5
! dist/calicoctl node --ip=127.0.0.1 --ip6=127.0.0.1
! dist/calicoctl node --ip=127.0.0.1 --ip6=aa:bb::zz
! dist/calicoctl bgppeer rr add 127.a.0.1
! dist/calicoctl bgppeer rr add aa:bb::zz
! dist/calicoctl pool add 127.a.0.1
! dist/calicoctl pool add aa:bb::zz
! dist/calicoctl container node1 ip add 127.a.0.1
! dist/calicoctl container node1 ip add aa:bb::zz
! dist/calicoctl container add node1 127.a.0.1
! dist/calicoctl container add node1 aa:bb::zz

# Add some pools and BGP peers and check the show commands
dist/calicoctl bgppeer rr add 172.16.58.3
dist/calicoctl bgppeer rr show
dist/calicoctl bgppeer rr show --ipv4
dist/calicoctl bgppeer rr show --ipv6
dist/calicoctl bgppeer rr show | grep 1.2.3.4
dist/calicoctl bgppeer rr show --ipv4 | grep 1.2.3.4
! dist/calicoctl bgppeer rr show --ipv6 | grep 1.2.3.4
dist/calicoctl bgppeer rr remove 1.2.3.4
! dist/calicoctl bgppeer rr show | grep 1.2.3.4

dist/calicoctl bgppeer rr add fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr show
dist/calicoctl bgppeer rr show --ipv4
dist/calicoctl bgppeer rr show --ipv6
dist/calicoctl bgppeer rr show | grep fdf8:f53e:61e4::18
! dist/calicoctl bgppeer rr show --ipv4 | grep fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr show --ipv6 | grep fdf8:f53e:61e4::18
dist/calicoctl bgppeer rr remove fdf8:f53e:61e4::18
! dist/calicoctl bgppeer rr show | grep fdf8:f53e:61e4::18

dist/calicoctl pool add 1.2.3.4
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep 1.2.3.4/32
dist/calicoctl pool show --ipv4 | grep 1.2.3.4/32
! dist/calicoctl pool show --ipv6 | grep 1.2.3.4/32
dist/calicoctl pool remove 1.2.3.4
! dist/calicoctl pool show | grep 1.2.3.4/32

dist/calicoctl pool add 1.2.3.0/24
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep 1.2.3.0/24
dist/calicoctl pool show --ipv4 | grep 1.2.3.0/24
! dist/calicoctl pool show --ipv6 | grep 1.2.3.0/24
dist/calicoctl pool remove 1.2.3.0/24
! dist/calicoctl pool show | grep 1.2.3.0/24

dist/calicoctl pool add fdf8:f53e:61e4::18
dist/calicoctl pool show
dist/calicoctl pool show --ipv4
dist/calicoctl pool show --ipv6
dist/calicoctl pool show | grep fdf8:f53e:61e4::18/128
! dist/calicoctl pool show --ipv4 | grep fdf8:f53e:61e4::18/128
dist/calicoctl pool show --ipv6 | grep fdf8:f53e:61e4::18/128
dist/calicoctl pool remove fdf8:f53e:61e4::18/128
! dist/calicoctl pool show | grep fdf8:f53e:61e4::18/128

# Not used anywhere else in the tests; added here for completeness.
PROFILE=TEST_PROFILE
dist/calicoctl profile add $PROFILE
TAG=TEST_TAG

dist/calicoctl profile $PROFILE tag add $TAG
dist/calicoctl profile $PROFILE tag remove $TAG
dist/calicoctl profile $PROFILE tag show
dist/calicoctl profile $PROFILE rule json
dist/calicoctl profile $PROFILE rule show
echo '{
  "id": "TEST_PROFILE",
  "inbound_rules": [
    {
      "action": "allow",
      "src_tag": "TEST_PROFILE"
    },
    {
      "action": "deny"
    }
  ],
  "outbound_rules": [
    {
      "action": "allow"
    }
  ]
}' | dist/calicoctl profile $PROFILE rule update

echo "Tests completed successfully"
{'fraction_non_alphanumeric': 0.12208847897451931, 'fraction_numerical': 0.09488822885727685, 'mean_word_length': 3.7568773234200745, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 42, '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': '4477190', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2683, 'n_words': 713}