Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- validate
uses: "./.github/workflows/lib-build.yaml"

# e2e:
# needs:
# - build
# uses: "./.github/workflows/lib-e2e.yaml"
e2e:
needs:
- build
uses: "./.github/workflows/lib-e2e.yaml"
10 changes: 5 additions & 5 deletions .github/workflows/devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ jobs:
- trivy
uses: "./.github/workflows/lib-build.yaml"

# e2e:
# needs:
# - build
# uses: "./.github/workflows/lib-e2e.yaml"
e2e:
needs:
- build
uses: "./.github/workflows/lib-e2e.yaml"

# devel image push
publish:
permissions:
contents: read
id-token: write
needs:
# - e2e
- e2e
- build
uses: "./.github/workflows/lib-publish.yaml"
secrets: inherit
18 changes: 5 additions & 13 deletions .github/workflows/lib-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ jobs:
matrix:
include:
- name: e2e-spr
targetjob: e2e-spr SKIP="App:compress-perf"
targetjob: e2e-spr
runner: spr
skip: App:compress-perf
images:
- intel-qat-plugin
- intel-qat-initcontainer
- openssl-qat-engine
- intel-dsa-plugin
- intel-idxd-config-initcontainer
- accel-config-demo
- dsa-dpdk-dmadevtest
- intel-deviceplugin-operator
- intel-iaa-plugin
- crypto-perf
- intel-gpu-plugin
- intel-gpu-levelzero
- intel-sgx-plugin
- intel-sgx-initcontainer
- intel-sgx-admissionwebhook
Expand All @@ -37,6 +32,7 @@ jobs:
env:
TARGET_JOB: ${{ matrix.targetjob || matrix.name }}
IMAGES: ${{ join(matrix.images, ' ') }}
SKIP: ${{ matrix.skip || '' }}

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
Expand All @@ -50,9 +46,5 @@ jobs:
echo "SHA: ${{ github.sha }}"
echo "Images: $IMAGES"
echo "Target job: $TARGET_JOB"
- name: Wait for ready state
run: ../../../../bmetal/actions-bmetal-runstage.sh waitready
- name: Prepare test environment
run: ../../../../bmetal/actions-bmetal-runstage.sh prepare
- name: Run tests
run: ../../../../bmetal/actions-bmetal-runstage.sh test
- name: Run e2e tests
run: ./test/e2e/scripts/run.sh
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ e2e-dsa:
e2e-iaa:
@$(GO) test -v ./test/e2e/... -ginkgo.v -ginkgo.show-node-events -ginkgo.focus "Device:iaa.*$(ADDITIONAL_FOCUS_REGEX)" $(GENERATED_SKIP_OPT) -delete-namespace-on-failure=false

# This is a CI specific target to run all tests that are possible in the SPR host
e2e-spr:
@$(GO) test -v ./test/e2e/... -ginkgo.v -ginkgo.show-node-events -ginkgo.focus "Device:(iaa|dsa)|Device:qat.*Mode:dpdk.*Resource:(cy|dc).*" -ginkgo.focus "Device:sgx.*|(SGX Admission)" -ginkgo.focus "Device:gpu.*Resource:i915" $(GENERATED_SKIP_OPT) -delete-namespace-on-failure=false
@$(GO) test -v ./test/e2e/... -ginkgo.v -ginkgo.show-node-events -ginkgo.focus "Device:qat.*Mode:dpdk.*Resource:(cy|dc).*" -ginkgo.focus "Device:sgx.*|(SGX Admission)" $(GENERATED_SKIP_OPT) -delete-namespace-on-failure=false

pre-pull:
ifeq ($(TAG),devel)
Expand Down
22 changes: 22 additions & 0 deletions test/e2e/scripts/build-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

script_path=$(dirname "$(readlink -f "$0")")
source "$script_path/common.sh"

cd "$GITHUB_WORKSPACE" || exit 1

make set-version

print_large "Build and cache images"

prepare_to_build

for img in $IMAGES; do
echo "Building $img with tag $TAG"
make "$img" || exit 1
done

