hashicorp / raft-boltdb

Raft backend implementation using BoltDB
Mozilla Public License 2.0
653 stars 112 forks source link

Disable database migration code on unsupported platforms or if the nobolt tag is present #37

Open Elara6331 opened 1 year ago

Elara6331 commented 1 year ago

Currently, raft-boltdb does not compile for unsupported architectures such as RISC-V because of its dependency on the unmaintained github.com/boltdb/bolt library. It appears the only reason that dependency exists is to be able to migrate v1 databases to v2, but it's not needed for this package to work.

This PR moves the migration code and its associated unit tests to separate files and uses build tags to only build those files if the platform is supported by bolt and the nobolt tag is not set.

Here are the results of running tests on this PR:

$ go test -v
=== RUN   TestBoltStore_MigrateToV2
--- PASS: TestBoltStore_MigrateToV2 (0.00s)
=== RUN   TestBoltStore_Implements
--- PASS: TestBoltStore_Implements (0.00s)
=== RUN   TestBoltOptionsTimeout
--- PASS: TestBoltOptionsTimeout (0.05s)
=== RUN   TestBoltOptionsReadOnly
--- PASS: TestBoltOptionsReadOnly (0.00s)
=== RUN   TestNewBoltStore
--- PASS: TestNewBoltStore (0.00s)
=== RUN   TestBoltStore_FirstIndex
--- PASS: TestBoltStore_FirstIndex (0.00s)
=== RUN   TestBoltStore_LastIndex
--- PASS: TestBoltStore_LastIndex (0.00s)
=== RUN   TestBoltStore_GetLog
--- PASS: TestBoltStore_GetLog (0.00s)
=== RUN   TestBoltStore_SetLog
--- PASS: TestBoltStore_SetLog (0.00s)
=== RUN   TestBoltStore_SetLogs
--- PASS: TestBoltStore_SetLogs (0.00s)
=== RUN   TestBoltStore_DeleteRange
--- PASS: TestBoltStore_DeleteRange (0.00s)
=== RUN   TestBoltStore_Set_Get
--- PASS: TestBoltStore_Set_Get (0.00s)
=== RUN   TestBoltStore_SetUint64_GetUint64
--- PASS: TestBoltStore_SetUint64_GetUint64 (0.00s)
PASS
ok      github.com/hashicorp/raft-boltdb/v2 0.056s

And on riscv64:

$ GOARCH=riscv64 go test -v
=== RUN   TestBoltStore_Implements
--- PASS: TestBoltStore_Implements (0.00s)
=== RUN   TestBoltOptionsTimeout
--- PASS: TestBoltOptionsTimeout (0.06s)
=== RUN   TestBoltOptionsReadOnly
--- PASS: TestBoltOptionsReadOnly (0.02s)
=== RUN   TestNewBoltStore
--- PASS: TestNewBoltStore (0.00s)
=== RUN   TestBoltStore_FirstIndex
--- PASS: TestBoltStore_FirstIndex (0.00s)
=== RUN   TestBoltStore_LastIndex
--- PASS: TestBoltStore_LastIndex (0.00s)
=== RUN   TestBoltStore_GetLog
--- PASS: TestBoltStore_GetLog (0.00s)
=== RUN   TestBoltStore_SetLog
--- PASS: TestBoltStore_SetLog (0.00s)
=== RUN   TestBoltStore_SetLogs
--- PASS: TestBoltStore_SetLogs (0.00s)
=== RUN   TestBoltStore_DeleteRange
--- PASS: TestBoltStore_DeleteRange (0.00s)
=== RUN   TestBoltStore_Set_Get
--- PASS: TestBoltStore_Set_Get (0.00s)
=== RUN   TestBoltStore_SetUint64_GetUint64
--- PASS: TestBoltStore_SetUint64_GetUint64 (0.00s)
PASS
ok      github.com/hashicorp/raft-boltdb/v2 0.154s

Fixes #27

hashicorp-cla commented 1 year ago

CLA assistant check
All committers have signed the CLA.