Skip to content

Commit

Permalink
implementation of local e2e-tests (kubernetes-retired#121)
Browse files Browse the repository at this point in the history
* e2e

more minor refactoring

delete github actions with sonobuoy

init test_e2e.sh

add e2e tests

added few e2e fns and main.sh

Signed-off-by: Neha Lohia <[email protected]>

adding local tests

add _artifacts to gitignore

fix daemonset invalid char issue

Signed-off-by: Neha Lohia <[email protected]>

x

fix ginkgo binary executable issue

Signed-off-by: Neha Lohia <[email protected]>

enabling proper iteration over backends and ipfamilies

fixing trouble with missing kubeconf

add input args for ipfamily and backend

Signed-off-by: Neha Lohia <[email protected]>

removed history file

Signed-off-by: Neha Lohia <[email protected]>

add e2e in github actions

Signed-off-by: Neha Lohia <[email protected]>

add e2e in github actions2

Signed-off-by: Neha Lohia <[email protected]>

fix github actions issues

Signed-off-by: Neha Lohia <[email protected]>

fix github actions issues 2

Signed-off-by: Neha Lohia <[email protected]>

fix github actions issues 3

Signed-off-by: Neha Lohia <[email protected]>

fix github actions issues 4

Signed-off-by: Neha Lohia <[email protected]>

refactor according to review

test change

Signed-off-by: Neha Lohia <[email protected]>

further improvements

Add help for ci mode

Improve help for ci mode

Fix ci mode

Fix export of logs to wrong dir

Fix script not properly failing

fix export of logs for failing tests

fix more fixes

remove debug messages

* Make failing tests not fail in gh actions, to remove blockers

* echo hint on failing tests
  • Loading branch information
friedrichwilken authored Dec 10, 2021
1 parent 712beea commit a3cf2e3
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 32 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/backend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ name: Backend Build Tests
on:
push:
branches:
- main
- master
- github_actions # TODO delete this if ever merged to master/main
pull_request:
branches:
- main
- master
- github_actions # TODO delete this if ever merged to master/main

jobs:
setup:
name: setup
runs-on: ubuntu-latest
steps:
- name: Setup Go
- name: setup Go
uses: actions/setup-go@v2
with:
go-version: '1.17.3'
Expand All @@ -34,8 +31,8 @@ jobs:
- name: checkout
uses: actions/checkout@v2

- name: Build backends/iptables
run: ./hack/build.sh iptables
- name: build backends/iptables
run: ./hack/test_backend_build.sh iptables

ipvs-as-sink:
name: build backend package ipvs-as-sink
Expand All @@ -45,8 +42,8 @@ jobs:
- name: checkout
uses: actions/checkout@v2

- name: Build backends/ipvs-as-sink
run: ./hack/build.sh ipvs
- name: build backends/ipvs-as-sink
run: ./hack/test_backend_build.sh ipvs

nft:
name: build backend package nft
Expand All @@ -56,5 +53,5 @@ jobs:
- name: checkout
uses: actions/checkout@v2

- name: Build backends/nft
run: ./hack/build.sh nft
- name: build backends/nft
run: ./hack/test_backend_build.sh nft
73 changes: 73 additions & 0 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: e2e tests
on:
push:
branches:
- master
pull_request:
branches:
- master

env:
GO_VERSION: "1.17.3"

jobs:
setup:
name: setup
runs-on: ubuntu-latest
steps:
- name: setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Install dependencies
run: |
go version
go get -u golang.org/x/lint/golint
e2e:
name: e2e
needs: setup
runs-on: ubuntu-latest
timeout-minutes: 100
strategy:
fail-fast: false
matrix:
ipFamily: ["ipv4", "ipv6", "dual"]
backend: ["iptables", "nft", "ipvs"]
env:
JOB_NAME: "kpng-e2e-${{ matrix.ipFamily }}-${{ matrix.backend }}"
IP_FAMILY: ${{ matrix.ipFamily }}
BACKEND: ${{ matrix.backend }}
steps:
- name: checkout
uses: actions/checkout@v2

- name: run e2e tests
run: ./hack/test_e2e.sh -i ${{ env.IP_FAMILY }} -b ${{ env.BACKEND }} -c

- name: Export logs
if: always()
run: |
./hack/e2e_export_logs.sh
- name: Upload Junit Reports
if: always()
uses: actions/upload-artifact@v2
with:
name: kind-junit-${{ env.JOB_NAME }}-${{ github.run_id }}
path: './hack/temp/e2e/artifacts/reports/*.xml'

- name: Upload logs
if: always()
uses: actions/upload-artifact@v2
with:
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }}
path: ./hack/temp/e2e/artifacts/logs/

- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
if: always()
with:
report_paths: './hack/temp/e2e/artifacts/reports/*.xml'
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
name: Unit Tests Build
name: Unit Tests

on:
push:
branches:
- main
- master
- github_actions # TODO delete this if ever merged to master/main
pull_request:
branches:
- main
- master
- github_actions # TODO delete this if ever merged to master/main

jobs:
setup:
Expand All @@ -26,14 +22,13 @@ jobs:
go version
go get -u golang.org/x/lint/golint
build_tests:
name: build unit tests
test:
name: run unit tests
needs: setup
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- name: Build unit tests
- name: run unit tests
run: ./hack/test_unit.sh

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ Participation in the Kubernetes community is governed by the [Kubernetes Code of

[owners]: https://git.k8s.io/community/contributors/guide/owners.md
[Creative Commons 4.0]: https://git.k8s.io/website/LICENSE


TODO add some lines about what to find ./hack
4 changes: 3 additions & 1 deletion hack/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
kpng-deployment-ds.yaml
/sonobuoy
/sonobuoy
/temp
/_artifacts
7 changes: 7 additions & 0 deletions hack/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

TODO add toc for file because we will have to add a lot of text for all the test

TODO add how-to/prereq. for e2e tests
TODO add how-to/prereq. for backend build unit tests
TODO add how-to/prereq. for backend build tests

# Get up and running w kpng

Run the local-up-kpng.sh script (make sure you have a kind or other cluster ready).
Expand Down
26 changes: 26 additions & 0 deletions hack/e2e_export_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script is for ci
# if the test_e2e.sh fails, the logs still need to be exportet

set -e
pushd "${0%/*}" > /dev/null
E2E_DIR="$(pwd)/temp/e2e/"
popd > /dev/null
E2E_FILE="${E2E_DIR}/clustername"
E2E_LOGS="${E2E_DIR}/artifacts/logs"
kind export logs --name="$(cat $E2E_FILE)" --loglevel="debug" "${E2E_LOGS}"
6 changes: 3 additions & 3 deletions hack/setup_sonobuoy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function is_kind_available() {
function is_kind_available {
if ! command -v kind &> /dev/null
then
echo "kind could not be found"
exit
fi
}

function setup_sonobuoy() {
function setup_sonobuoy {
if [ -f ./sonobuoy/sonobuoy ]; then
echo "Found Sonobuoy, skipping setup."
else
Expand All @@ -36,7 +36,7 @@ function setup_sonobuoy() {
fi
}

function setup_kind() {
function setup_kind {
if kind get clusters | grep -q kpng-proxy; then
echo "Found kind cluster 'kpng-proxy', skipping setup."
else
Expand Down
8 changes: 4 additions & 4 deletions hack/build.sh → hack/test_backend_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
package=$1

# removing output from pushd
function pushd () {
function pushd {
command pushd "$@" > /dev/null
}
# removing output from popd
function popd () {
function popd {
command popd "$@" > /dev/null
}

function build_package() {
function build_package {
local dir="$1"
echo "trying to build '$dir' "
pushd ./$dir/
Expand All @@ -34,7 +34,7 @@ function build_package() {
popd
}

function build_all_backends() {
function build_all_backends {
cd ./backends
for f in $(find -name go.mod); do build_package $(dirname $f); done
}
Expand Down
Loading

0 comments on commit a3cf2e3

Please sign in to comment.