Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mono-repo' into mono-repo-circle…
Browse files Browse the repository at this point in the history
…ci-ee
  • Loading branch information
isacikgoz committed Mar 15, 2023
2 parents 74f8e1b + 724ad8e commit 2d1bb7f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
--env-file=dotenv/test.env \
--env MM_SQLSETTINGS_DRIVERNAME="${{ inputs.drivername }}" \
--env MM_SQLSETTINGS_DATASOURCE="${{ inputs.datasource }}" \
--env TEST_DATABASE_MYSQL_DSN="${{ inputs.datasource }}" \
--env TEST_DATABASE_POSTGRESQL_DSN="${{ inputs.datasource }}" \
-v ~/work/mattermost-server:/mattermost-server \
-w /mattermost-server/mattermost-server/server \
$BUILD_IMAGE \
Expand Down
2 changes: 1 addition & 1 deletion server/channels/store/sqlstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func SetupConnection(connType string, dataSource string, settings *model.SqlSett
}

for i := 0; i < DBPingAttempts; i++ {
mlog.Info("Pinging SQL", mlog.String("database", connType))
mlog.Info("Pinging SQL", mlog.String("database", connType), mlog.String("dataSource", dataSource))
ctx, cancel := context.WithTimeout(context.Background(), DBPingTimeoutSecs*time.Second)
defer cancel()
err = db.PingContext(ctx)
Expand Down
29 changes: 27 additions & 2 deletions server/channels/store/storetest/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pkg/errors"

"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/server/platform/shared/mlog"
)

const (
Expand Down Expand Up @@ -50,7 +51,19 @@ func log(message string) {
// MySQLSettings returns the database settings to connect to the MySQL unittesting database.
// The database name is generated randomly and must be created before use.
func MySQLSettings(withReplica bool) *model.SqlSettings {
dsn := getEnv("TEST_DATABASE_MYSQL_DSN", defaultMysqlDSN)
dsn := os.Getenv("TEST_DATABASE_MYSQL_DSN")
if dsn == "" {
dsn = defaultMysqlDSN
mlog.Info("No TEST_DATABASE_MYSQL_DSN override, using default", mlog.String("default_dsn", dsn))
} else {
mlog.Info("Using TEST_DATABASE_MYSQL_DSN override", mlog.String("dsn", dsn))
}

if os.Getenv("MM_SQLSETTINGS_DATASOURCE") != "" {
os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
mlog.Info("Clearing MM_SQLSETTINGS_DATASOURCE to use test dsn exclusively")
}

cfg, err := mysql.ParseDSN(dsn)
if err != nil {
panic("failed to parse dsn " + dsn + ": " + err.Error())
Expand All @@ -70,7 +83,19 @@ func MySQLSettings(withReplica bool) *model.SqlSettings {
// PostgresSQLSettings returns the database settings to connect to the PostgreSQL unittesting database.
// The database name is generated randomly and must be created before use.
func PostgreSQLSettings() *model.SqlSettings {
dsn := getEnv("TEST_DATABASE_POSTGRESQL_DSN", defaultPostgresqlDSN)
dsn := os.Getenv("TEST_DATABASE_POSTGRESQL_DSN")
if dsn == "" {
dsn = defaultPostgresqlDSN
mlog.Info("No TEST_DATABASE_POSTGRESQL_DSN override, using default", mlog.String("default_dsn", dsn))
} else {
mlog.Info("Using TEST_DATABASE_POSTGRESQL_DSN override", mlog.String("dsn", dsn))
}

if os.Getenv("MM_SQLSETTINGS_DATASOURCE") != "" {
os.Unsetenv("MM_SQLSETTINGS_DATASOURCE")
mlog.Info("Clearing MM_SQLSETTINGS_DATASOURCE to use test dsn exclusively")
}

dsnURL, err := url.Parse(dsn)
if err != nil {
panic("failed to parse dsn " + dsn + ": " + err.Error())
Expand Down
2 changes: 1 addition & 1 deletion server/playbooks/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func Setup(t *testing.T) *TestEnvironment {
os.Unsetenv("MM_SERVICESETTINGS_LISTENADDRESS")

// Environment Settings
driverName := getEnvWithDefault("TEST_DATABASE_DRIVERNAME", "postgres")
driverName := getEnvWithDefault("MM_SQLSETTINGS_DRIVERNAME", "postgres")
sqlSettings := storetest.MakeSqlSettings(driverName, false)

// Create a test memory store and modify configuration appropriately
Expand Down

0 comments on commit 2d1bb7f

Please sign in to comment.