Skip to content

Commit

Permalink
integration test config
Browse files Browse the repository at this point in the history
Signed-off-by: troychiu <[email protected]>
  • Loading branch information
troychiu committed Mar 14, 2024
1 parent 44914b1 commit bd8b133
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
with:
go-version: ${{ inputs.go-version }}
- name: Integration
env:
ADMIN_DB_CONFIG: CI
run: |
# attempt to clean up some unneeded data: https://github.com/actions/virtual-environments/issues/2840#issuecomment-790492173
sudo rm -rf /usr/share/dotnet
Expand Down
27 changes: 20 additions & 7 deletions flyteadmin/tests/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package tests
import (
"context"
"fmt"
"os"

"gorm.io/gorm"

Expand All @@ -19,8 +20,18 @@ const insertExecutionQueryStr = `INSERT INTO "executions" ` +
`("execution_project","execution_domain","execution_name","phase","launch_plan_id","workflow_id") ` +
`VALUES ('%s', '%s', '%s', '%s', '%d', '%d')`

const ENV_DB_CONFIG = "ADMIN_DB_CONFIG"

var adminScope = promutils.NewScope("flyteadmin")

func getDbConfigWithEnv() *database.DbConfig {
if os.Getenv(ENV_DB_CONFIG) == "CI" {
return getDbConfig()
} else {
return getSandboxDbConfig()
}
}

func getDbConfig() *database.DbConfig {
return &database.DbConfig{
Postgres: database.PostgresConfig{
Expand All @@ -32,13 +43,15 @@ func getDbConfig() *database.DbConfig {
}
}

func getLocalDbConfig() *database.DbConfig {
// Run `flytectl demo start` to start the sandbox
func getSandboxDbConfig() *database.DbConfig {
return &database.DbConfig{
Postgres: database.PostgresConfig{
Host: "localhost",
Port: 5432,
DbName: "flyteadmin",
User: "postgres",
Host: "localhost",
Port: 30001,
DbName: "flyte",
Password: "postgres",
User: "postgres",
},
}
}
Expand Down Expand Up @@ -74,7 +87,7 @@ func truncateAllTablesForTestingOnly() {
TruncateAdminTags := fmt.Sprintf("TRUNCATE TABLE admin_tags;")
TruncateExecutionAdminTags := fmt.Sprintf("TRUNCATE TABLE execution_admin_tags;")
ctx := context.Background()
db, err := repositories.GetDB(ctx, getDbConfig(), getLoggerConfig())
db, err := repositories.GetDB(ctx, getDbConfigWithEnv(), getLoggerConfig())
if err != nil {
logger.Fatalf(ctx, "Failed to open DB connection due to %v", err)
}
Expand Down Expand Up @@ -107,7 +120,7 @@ func truncateAllTablesForTestingOnly() {

func populateWorkflowExecutionForTestingOnly(project, domain, name string) {
InsertExecution := fmt.Sprintf(insertExecutionQueryStr, project, domain, name, "UNDEFINED", 1, 2)
db, err := repositories.GetDB(context.Background(), getDbConfig(), getLoggerConfig())
db, err := repositories.GetDB(context.Background(), getDbConfigWithEnv(), getLoggerConfig())
ctx := context.Background()
if err != nil {
logger.Fatalf(ctx, "Failed to open DB connection due to %v", err)
Expand Down

0 comments on commit bd8b133

Please sign in to comment.