Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: disable sample instance in tests (#6107)
Danny Xu49fca2d604eb
diff --git a/backend/server/server.go b/backend/server/server.goindex e252478606..f3be684388 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -264,14 +264,16 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {// Start a Postgres sample server. This is used for onboarding users without requiring them to// configure an external instance.- log.Info("-----Sample Postgres Instance BEGIN-----")- sampleDataDir := common.GetPostgresSampleDataDir(profile.DataDir)- log.Info(fmt.Sprintf("sampleDatabasePort=%d", profile.SampleDatabasePort))- log.Info(fmt.Sprintf("sampleDataDir=%s", sampleDataDir))- if err := postgres.StartSampleInstance(ctx, s.pgBinDir, sampleDataDir, profile.SampleDatabasePort, profile.Mode); err != nil {- return nil, err+ if profile.SampleDatabasePort != 0 {+ log.Info("-----Sample Postgres Instance BEGIN-----")+ sampleDataDir := common.GetPostgresSampleDataDir(profile.DataDir)+ log.Info(fmt.Sprintf("sampleDatabasePort=%d", profile.SampleDatabasePort))+ log.Info(fmt.Sprintf("sampleDataDir=%s", sampleDataDir))+ if err := postgres.StartSampleInstance(ctx, s.pgBinDir, sampleDataDir, profile.SampleDatabasePort, profile.Mode); err != nil {+ return nil, err+ }+ log.Info("-----Sample Postgres Instance END-----")}- log.Info("-----Sample Postgres Instance END-----")// New MetadataDB instance.if profile.UseEmbedDB() {@@ -542,8 +544,10 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {}// Only generate onboarding data after the first enduser signup.if firstEndUser {- if err := s.generateOnboardingData(ctx, user.ID); err != nil {- return status.Errorf(codes.Internal, "failed to prepare onboarding data, error: %v", err)+ if profile.SampleDatabasePort != 0 {+ if err := s.generateOnboardingData(ctx, user.ID); err != nil {+ return status.Errorf(codes.Internal, "failed to prepare onboarding data, error: %v", err)+ }}}return nil@@ -911,8 +915,10 @@ func (s *Server) Shutdown(ctx context.Context) error {}// Shutdown postgres sample instance.- if err := postgres.Stop(s.pgBinDir, common.GetPostgresSampleDataDir(s.profile.DataDir)); err != nil {- log.Error("Failed to stop postgres sample instance", zap.Error(err))+ if s.profile.SampleDatabasePort != 0 {+ if err := postgres.Stop(s.pgBinDir, common.GetPostgresSampleDataDir(s.profile.DataDir)); err != nil {+ log.Error("Failed to stop postgres sample instance", zap.Error(err))+ }}// Shutdown postgres server if embed.diff --git a/backend/tests/start_test.go b/backend/tests/start_test.goindex 7239aa87c3..d85ab06809 100644--- a/backend/tests/start_test.go+++ b/backend/tests/start_test.go@@ -27,10 +27,9 @@ func startStopServer(ctx context.Context, a *require.Assertions, ctl *controllerprojects, err := ctl.getProjects()a.NoError(err)- // Default + Sample project.- a.Equal(2, len(projects))+ // Default.+ a.Equal(1, len(projects))a.Equal("Default", projects[0].Name)- a.Equal("Sample Project", projects[1].Name)err = ctl.Close(ctx)a.NoError(err)diff --git a/backend/tests/tests.go b/backend/tests/tests.goindex 17729192b4..0df11e9b05 100644--- a/backend/tests/tests.go+++ b/backend/tests/tests.go@@ -307,7 +307,7 @@ func getTestProfile(dataDir, resourceDir string, port int, readOnly bool, feishuExternalURL: fmt.Sprintf("http://localhost:%d", port),GrpcPort: port + 1,DatastorePort: port + 2,- SampleDatabasePort: port + 3,+ SampleDatabasePort: 0,PgUser: "bbtest",Readonly: readOnly,DataDir: dataDir,@@ -327,7 +327,7 @@ func getTestProfileWithExternalPg(dataDir, resourceDir string, port int, pgUserMode: testReleaseMode,ExternalURL: fmt.Sprintf("http://localhost:%d", port),GrpcPort: port + 1,- SampleDatabasePort: port + 2,+ SampleDatabasePort: 0,PgUser: pgUser,DataDir: dataDir,ResourceDir: resourceDir,