print_large "build ok"

exit 0

8 changes: 8 additions & 0 deletions test/e2e/scripts/cache-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

cd "$GITHUB_WORKSPACE" || exit 1

for img in $IMAGES; do
echo "Store image to cache: $img:$TAG"
docker save intel/$img:$TAG | ctr -n k8s.io image import - || exit 1
done
254 changes: 254 additions & 0 deletions test/e2e/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
#!/bin/bash

collateral_path=$HOME/collaterals/

K8S_VERSION=""
K3S_VERSION=""

fetch_current_k8s_version() {
local version

version=$(yq .jobs.envtest.strategy.matrix.version[-1] $GITHUB_WORKSPACE/.github/workflows/lib-validate.yaml)

# cut the ".x" from the version
version=$(echo $version | tr -d '"' | sed 's/\.x$//')

if [ -z "$version" ]; then
echo "Couldn't find k8s version in the workflow file"

return 1
fi

K8S_VERSION=$version
}

k3s_version_for_k8s_version() {
local requested="$K8S_VERSION"

local known_versions

known_versions="v1.34.1+k3s1;v1.33.5+k3s1;v1.32.9+k3s1;v1.31.9+k3s1;v1.30.13+k3s1"

local latest
latest=$(echo $known_versions | tr ';' '\n' | grep "$requested" | head -1)
if [ -z "$latest" ]; then
echo "No k3s version found for requested k8s version $requested"

return 1
fi

K3S_VERSION=$latest
}

download_k3s_binaries() {
mkdir -p $collateral_path/k3s-cache

[ -e $collateral_path/k3s-cache/install-k3s.sh ] || {
wget https://get.k3s.io/ -O $collateral_path/k3s-cache/install-k3s.sh || {
echo "Failed to download k3s install script"

return 1
}

chmod +x $collateral_path/k3s-cache/install-k3s.sh
}

[ -e $collateral_path/k3s-cache/${K3S_VERSION} ] && {
echo "Using cached k3s binary"

return 0
}

local k3s_ver_encoded

k3s_ver_encoded=$(echo "$K3S_VERSION" | sed -e 's/+/\%2B/')

local k3s_url
k3s_url="https://github.com/k3s-io/k3s/releases/download/${k3s_ver_encoded}/k3s"

local k3s_images_url
k3s_images_url="https://github.com/k3s-io/k3s/releases/download/${k3s_ver_encoded}/k3s-airgap-images-amd64.tar.zst"

mkdir -p $collateral_path/k3s-cache/${K3S_VERSION}

wget -q -O $collateral_path/k3s-cache/${K3S_VERSION}/k3s $k3s_url || {
echo "Failed to download k3s binary from $k3s_url"
return 1
}

chmod +x $collateral_path/k3s-cache/${K3S_VERSION}/k3s

wget -q -O $collateral_path/k3s-cache/${K3S_VERSION}/images.tar.zst $k3s_images_url || {
echo "Failed to download k3s images from $k3s_images_url"
return 1
}

return 0
}

print_large() {
type figlet > /dev/null 2>&1 && {
figlet "$@"
} || {
echo "========================================"
echo "$@"
echo "========================================"
}
}

wait_for_cluster_to_be_ready() {
echo "Waiting for cluster to become accessible"

for _ in $(seq 60); do
kubectl get pods -A 2>&1 | grep -q "No resources found" || {
echo "Cluster is accessible"
break
}

echo -n "."
sleep 1
done

echo "Waiting for Pods to become ready"

for _ in $(seq 60); do
sleep 1
echo -n "."

allcount=$(kubectl get pods -A --no-headers=true | wc -l)
notreadycount=$(kubectl get pods -A --no-headers=true | grep -c -v -e Complete -e Running)

if [ $allcount -lt 7 ]; then
continue
fi

if [ $notreadycount -eq 0 ]; then
echo "READY"

return 0
fi
done

echo ""
echo "Cluster did not become ready.."

return 1
}

