Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (tests): Start test mongod with glibc rseq disabled and print a failed container's output, so MongoDB 9 boots on GitHub runners with Linux 7.0 and a boot failure shows its cause

Rostislav Dugin8a5c14e17d92
diff --git a/backend/internal/util/testing/containers/containers.go b/backend/internal/util/testing/containers/containers.go
index 3934f3bd..5d898a27 100644
--- a/backend/internal/util/testing/containers/containers.go
+++ b/backend/internal/util/testing/containers/containers.go
@@ -6,6 +6,7 @@ package containers
import (
"context"
+ "io"
"strconv"
"strings"
"testing"
@@ -26,6 +27,8 @@ const loopbackIP = "127.0.0.1"
// load spike. More would only delay the report of a genuinely broken image.
const containerBootAttempts = 3
+const failedContainerOutputTailBytes = 8 * 1024
+
// Endpoint is the reachable address of a started container's primary port.
type Endpoint struct {
Host string
@@ -133,6 +136,7 @@ func bootContainer(t *testing.T, req testcontainers.ContainerRequest) testcontai
lastErr = err
t.Logf("attempt %d/%d to start %s container failed: %v", attempt, containerBootAttempts, req.Image, err)
+ logContainerOutputTail(t, container, req.Image)
// GenericContainer hands back the half-started container alongside the error.
if err := testcontainers.TerminateContainer(container); err != nil {
@@ -145,6 +149,35 @@ func bootContainer(t *testing.T, req testcontainers.ContainerRequest) testcontai
return nil
}
+// A container that exits during boot surfaces only as "exited with code N"; the reason sits in its
+// own output, which is gone once the container is terminated.
+func logContainerOutputTail(t *testing.T, container testcontainers.Container, image string) {
+ t.Helper()
+
+ if container == nil {
+ return
+ }
+
+ logs, err := container.Logs(context.Background())
+ if err != nil {
+ t.Logf("failed to read %s container output: %v", image, err)
+ return
+ }
+ defer func() { _ = logs.Close() }()
+
+ output, err := io.ReadAll(logs)
+ if err != nil {
+ t.Logf("failed to read %s container output: %v", image, err)
+ return
+ }
+
+ if len(output) > failedContainerOutputTailBytes {
+ output = output[len(output)-failedContainerOutputTailBytes:]
+ }
+
+ t.Logf("%s container output tail:\n%s", image, output)
+}
+
// The MySQL client resolves the name "localhost" to a unix socket rather than TCP, and the server
// lives in a container where no such socket exists.
func endpointOf(t *testing.T, container testcontainers.Container, mappedPort string) Endpoint {
diff --git a/backend/internal/util/testing/containers/mongodb.go b/backend/internal/util/testing/containers/mongodb.go
index a8e3ce0e..9f6e72bd 100644
--- a/backend/internal/util/testing/containers/mongodb.go
+++ b/backend/internal/util/testing/containers/mongodb.go
@@ -34,11 +34,15 @@ func mongodbReady() wait.Strategy {
)
}
+// GLIBC_TUNABLES stops glibc from registering rseq, which the TCMalloc bundled in mongod needs for
+// itself; on Linux 6.19+ (GitHub runners ship 7.0) mongod otherwise exits at startup, see
+// SERVER-121912.
func mongodbEnv() map[string]string {
return map[string]string{
"MONGO_INITDB_ROOT_USERNAME": MongodbUsername,
"MONGO_INITDB_ROOT_PASSWORD": MongodbPassword,
"MONGO_INITDB_DATABASE": MongodbDatabase,
+ "GLIBC_TUNABLES": "glibc.pthread.rseq=0",
}
}