---
# Source: consul/templates/test-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: ship-consul-tests
data:
  run.sh: |-
    @test "Testing Consul cluster has quorum" {
      for i in {0..2}; do
        for n in {1..30}; do
          if [ `kubectl exec ship-consul-$i consul members --namespace=default | grep server | wc -l` -ge "3" ]; then
            echo "ship-consul-$i OK. consul members returning at least 3 records."
            break
          else
            echo "ship-consul-$i ERROR. consul members returning less than 3 records."
          fi

          if [ "$n" -ge "30" ]; then
            echo "Failed $n times to get members from ship-consul-$i"
            exit 1
          fi
          sleep 10
        done
      done
    }
