forked from elastic/elastic-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI]Buildkite k8s tests migration (elastic#3680)
* Buildkite k8s tests * Buildkite k8s tests * Added kind setup script * Added kind setup script * Added kind setup script * Added kind setup script * Branch configuration for k8s tests * transformed to matrix build * transformed to matrix build * transformed to matrix build * transformed to matrix build * transformed to matrix build * transformed to matrix build * transformed to matrix build * Removed k8s tests from Jenkinsfile * Run k8s tests on every PR * Fix review comments * install kind: moved path update to the top * Moved PATH declaration to the top leve script * Removed junit-annotate from k8s tests * Moved k8s tests to upper level in the pipeline
- Loading branch information
Showing
6 changed files
with
151 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
|
||
echo "--- Install Kind" | ||
|
||
MSG="environment variable missing." | ||
DEFAULT_HOME="/usr/local" | ||
KIND_VERSION=${KIND_VERSION:?$MSG} | ||
HOME=${HOME:?$DEFAULT_HOME} | ||
KIND_CMD="${HOME}/bin/kind" | ||
|
||
if command -v kind | ||
then | ||
set +e | ||
echo "Found Kind. Checking version.." | ||
FOUND_KIND_VERSION=$(kind --version 2>&1 >/dev/null | awk '{print $3}') | ||
if [ "$FOUND_KIND_VERSION" == "$KIND_VERSION" ] | ||
then | ||
echo "Versions match. No need to install Kind. Exiting." | ||
exit 0 | ||
fi | ||
set -e | ||
fi | ||
|
||
echo "Installing Kind" | ||
|
||
OS=$(uname -s| tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]') | ||
if [ "${ARCH}" == "aarch64" ] ; then | ||
ARCH_SUFFIX=arm64 | ||
else | ||
ARCH_SUFFIX=amd64 | ||
fi | ||
|
||
mkdir -p "${HOME}/bin" | ||
|
||
if curl -sSLo "${KIND_CMD}" "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-${OS}-${ARCH_SUFFIX}" ; then | ||
chmod +x "${KIND_CMD}" | ||
else | ||
echo "Something bad with the download, let's delete the corrupted binary" | ||
if [ -e "${KIND_CMD}" ] ; then | ||
rm "${KIND_CMD}" | ||
fi | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
echo "--- Install kubectl" | ||
|
||
MSG="parameter missing." | ||
DEFAULT_HOME="/usr/local" | ||
K8S_VERSION=${K8S_VERSION:?$MSG} | ||
HOME=${HOME:?$DEFAULT_HOME} | ||
KUBECTL_CMD="${HOME}/bin/kubectl" | ||
|
||
if command -v kubectl | ||
then | ||
set +e | ||
echo "Found kubectl. Checking version.." | ||
FOUND_KUBECTL_VERSION=$(kubectl version --client --short 2>&1 >/dev/null | awk '{print $3}') | ||
if [ "${FOUND_KUBECTL_VERSION}" == "${K8S_VERSION}" ] | ||
then | ||
echo "Versions match. No need to install kubectl. Exiting." | ||
exit 0 | ||
fi | ||
set -e | ||
fi | ||
|
||
echo "Installing kubectl" | ||
|
||
mkdir -p "${HOME}/bin" | ||
|
||
OS=$(uname -s| tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]') | ||
if [ "${ARCH}" == "aarch64" ] ; then | ||
ARCH_SUFFIX=arm64 | ||
else | ||
ARCH_SUFFIX=amd64 | ||
fi | ||
|
||
if curl -sSLo "${KUBECTL_CMD}" "https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/${OS}/${ARCH_SUFFIX}/kubectl" ; then | ||
chmod +x "${KUBECTL_CMD}" | ||
else | ||
echo "Something bad with the download, let's delete the corrupted binary" | ||
if [ -e "${KUBECTL_CMD}" ] ; then | ||
rm "${KUBECTL_CMD}" | ||
fi | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export PATH=$HOME/bin:${PATH} | ||
source .buildkite/scripts/install-kubectl.sh | ||
source .buildkite/scripts/install-kind.sh | ||
|
||
kind create cluster --image "kindest/node:${K8S_VERSION}" --config - <<EOF | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
kubeadmConfigPatches: | ||
- | | ||
kind: ClusterConfiguration | ||
scheduler: | ||
extraArgs: | ||
bind-address: "0.0.0.0" | ||
port: "10251" | ||
secure-port: "10259" | ||
controllerManager: | ||
extraArgs: | ||
bind-address: "0.0.0.0" | ||
port: "10252" | ||
secure-port: "10257" | ||
EOF | ||
kubectl cluster-info | ||
|
||
|
||
make -C deploy/kubernetes test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
set -uo pipefail | ||
|
||
source .buildkite/scripts/common.sh | ||
|
||
echo "--- Unit tests" | ||
RACE_DETECTOR=true TEST_COVERAGE=true mage unitTest | ||
TESTS_EXIT_STATUS=$? | ||
# Copy coverage file to build directory so it can be downloaded as an artifact | ||
cp build/TEST-go-unit.cov coverage.out | ||
cp build/TEST-go-unit.cov coverage.out | ||
exit $TESTS_EXIT_STATUS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters