| 1 |
#!/usr/bin/env bash |
| 2 |
set -euo pipefail |
| 3 |
|
| 4 |
# Check for root |
| 5 |
if [[ $EUID -ne 0 ]]; then |
| 6 |
echo "Please run this script as root" |
| 7 |
exit 1 |
| 8 |
fi |
| 9 |
|
| 10 |
# Install latest CRI-O |
| 11 |
curl https://raw.githubusercontent.com/cri-o/cri-o/master/scripts/get | bash |
| 12 |
crio --version |
| 13 |
|
| 14 |
# Use runc as default runtime |
| 15 |
rm /etc/crio/crio.conf.d/10-crun.conf |
| 16 |
cat <<EOT >>/etc/crio/crio.conf.d/10-config.conf |
| 17 |
[crio.runtime] |
| 18 |
log_level = "debug" |
| 19 |
[crio.runtime.runtimes.runc] |
| 20 |
runtime_path = "/usr/local/bin/runc" |
| 21 |
EOT |
| 22 |
runc --version |
| 23 |
|
| 24 |
# Start CRI-O |
| 25 |
systemctl daemon-reload |
| 26 |
systemctl start crio |
| 27 |
systemctl is-active --quiet crio && echo CRI-O is running |
| 28 |
journalctl --no-pager -u crio |
| 29 |
|
| 30 |
# Start Kubernetes |
| 31 |
GOROOT="$GOROOT_1_17_X64" |
| 32 |
GOPATH="$HOME/go" |
| 33 |
PATH="$GOROOT/bin:$PATH" |
| 34 |
K8SPATH="$GOPATH/src/k8s.io" |
| 35 |
mkdir -p "$K8SPATH" |
| 36 |
pushd "$K8SPATH" |
| 37 |
git clone --depth=1 https://github.com/kubernetes/kubernetes |
| 38 |
pushd kubernetes |
| 39 |
|
| 40 |
LATEST=$(curl -sSfL https://dl.k8s.io/ci/latest.txt) |
| 41 |
echo "Using Kubernetes build $LATEST" |
| 42 |
|
| 43 |
URL="https://dl.k8s.io/ci/$LATEST" |
| 44 |
mkdir -p _output/bin |
| 45 |
|
| 46 |
echo Downloading server binaries |
| 47 |
curl -sSfL "$URL/kubernetes-server-linux-amd64.tar.gz" -o- | tar xfz - |
| 48 |
cp kubernetes/server/bin/{kubectl,kube-apiserver,kube-controller-manager,kube-proxy,kube-scheduler,kubelet} \ |
| 49 |
_output/bin |
| 50 |
|
| 51 |
echo Downloading test binaries |
| 52 |
curl -sSfL "$URL/kubernetes-test-linux-amd64.tar.gz" -o- | tar xfz - |
| 53 |
cp kubernetes/test/bin/{ginkgo,e2e.test} _output/bin |
| 54 |
|
| 55 |
export CONTAINER_RUNTIME=remote |
| 56 |
export CGROUP_DRIVER=systemd |
| 57 |
export CGROUP_ROOT=/ |
| 58 |
export KUBELET_FLAGS='--runtime-cgroups=/system.slice/crio.service --non-masquerade-cidr=0.0.0.0/0' |
| 59 |
export CONTAINER_RUNTIME_ENDPOINT=/var/run/crio/crio.sock |
| 60 |
export ALLOW_PRIVILEGED=1 |
| 61 |
|
| 62 |
IP=$(ip route get 1.2.3.4 | cut -d ' ' -f7 | tr -d '[:space:]') |
| 63 |
echo "Using IP: $IP" |
| 64 |
export DNS_SERVER_IP=$IP |
| 65 |
export API_HOST_IP=$IP |
| 66 |
|
| 67 |
iptables -F |
| 68 |
hack/install-etcd.sh |
| 69 |
export PATH="$GOPATH/src/k8s.io/kubernetes/third_party/etcd:$PATH" |
| 70 |
|
| 71 |
OUTPUT=$(mktemp) |
| 72 |
hack/local-up-cluster.sh -O 2>&1 | tee "$OUTPUT" & |
| 73 |
PID=$! |
| 74 |
|
| 75 |
until grep -q "Local Kubernetes cluster is running" "$OUTPUT"; do |
| 76 |
echo Waiting for hack/local-up-cluster.sh |
| 77 |
if ! ps $PID >/dev/null; then |
| 78 |
exit 1 |
| 79 |
fi |
| 80 |
sleep 5 |
| 81 |
done |
| 82 |
|
| 83 |
echo Cluster is up and running |
| 84 |
|
| 85 |
# Run the tests |
| 86 |
export KUBERUN=/var/run/kubernetes |
| 87 |
export KUBECONFIG=$KUBERUN/admin.kubeconfig |
| 88 |
export PATH="$GOPATH/src/k8s.io/kubernetes/_output/local/bin/linux/amd64:$PATH" |
| 89 |
export KUBE_MASTER_URL=$IP |
| 90 |
export KUBE_MASTER_IP=$IP |
| 91 |
export KUBE_MASTER=$IP |
| 92 |
export HOSTNAME_OVERRIDE=$IP |
| 93 |
|
| 94 |
export GINKGO_PARALLEL_NODES=4 |
| 95 |
export GINKGO_PARALLEL=y |
| 96 |
|
| 97 |
_output/bin/e2e.test --provider=local --host="https://$IP:6443" \ |
| 98 |
--ginkgo.focus='\[NodeConformance|NodeFeature:.*\]' \ |
| 99 |
--ginkgo.skip='\[Flaky|Slow|Serial|sig-network|NodeFeature:RuntimeHandler\]|exec hook properly' |