Skip to content

Commit

Permalink
Merge pull request #1 from aenix-io/add-tests-refactor
Browse files Browse the repository at this point in the history
Refactor e2e tests for applications
  • Loading branch information
klinch0 authored Oct 18, 2024
2 parents e274032 + 03206eb commit fe80232
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 59 deletions.
11 changes: 2 additions & 9 deletions hack/e2e.applications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ done
ROOT_NS="tenant-root"
TEST_TENANT="tenant-e2e"

FLUX_NS="cozy-fluxcd"
GITREPO_NAME="e2e-repo"
BRANCH="main"

function test() {
create_git_repo $GITREPO_NAME $FLUX_NS $BRANCH

install_tenant $TEST_TENANT $ROOT_NS $GITREPO_NAME $FLUX_NS
install_tenant $TEST_TENANT $ROOT_NS
check_helmrelease_status $TEST_TENANT $ROOT_NS

install_all_apps "../packages/apps" "$TEST_TENANT" $GITREPO_NAME $FLUX_NS
install_all_apps "../packages/apps" "$TEST_TENANT" cozystack-apps cozy-public

if true; then
echo -e "${GREEN}All tests passed!${RESET}"
Expand All @@ -27,7 +21,6 @@ function test() {
}

function clean() {
kubectl delete gitrepository.source.toolkit.fluxcd.io $GITREPO_NAME -n $FLUX_NS
kubectl delete helmrelease.helm.toolkit.fluxcd.io $TEST_TENANT -n $ROOT_NS
if true; then
echo -e "${GREEN}Cleanup successful!${RESET}"
Expand Down
33 changes: 0 additions & 33 deletions hack/modules/create_git_repo.sh

This file was deleted.

14 changes: 7 additions & 7 deletions hack/modules/install_all_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function is_chart_ignored() {
function install_all_apps() {
local charts_dir="$1"
local namespace="$2"
local gitrepo_name="$3"
local flux_ns="$4"
local repo_name="$3"
local repo_ns="$4"

local ignore_file="./modules/ignored_charts"
local ignored_charts
Expand All @@ -53,12 +53,12 @@ function install_all_apps() {
continue
fi

chart_name="$chart_name-e2e"
echo "Installing chart: $chart_name"
install_helmrelease "$chart_name" "$namespace" "$chart_path" "$gitrepo_name" "$flux_ns"
release_name="$chart_name-e2e"
echo "Installing release: $release_name"
install_helmrelease "$release_name" "$namespace" "$chart_name" "$repo_name" "$repo_ns"

echo "Checking status for HelmRelease: $chart_name"
check_helmrelease_status "$chart_name" "$namespace"
echo "Checking status for HelmRelease: $release_name"
check_helmrelease_status "$release_name" "$namespace"
else
echo "$chart_path is not a directory. Skipping."
fi
Expand Down
10 changes: 5 additions & 5 deletions hack/modules/install_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function install_helmrelease() {
local release_name="$1"
local namespace="$2"
local chart_path="$3"
local gitrepo_name="$4"
local flux_ns="$5"
local repo_name="$4"
local repo_ns="$5"
local values_file="$6"

if [[ -z "$release_name" ]]; then
Expand Down Expand Up @@ -41,9 +41,9 @@ function install_helmrelease() {
echo " chart: \"$chart_path\""
echo " reconcileStrategy: Revision"
echo " sourceRef:"
echo " kind: GitRepository"
echo " name: \"$gitrepo_name\""
echo " namespace: \"$flux_ns\""
echo " kind: HelmRepository"
echo " name: \"$repo_name\""
echo " namespace: \"$repo_ns\""
echo " version: '*'"
echo " interval: 1m0s"
echo " timeout: 5m0s"
Expand Down
8 changes: 4 additions & 4 deletions hack/modules/install_tenant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
function install_tenant (){
local release_name="$1"
local namespace="$2"
local gitrepo_name="$3"
local flux_ns="$4"
local values_file="${5:-tenant.yaml}"
local values_file="${3:-tenant.yaml}"
local repo_name="cozystack-apps"
local repo_ns="cozy-public"

install_helmrelease "$release_name" "$namespace" "../../packages/apps/tenant" "$gitrepo_name" "$flux_ns" "$values_file"
install_helmrelease "$release_name" "$namespace" "tenant" "$repo_name" "$repo_ns" "$values_file"
}
2 changes: 1 addition & 1 deletion hack/pre-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RED='\033[31m'
RESET='\033[0m'

check-yq-version() {
current_version=$(yq -V | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+')
current_version=$(yq -V | awk '$(NF-1) == "version" {print $NF}')
if [ -z "$current_version" ]; then
echo "yq is not installed or version cannot be determined."
exit 1
Expand Down

0 comments on commit fe80232

Please sign in to comment.