Skip to content

Commit

Permalink
add container level test
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <[email protected]>
  • Loading branch information
SamYuan1990 committed Apr 4, 2024
1 parent d738af6 commit 5387734
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,27 @@ jobs:
run: |
export CLUSTER_PROVIDER=${{matrix.cluster_provider}}
./verify.sh
containertestubuntu:
needs:
- shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v8.1.5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: test image with container
uses: docker/build-push-action@v5
with:
context: .
file: ./test/ubuntu.Dockerfile
platforms: linux/amd64
#,linux/arm64,linux/s390x later
push: false
tags: ubuntutest:latest

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@

This repo provides the scripts to create a local [kubernetes](kind/kind.sh)/[openshift](microshift/microshift.sh) cluster to be used for development or integration tests. It is also used in [Github action](https://github.com/sustainable-computing-io/kepler-action) for kepler.

## Prerequisites
## Prerequisites for this REPO
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installing-from-release-binaries)
- [Git](https://git-scm.com/)

Please install the same version of `kubectl` and `kind` as Github-hosted runner.

Currently Kepler project's Github Action only supports `Ubuntu` based runners.

You can refer to tools list [here](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#tools)

## Prerequisites (optional)
```
./main.sh prerequisites
```
Will setup ebpf on your host instance.

## Container runtime (optional)
```
./main.sh containerruntime
```
Will setup container runtime on your host instance.

## Startup
1. Modify kind [config](./kind/manifests/kind.yml) to make sure `extraMounts:` cover the linux header and BCC.
2. Export `CLUSTER_PROVIDER` env variable:
Expand Down
11 changes: 8 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ containerruntime() {
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update -y
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
docker info
}

main() {
Expand All @@ -175,8 +174,6 @@ main() {

# shellcheck source=providers/kind/kind.sh
# shellcheck source=providers/microshift/microshift.sh
source "$cluster_lib"
print_config

case "$1" in
prerequisites)
Expand All @@ -189,21 +186,29 @@ main() {
return $?
;;
up)
source "$cluster_lib"
print_config
cluster_up
return $?
;;

down)
source "$cluster_lib"
print_config
cluster_down
return $?
;;
restart)
source "$cluster_lib"
print_config
cluster_down || true
cluster_up
return $?
;;
*)
echo "unknown command $1; bringing a cluster up"
source "$cluster_lib"
print_config
cluster_up
;;
esac
Expand Down
8 changes: 8 additions & 0 deletions test/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
From ubuntu

WORKDIR /workspace

COPY . .
RUN apt-get update -y && apt-get install -y git sudo
RUN ./main.sh containerruntime
RUN ./verify.sh containerruntime
9 changes: 9 additions & 0 deletions verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ verify_cluster() {
ok "Cluster is up and running"
}

containerruntime() {
which docker
# there is a docker in docker issue on GHA, use a or true logic as workaround
docker info || true
}

main() {
# verify the deployment of cluster
case $1 in
Expand All @@ -70,6 +76,9 @@ main() {
cluster)
verify_cluster
;;
containerruntime)
containerruntime
;;
all | *)
verify_bcc
verify_cluster
Expand Down

0 comments on commit 5387734

Please sign in to comment.