Skip to content

Commit

Permalink
in test environments return accumulated records
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Nov 16, 2023
1 parent ce67c82 commit 636118d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ jobs:
PEERDB_CATALOG_PASSWORD: postgres
PEERDB_CATALOG_DATABASE: postgres
PEERDB_CDC_IDLE_TIMEOUT_SECONDS: 3
PEERDB_ENVIRONMENT: test
2 changes: 1 addition & 1 deletion flow/connectors/postgres/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (p *PostgresCDCSource) consumeStream(
if err != nil && !p.commitLock {
if pgconn.Timeout(err) {
log.Infof("Idle timeout reached")
if receivedPKM || len(localRecords) > 0 {
if utils.IsTestEnv() || receivedPKM || len(localRecords) > 0 {
log.Infof("Returning currently accumulated records - %d", len(localRecords))
return nil
} else {
Expand Down
20 changes: 20 additions & 0 deletions flow/connectors/utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ func GetEnvInt(name string, defaultValue int) int {

return i
}

// GetEnvString returns the value of the environment variable with the given
// name or defaultValue if the environment variable is not set.
func GetEnvString(name string, defaultValue string) string {
val, ok := GetEnv(name)
if !ok {
return defaultValue
}

return val
}

func IsTestEnv() bool {
envVal := GetEnvString("PEERDB_ENVIRONMENT", "")
if envVal == "test" {
return true
} else {
return false
}
}

0 comments on commit 636118d

Please sign in to comment.