mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-28 18:18:41 +00:00
Refactor e2e tests for applications
This commit is contained in:
@@ -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}"
|
||||
@@ -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}"
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function create_git_repo() {
|
||||
local repo_name="$1"
|
||||
local namespace="$2"
|
||||
local branch="$3"
|
||||
|
||||
if [[ -z "$repo_name" || -z "$namespace" || -z "$branch" ]]; then
|
||||
echo "Usage: create_git_repo <repo_name> <namespace> <branch>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local gitrepo_file=$(mktemp /tmp/GitRepository.XXXXXX.yaml)
|
||||
{
|
||||
echo "apiVersion: source.toolkit.fluxcd.io/v1"
|
||||
echo "kind: GitRepository"
|
||||
echo "metadata:"
|
||||
echo " name: \"$repo_name\""
|
||||
echo " namespace: \"$namespace\""
|
||||
echo "spec:"
|
||||
echo " interval: 1m"
|
||||
echo " url: https://github.com/aenix-io/cozystack"
|
||||
echo " ref:"
|
||||
echo " branch: \"$branch\""
|
||||
echo " ignore: |"
|
||||
echo " !/packages/apps/ "
|
||||
|
||||
} > "$gitrepo_file"
|
||||
|
||||
kubectl apply -f "$gitrepo_file"
|
||||
|
||||
rm -f "$gitrepo_file"
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user