diff --git a/cmd/cluster_analysis_test.go b/cmd/cluster_analysis_test.go new file mode 100644 index 00000000..b5d01ae3 --- /dev/null +++ b/cmd/cluster_analysis_test.go @@ -0,0 +1,88 @@ +package cmd + +import ( + "testing" + + "github.com/qovery/qovery-client-go" +) + +func TestParseAnalysisOutput(t *testing.T) { + tests := []struct { + name string + input string + expected qovery.ClusterAnalysisOutputFormat + wantErr bool + }{ + { + name: "empty defaults to json", + input: "", + expected: qovery.CLUSTERANALYSISOUTPUTFORMAT_JSON, + }, + { + name: "json", + input: "json", + expected: qovery.CLUSTERANALYSISOUTPUTFORMAT_JSON, + }, + { + name: "table", + input: "table", + expected: qovery.CLUSTERANALYSISOUTPUTFORMAT_TABLE, + }, + { + name: "csv", + input: "csv", + expected: qovery.CLUSTERANALYSISOUTPUTFORMAT_CSV, + }, + { + name: "trims and ignores case", + input: " CSV ", + expected: qovery.CLUSTERANALYSISOUTPUTFORMAT_CSV, + }, + { + name: "invalid format", + input: "yaml", + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := parseAnalysisOutput(tt.input) + if tt.wantErr { + if err == nil { + t.Fatal("expected an error") + } + return + } + + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if got != tt.expected { + t.Fatalf("expected %q, got %q", tt.expected, got) + } + }) + } +} + +func TestIsFinalAnalysisStatus(t *testing.T) { + tests := []struct { + status qovery.ClusterAnalysisStatus + expected bool + }{ + {status: qovery.CLUSTERANALYSISSTATUS_PENDING, expected: false}, + {status: qovery.CLUSTERANALYSISSTATUS_RUNNING, expected: false}, + {status: qovery.CLUSTERANALYSISSTATUS_SUCCEEDED, expected: true}, + {status: qovery.CLUSTERANALYSISSTATUS_FAILED, expected: true}, + {status: qovery.CLUSTERANALYSISSTATUS_TERMINATED, expected: true}, + } + + for _, tt := range tests { + t.Run(string(tt.status), func(t *testing.T) { + got := isFinalAnalysisStatus(tt.status) + if got != tt.expected { + t.Fatalf("expected %t, got %t", tt.expected, got) + } + }) + } +} diff --git a/cmd/demo_scripts/create_qovery_demo.sh b/cmd/demo_scripts/create_qovery_demo.sh index 064f8ad4..072f92c1 100755 --- a/cmd/demo_scripts/create_qovery_demo.sh +++ b/cmd/demo_scripts/create_qovery_demo.sh @@ -85,12 +85,15 @@ install_or_upgrade_helm_charts() { --set services.certificates.qovery-cert-manager-webhook.enabled=false \ --set services.qovery.qovery-cluster-agent.enabled=false \ --set services.qovery.qovery-engine.enabled=false \ + --set services.qovery.qovery-operator.enabled=false \ qovery qovery/qovery fi for i in $(seq 1 3); do set -x - helm upgrade --install --create-namespace ${HELM_DEBUG} --timeout=15m -n qovery -f values.yaml --wait --atomic qovery qovery/qovery && break + helm upgrade --install --create-namespace ${HELM_DEBUG} --timeout=15m -n qovery -f values.yaml --wait --atomic \ + --set services.qovery.qovery-operator.enabled=false \ + qovery qovery/qovery && break set +x echo "Install failed. Retrying in 10 seconds. To let the cluster initialize" sleep 10 diff --git a/pkg/cluster/selfmanaged/install_self_managed_cluster_service.go b/pkg/cluster/selfmanaged/install_self_managed_cluster_service.go index aa27f112..59c814fb 100644 --- a/pkg/cluster/selfmanaged/install_self_managed_cluster_service.go +++ b/pkg/cluster/selfmanaged/install_self_managed_cluster_service.go @@ -255,11 +255,14 @@ helm upgrade --install --create-namespace -n qovery -f "%s" --rollback-on-failur --set services.certificates.qovery-cert-manager-webhook.enabled=false \ --set services.qovery.qovery-cluster-agent.enabled=false \ --set services.qovery.qovery-engine.enabled=false \ + --set services.qovery.qovery-operator.enabled=false \ qovery qovery/qovery`, helmValuesFileName)) utils.Println(fmt.Sprintf(` -# Then, re-apply the full Qovery installation with all services -helm upgrade --install --create-namespace -n qovery -f "%s" --wait --rollback-on-failure qovery qovery/qovery +# Then, re-apply the Qovery installation with the remaining services +helm upgrade --install --create-namespace -n qovery -f "%s" --wait --rollback-on-failure \ + --set services.qovery.qovery-operator.enabled=false \ + qovery qovery/qovery `, helmValuesFileName)) utils.Println("////////////////////////////////////////////////////////////////////////////////////") utils.PrintlnInfo("Please note that the installation process may take a few minutes to complete.")