Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/plugin/mongodb: skip tests on 32bit systems #19873

Closed
wants to merge 3 commits into from
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
5 changes: 5 additions & 0 deletions builtin/logical/database/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"log"
"os"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -709,6 +710,10 @@ func TestBackend_StaticRole_Rotations_PostgreSQL(t *testing.T) {
}

func TestBackend_StaticRole_Rotations_MongoDB(t *testing.T) {
if strconv.IntSize == 32 {
t.Skip("Skipping for 32-bit architecture")
}

cleanup, connURL := mongodb.PrepareTestContainerWithDatabase(t, "5.0.10", "vaulttestdb")
defer cleanup()

Expand Down
7 changes: 7 additions & 0 deletions plugins/database/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io"
"strconv"
"strings"

log "github.com/hashicorp/go-hclog"
Expand Down Expand Up @@ -62,6 +63,12 @@ func (m *MongoDB) Initialize(ctx context.Context, req dbplugin.InitializeRequest
m.Lock()
defer m.Unlock()

if strconv.IntSize == 32 {
// Disable the plugin on 32-bit architectures, otherwise we will get
// a panic in the mongo driver due to a field not being 64-bit aligned.
return dbplugin.InitializeResponse{}, fmt.Errorf("this plugin is disabled on 32-bit architectures")
}

m.RawConfig = req.Config

usernameTemplate, err := strutil.GetString(req.Config, "username_template")
Expand Down
14 changes: 14 additions & 0 deletions plugins/database/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/x509"
"fmt"
"reflect"
"strconv"
"strings"
"sync"
"testing"
Expand All @@ -28,7 +29,14 @@ import (

const mongoAdminRole = `{ "db": "admin", "roles": [ { "role": "readWrite" } ] }`

func skipIf32Bit(t *testing.T) {
if strconv.IntSize == 32 {
t.Skip("Skipping for 32-bit architecture")
}
}

func TestMongoDB_Initialize(t *testing.T) {
skipIf32Bit(t)
cleanup, connURL := mongodb.PrepareTestContainer(t, "latest")
defer cleanup()

Expand Down Expand Up @@ -59,6 +67,7 @@ func TestMongoDB_Initialize(t *testing.T) {
}

func TestNewUser_usernameTemplate(t *testing.T) {
skipIf32Bit(t)
type testCase struct {
usernameTemplate string

Expand Down Expand Up @@ -148,6 +157,7 @@ func TestNewUser_usernameTemplate(t *testing.T) {
}

func TestMongoDB_CreateUser(t *testing.T) {
skipIf32Bit(t)
cleanup, connURL := mongodb.PrepareTestContainer(t, "latest")
defer cleanup()

Expand Down Expand Up @@ -180,6 +190,7 @@ func TestMongoDB_CreateUser(t *testing.T) {
}

func TestMongoDB_CreateUser_writeConcern(t *testing.T) {
skipIf32Bit(t)
cleanup, connURL := mongodb.PrepareTestContainer(t, "latest")
defer cleanup()

Expand Down Expand Up @@ -214,6 +225,7 @@ func TestMongoDB_CreateUser_writeConcern(t *testing.T) {
}

func TestMongoDB_DeleteUser(t *testing.T) {
skipIf32Bit(t)
cleanup, connURL := mongodb.PrepareTestContainer(t, "latest")
defer cleanup()

Expand Down Expand Up @@ -254,6 +266,7 @@ func TestMongoDB_DeleteUser(t *testing.T) {
}

func TestMongoDB_UpdateUser_Password(t *testing.T) {
skipIf32Bit(t)
cleanup, connURL := mongodb.PrepareTestContainer(t, "latest")
defer cleanup()

Expand Down Expand Up @@ -290,6 +303,7 @@ func TestMongoDB_UpdateUser_Password(t *testing.T) {
}

func TestGetTLSAuth(t *testing.T) {
skipIf32Bit(t)
ca := certhelpers.NewCert(t,
certhelpers.CommonName("certificate authority"),
certhelpers.IsCA(true),
Expand Down