Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
env:
TESTCONTAINERS_RYUK_DISABLED: "${{ inputs.ryuk-disabled }}"
RYUK_CONNECTION_TIMEOUT: "${{ inputs.project-directory == 'modules/compose' && '5m' || '60s' }}"
TESTCONTAINERS_PORT_MAPPING_TIMEOUT: "5s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: In the standard case 5s might sound generous but if a system is underload this could cause issues, what lead to choice of 5s as the default?

RYUK_RECONNECTION_TIMEOUT: "${{ inputs.project-directory == 'modules/compose' && '30s' || '10s' }}"
SHOULD_RUN_SONAR: "false"
strategy:
Expand Down
10 changes: 10 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ type Config struct {
//
// Environment variable: TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
TestcontainersHost string `properties:"tc.host,default="`

// TestcontainersPortMappingTimeout is the time to wait before all the exposed ports are mapped.
//
// Environment variable: TESTCONTAINERS_PORT_MAPPING_TIMEOUT
TestcontainersPortMappingTimeout time.Duration `properties:"tc.port.mapping.timeout,default=5s"`
}

// }
Expand Down Expand Up @@ -141,6 +146,11 @@ func read() Config {
config.RyukConnectionTimeout = timeout
}

testcontainersPortMappingTimeoutEnv := readTestcontainersEnv("TESTCONTAINERS_PORT_MAPPING_TIMEOUT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value is used in defaultReadinessHook. What if this hook will be extended in future and will include more checks than just check of the port mapping? "Port mapping" (in the name of environment variable, in the name of local variable and in the name of field of Config struct) sounds like exposure of implementation details of "default readiness hook".

What if we use different name (I'm not good in naming), like:

Suggested change
testcontainersPortMappingTimeoutEnv := readTestcontainersEnv("TESTCONTAINERS_PORT_MAPPING_TIMEOUT")
testcontainersDefaultReadinessHookTimeoutEnv := readTestcontainersEnv("TESTCONTAINERS_DEFAULT_READINESS_HOOK_TIMEOUT")

?

if timeout, err := time.ParseDuration(testcontainersPortMappingTimeoutEnv); err == nil {
config.TestcontainersPortMappingTimeout = timeout
}

return config
}

Expand Down
Loading
Loading