Skip to content

Commit

Permalink
Add app-gateway k3d integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
m00g3n committed Mar 11, 2024
1 parent 844eaa5 commit 4960209
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 12 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/kyma-integration-k3d-app-gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run app-gateway integration tests on k3d
on:
push:
branches: [ main ]
paths:
- 'components/central-application-gateway/**'
pull_request:
branches: [ main ]
paths:
- 'components/central-application-gateway/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
/home/runner/work/common/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make -C tests/components/application-connector/hack/ci k3d-gateway-tests
2 changes: 2 additions & 0 deletions components/central-application-gateway/pkg/httptools/http.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package httptools

// TODO:remove me

import (
"io"
"net/http"
Expand Down
15 changes: 15 additions & 0 deletions hack/get_kyma_file_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

function get_kyma_file_name () {

local _OS_TYPE=$1
local _OS_ARCH=$2

[ "$_OS_TYPE" == "Linux" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma-linux" ||
[ "$_OS_TYPE" == "Linux" ] && [ "$_OS_ARCH" == "arm64" ] && echo "kyma-linux-arm" ||
[ "$_OS_TYPE" == "Windows" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma.exe" ||
[ "$_OS_TYPE" == "Windows" ] && [ "$_OS_ARCH" == "arm64" ] && echo "kyma-arm.exe" ||
[ "$_OS_TYPE" == "Darwin" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma-darwin"
}

get_kyma_file_name "$@"
55 changes: 43 additions & 12 deletions tests/components/application-connector/hack/ci/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
PROJECT_ROOT ?= ../..
KYMA_ROOT_CI ?= /home/prow/go/src/github.com/kyma-project/kyma
PROJECT_ROOT ?= ../..
KYMA_ROOT_CI ?= /home/prow/go/src/github.com/kyma-project/kyma
CLUSTER_NAME ?= kyma
REGISTRY_PORT ?= 5001
REGISTRY_NAME ?= ${CLUSTER_NAME}-registry

# Operating system architecture
OS_ARCH ?= $(shell uname -m)

# Operating system type
OS_TYPE ?= $(shell uname)

.PHONY: setup-environment run-gateway-tests run-validator-tests run-agent-test

.ONESHELL:
setup-environment:
set -e
k3d registry create k3d-registry --port 5000
k3d cluster create k3d --registry-use k3d-k3d-registry:5000
kubectl cluster-info
CLI_VERSION=$(shell curl -s https://api.github.com/repos/kyma-project/cli/releases/latest | grep tag_name | cut -d '"' -f 4); \
curl -Lo kyma.tar.gz https://github.com/kyma-project/cli/releases/download/$$CLI_VERSION/kyma_Linux_x86_64.tar.gz && mkdir kyma-release && tar -C kyma-release -zxvf kyma.tar.gz && chmod +x kyma-release/kyma && mv kyma-release/kyma /usr/local/bin && rm -rf kyma-release kyma.tar.gz
setup-environment: kyma ## Setup environment for tests
${KYMA} provision k3d \
--registry-port ${REGISTRY_PORT} \
--name ${CLUSTER_NAME} \
-p 8080:80@loadbalancer \
-p 8443:443@loadbalancer \
--ci

k3d-gateway-tests: setup-environment
apk add openssl
Expand All @@ -18,7 +27,6 @@ k3d-gateway-tests: setup-environment
make -f Makefile.test-application-gateway test
k3d cluster delete


k3d-validator-tests: setup-environment
kyma deploy --ci --components-file ${PROJECT_ROOT}/resources/installation-config/mini-kyma-skr.yaml --value global.disableLegacyConnectivity=true --source=local --workspace ${KYMA_ROOT_CI}
cd ${PROJECT_ROOT}
Expand All @@ -31,4 +39,27 @@ k3d-agent-tests: setup-environment
kubectl -n kube-system delete pods -l k8s-app=kube-dns
cd ${PROJECT_ROOT}
make -f Makefile.test-compass-runtime-agent test
k3d cluster delete
k3d cluster delete

##@ Tools

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

########## Kyma CLI ###########
KYMA_STABILITY ?= unstable

define os_error
$(error Error: unsuported platform OS_TYPE:$1, OS_ARCH:$2; to mitigate this problem set variable KYMA with absolute path to kyma-cli binary compatible with your operating system and architecture)
endef

KYMA_FILE_NAME ?= $(shell ./tests/components/application-connector/hack/get_kyma_file_name.sh ${OS_TYPE} ${OS_ARCH})

KYMA ?= $(LOCALBIN)/kyma-$(KYMA_STABILITY)
kyma: $(LOCALBIN) $(KYMA) ## Download kyma locally if necessary.
$(KYMA):
$(if $(KYMA_FILE_NAME),,$(call os_error, ${OS_TYPE}, ${OS_ARCH}))
test -f $@ || curl -s -Lo $(KYMA) https://storage.googleapis.com/kyma-cli-$(KYMA_STABILITY)/$(KYMA_FILE_NAME)

15 changes: 15 additions & 0 deletions tests/components/application-connector/hack/get_kyma_file_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

function get_kyma_file_name () {

local _OS_TYPE=$1
local _OS_ARCH=$2

[ "$_OS_TYPE" == "Linux" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma-linux" ||
[ "$_OS_TYPE" == "Linux" ] && [ "$_OS_ARCH" == "arm64" ] && echo "kyma-linux-arm" ||
[ "$_OS_TYPE" == "Windows" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma.exe" ||
[ "$_OS_TYPE" == "Windows" ] && [ "$_OS_ARCH" == "arm64" ] && echo "kyma-arm.exe" ||
[ "$_OS_TYPE" == "Darwin" ] && [ "$_OS_ARCH" == "x86_64" ] && echo "kyma-darwin"
}

get_kyma_file_name "$@"

0 comments on commit 4960209

Please sign in to comment.