Skip to content

Commit 4882c59

Browse files
authored
Merge pull request #3110 from st3penta/fix-flaky-acceptance-instruction
Fix flaky tests by adding health check to git daemon
2 parents 0f3cc13 + acc094e commit 4882c59

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

acceptance/git/git.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"math"
3333
"math/big"
3434
"os"
35+
"os/exec"
3536
"path"
3637
"strings"
3738
"time"
@@ -148,10 +149,27 @@ func startStubGitServer(ctx context.Context) (context.Context, error) {
148149
}
149150
}
150151

152+
// Create a minimal health check repository before starting the container
153+
healthCheckDir := path.Join(repositories, "health-check.git")
154+
if err := os.MkdirAll(healthCheckDir, 0755); err != nil {
155+
return ctx, err
156+
}
157+
158+
// Initialize a bare git repository for health checking
159+
cmd := exec.Command("git", "init", "--bare", healthCheckDir)
160+
if err := cmd.Run(); err != nil {
161+
return ctx, fmt.Errorf("failed to create health check repository: %w", err)
162+
}
163+
151164
req := testenv.TestContainersRequest(ctx, testcontainers.ContainerRequest{
152165
Image: "docker.io/ynohat/git-http-backend",
153166
ExposedPorts: []string{"0.0.0.0::443/tcp"},
154-
WaitingFor: wait.ForListeningPort("443/tcp"),
167+
WaitingFor: wait.ForHTTP("/git/health-check.git/info/refs?service=git-upload-pack").
168+
WithPort("443/tcp").
169+
WithTLS(true).
170+
WithAllowInsecure(true).
171+
WithStartupTimeout(30 * time.Second).
172+
WithPollInterval(500 * time.Millisecond),
155173
Binds: []string{
156174
fmt.Sprintf("%s:/git:Z", repositories), // :Z is to allow accessing the directory under SELinux
157175
fmt.Sprintf("%s/nginx.conf:/etc/nginx/nginx.conf:Z", nginxConfDir),

0 commit comments

Comments
 (0)