prepare_cluster() {
print_large "Prepare cluster"

echo "Versions: $K3S_VERSION & $K8S_VERSION"

[ -e /usr/local/bin/k3s-uninstall.sh ] && {
echo "Found existing k3s install, removing it"

k3s-uninstall.sh || return 1
}

echo "prepare images"
sudo mkdir -p /var/lib/rancher/k3s/agent/images/ && \
sudo cp $collateral_path/k3s-cache/$K3S_VERSION/images.tar.zst /var/lib/rancher/k3s/agent/images/k3s-airgap-images-amd64.tar.zst || return 1
sudo cp $collateral_path/k3s-cache/$K3S_VERSION/k3s /usr/local/bin/ || return 1
sudo chmod +x /usr/local/bin/k3s || return 1

echo "prepare kubelet config"
cat <<EOF > /tmp/kubelet.conf
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cpuManagerPolicy: static
systemReserved:
cpu: 2000m
memory: 512M
kubeReserved:
cpu: 1000m
memory: 256M
EOF

sudo mkdir -p /etc/rancher/k3s
cat <<EOF > /tmp/k3s-config.yaml
kubelet-arg:
- config=/tmp/kubelet.conf
EOF
sudo mv /tmp/k3s-config.yaml /etc/rancher/k3s/config.yaml

echo "prepare k3s cluster"
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='--write-kubeconfig-mode=644' $collateral_path/k3s-cache/install-k3s.sh && \
sudo chmod +r /etc/rancher/k3s/k3s.yaml && \
sudo chmod o+rw /run/k3s/containerd/containerd.sock || {
return 1
}

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

wait_for_cluster_to_be_ready || return 1

kubectl get nodes -o wide
kubectl get pods -A
}

install_go() {
local go_version
go_version=$(grep "^go " $GITHUB_WORKSPACE/go.mod | head -1 | cut -c 4-)

[ -e $collateral_path/go$go_version.linux-amd64.tar.gz ] || {
wget https://go.dev/dl/go$go_version.linux-amd64.tar.gz -O $collateral_path/go$go_version.linux-amd64.tar.gz || exit 1
}

mkdir -p ~/bin
tar -xf $collateral_path/go$go_version.linux-amd64.tar.gz -C ~/bin || exit 1

export PATH=$PATH:~/bin/go/bin

type go || {
echo "Go installation failed"
return 1
}

go version || return 1
}

install_k8s_deps() {
print_large "Install cert-manager"
kubectl apply --wait -f https://github.com/cert-manager/cert-manager/releases/download/v1.18.0/cert-manager.yaml || return 1
}

prepare_to_build() {
echo "Fetch vendor dependencies"
make vendor || return 1

echo "Generate dummy licenses"

for ldir in $(ls --ignore=internal cmd | xargs -I"{}" echo licenses/{}); do
mkdir -p $GITHUB_WORKSPACE/$ldir
touch $GITHUB_WORKSPACE/$ldir/dummy-license.txt
done
}

# This should be executed only once per run.
generate_tag() {
# Extract the version from the reconciler.
local BUILD_VERSION
BUILD_VERSION=$(grep -r --include="*.go" 'ImageMinVersion =' ${GITHUB_WORKSPACE} | head -1 | sed -e 's/.*"\(.*\)".*/\1/')

# Add random components to avoid collision with other images.
BUILD_VERSION=$BUILD_VERSION-$GITHUB_RUN_NUMBER-$RANDOM

export TAG=$BUILD_VERSION
}

cache_shared_images() {
echo "Cache shared images"

local SHARED_IMAGES=""

echo $IMAGES | grep -q gpu && {
SHARED_IMAGES="${SHARED_IMAGES}intel/intel-extension-for-pytorch:2.8.10-xpu "
}

for image in $SHARED_IMAGES;
do
echo "Downloading and caching $image"
docker pull $image && docker save $image | sudo ctr -n k8s.io image import - || return 1
done
}
5 changes: 5 additions & 0 deletions test/e2e/scripts/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

sudo apt install figlet docker.io git yq make

mkdir ~/collaterals
Loading