Skip to content

Commit 79b4927

Browse files
authored
Merge pull request #1397 from neolit123/packages
add e2e test for install/uninstall DEB packages
2 parents 8f0b85d + 786349d commit 79b4927

File tree

2 files changed

+141
-5
lines changed

2 files changed

+141
-5
lines changed

tests/e2e/packages/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
## Tools for verifying Kubernetes packages are published
1+
## Tools for verifying Kubernetes packages
22

3-
The `verify_packages_published.sh` script in this folder verifies that the necessary deb/rpms are published to official repositories.
4-
This script is run periodically and results are available at https://k8s-testgrid.appspot.com/sig-cluster-lifecycle-all#periodic-kubernetes-e2e-packages-pushed
3+
The tests in this folder run periodically and their status is available here:
4+
https://k8s-testgrid.appspot.com/sig-cluster-lifecycle-all
55

6-
### Running
6+
### Package publishing
77

8-
The script should be run in a Docker container like this:
8+
The `verify_packages_published.sh` script verifies that the necessary DEB/RPM packages are published to official repositories.
99

10+
Running locally:
1011
```
1112
docker run -it -v $(pwd):/test debian:stretch /test/tests/e2e/packages/verify_packages_published.sh
1213
```
14+
15+
### Package installation
16+
17+
The `verify_packages_install_deb.sh` verifies that the DEB packages from our release repositories and CI build
18+
can be installed and uninstalled successfully.
19+
20+
Running locally:
21+
```
22+
docker run -it -v $(pwd):/test debian:stretch /test/tests/e2e/packages/verify_packages_install_deb.sh
23+
```
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
3+
set -o nounset
4+
set -o pipefail
5+
set -o errexit
6+
7+
# This test installs debian packages that are a result of the CI and release builds.
8+
# It runs '... --version' commands to verify that the binaries are correctly installed
9+
# and finally uninstalls the packages.
10+
# For the release packages it tests all versions in the support skew.
11+
12+
LINE_SEPARATOR="*************************************************"
13+
echo "$LINE_SEPARATOR"
14+
15+
PACKAGES_TO_TEST_K8S=("kubectl" "kubelet" "kubeadm")
16+
PACKAGES_TO_TEST_EXT=("cri-tools" "kubernetes-cni")
17+
18+
PACKAGES_TO_TEST=("${PACKAGES_TO_TEST_EXT[@]}" "${PACKAGES_TO_TEST_K8S[@]}")
19+
20+
# harcode the LSB release to "xenial" instead of calling "lsb_release -c -s"
21+
LSB_RELEASE="xenial"
22+
23+
# install prerequisites
24+
25+
echo "* installing prerequisites"
26+
apt-get update
27+
apt-get install -y apt-transport-https curl python gnupg
28+
29+
# check if gsutil from the Google Cloud SDK exists and if not install the SDK
30+
31+
if ! gsutil version > /dev/null; then
32+
curl -sSL https://sdk.cloud.google.com > /tmp/gcl && bash /tmp/gcl --install-dir=~/gcloud --disable-prompts
33+
export PATH=$PATH:~/gcloud/google-cloud-sdk/bin
34+
fi
35+
gsutil version
36+
37+
# test CI packages
38+
39+
echo "$LINE_SEPARATOR"
40+
echo "* TESTING CI PACKAGES"
41+
42+
PACKAGE_EXT="deb"
43+
CI_DIR=/tmp/k8s-ci
44+
mkdir -p $CI_DIR
45+
mkdir -p /opt/cni/bin
46+
CI_VERSION=$(curl -sSL https://dl.k8s.io/ci/latest.txt)
47+
CI_URL="gs://kubernetes-release-dev/ci/$CI_VERSION-bazel/bin/linux/amd64"
48+
49+
echo "* testing CI version $CI_VERSION"
50+
51+
for CI_PACKAGE in "${PACKAGES_TO_TEST[@]}"; do
52+
echo "* downloading package: $CI_URL/$CI_PACKAGE.$PACKAGE_EXT"
53+
gsutil cp "$CI_URL/$CI_PACKAGE.$PACKAGE_EXT" "$CI_DIR/$CI_PACKAGE.$PACKAGE_EXT"
54+
dpkg -i "$CI_DIR/$CI_PACKAGE.$PACKAGE_EXT" || echo "* ignoring expected 'dpkg -i' result"
55+
done
56+
57+
echo "* installing"
58+
59+
apt-get install -f -y
60+
61+
echo "* testing binaries"
62+
63+
kubeadm version -o=short
64+
kubectl version --client=true --short=true
65+
kubelet --version
66+
crictl --version
67+
ls /opt/cni/bin/loopback
68+
69+
echo "* removing packages"
70+
71+
apt-get remove -y --purge "${PACKAGES_TO_TEST[@]}"
72+
apt-get autoremove -y
73+
74+
rm -rf $CI_DIR
75+
76+
# test stable packages
77+
# NOTE: MAJOR version bumps are not supported!
78+
79+
echo "$LINE_SEPARATOR"
80+
echo "* TESTING STABLE PACKAGES"
81+
82+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
83+
cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
84+
deb http://apt.kubernetes.io/ kubernetes-$LSB_RELEASE main
85+
EOF
86+
apt-get update
87+
88+
VERSIONS=$(apt-cache madison kubelet | awk '{print $3}')
89+
LATEST_STABLE=$(apt-cache madison kubelet | awk '{print $3}' | head -1)
90+
LATEST_STABLE_MINOR=$(echo "$LATEST_STABLE" | cut -d '.' -f 2)
91+
MIN_SUPPORTED_MINOR=$(("$LATEST_STABLE_MINOR" - 2))
92+
93+
for VER in $VERSIONS; do
94+
echo "$LINE_SEPARATOR"
95+
echo "* testing version: $VER"
96+
MINOR=$(echo "$VER" | cut -d '.' -f 2)
97+
98+
if [[ "$MINOR" -lt "$MIN_SUPPORTED_MINOR" ]]; then
99+
echo "* found version outside of the support skew: $VER; finishing..."
100+
break
101+
fi
102+
103+
# add versions for the k/k originated packages
104+
PACKAGES_TO_TEST_K8S_VER=()
105+
for PKG_K8S in "${PACKAGES_TO_TEST_K8S[@]}"; do
106+
PACKAGES_TO_TEST_K8S_VER+=("$PKG_K8S=$VER")
107+
done
108+
109+
echo "* installing ${PACKAGES_TO_TEST_EXT[*]} ${PACKAGES_TO_TEST_K8S_VER[*]}"
110+
111+
apt-get install -y "${PACKAGES_TO_TEST_EXT[@]}" "${PACKAGES_TO_TEST_K8S_VER[@]}"
112+
113+
echo "* testing binaries"
114+
115+
kubeadm version -o=short
116+
kubectl version --client=true --short=true
117+
kubelet --version
118+
crictl --version
119+
ls /opt/cni/bin/loopback
120+
121+
echo "* removing packages"
122+
123+
apt-get remove -y --purge "${PACKAGES_TO_TEST[@]}"
124+
apt-get autoremove -y
125+
done

0 commit comments

Comments
 (0)