Skip to content

Commit

Permalink
Merge pull request #876 from Klarrio/fix/GO-2020-0018
Browse files Browse the repository at this point in the history
Switch uuid package to get around GO-2020-0018
  • Loading branch information
sgotti authored Oct 18, 2022
2 parents ce7fd99 + 250379d commit 1551f11
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 71 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ require (
github.com/docker/leadership v0.1.0
github.com/docker/libkv v0.2.1
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang/mock v1.4.0
github.com/google/go-cmp v0.4.0
github.com/hashicorp/consul/api v1.4.0
github.com/lib/pq v1.3.0
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/copystructure v1.0.0
github.com/prometheus/client_golang v1.4.1
github.com/satori/go.uuid v1.2.0
github.com/sgotti/gexpect v0.0.0-20210315095146-1ec64e69809b
github.com/sorintlab/pollon v0.0.0-20181009091703-248c68238c16
github.com/spf13/cobra v0.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
Expand Down Expand Up @@ -290,8 +292,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sgotti/gexpect v0.0.0-20210315095146-1ec64e69809b h1:rGT0mqolw5UvjfByF0vWfFEhtL7Hn6P7dNKz7iHBMdA=
Expand Down
6 changes: 3 additions & 3 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"reflect"
"strings"

"github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

const (
Expand All @@ -50,12 +50,12 @@ var Roles = []Role{
}

func UID() string {
u := uuid.NewV4()
u := uuid.Must(uuid.NewV4())
return fmt.Sprintf("%x", u[:4])
}

func UUID() string {
return uuid.NewV4().String()
return uuid.Must(uuid.NewV4()).String()
}

const (
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/sorintlab/stolon/internal/common"
"github.com/sorintlab/stolon/internal/store"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

func TestServerParameters(t *testing.T) {
Expand All @@ -52,7 +52,7 @@ func TestServerParameters(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -149,7 +149,7 @@ func TestWalLevel(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -264,7 +264,7 @@ func TestWalKeepSegments(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -437,7 +437,7 @@ func TestAlterSystem(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -509,7 +509,7 @@ func TestAdditionalReplicationSlots(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -658,7 +658,7 @@ func TestAutomaticPgRestart(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -782,7 +782,7 @@ func TestAdvertise(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down
50 changes: 25 additions & 25 deletions tests/integration/ha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"
"time"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
"github.com/sorintlab/stolon/internal/cluster"
"github.com/sorintlab/stolon/internal/common"
pg "github.com/sorintlab/stolon/internal/postgresql"
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestInitWithMultipleKeepers(t *testing.T) {

storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -333,7 +333,7 @@ func testMasterStandby(t *testing.T, syncRepl bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -388,7 +388,7 @@ func testFailover(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -397,7 +397,7 @@ func testFailover(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -499,7 +499,7 @@ func testFailoverFailed(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -508,7 +508,7 @@ func testFailoverFailed(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -611,7 +611,7 @@ func testFailoverTooMuchLag(t *testing.T, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -620,7 +620,7 @@ func testFailoverTooMuchLag(t *testing.T, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -690,7 +690,7 @@ func testOldMasterRestart(t *testing.T, syncRepl, minSync0 bool, usePgrewind boo
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -699,7 +699,7 @@ func testOldMasterRestart(t *testing.T, syncRepl, minSync0 bool, usePgrewind boo
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

specOptions := []optionSetter{
withMinSync0(minSync0),
Expand Down Expand Up @@ -844,7 +844,7 @@ func testPartition1(t *testing.T, syncRepl, minSync0, usePgrewind bool, standbyC
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -853,7 +853,7 @@ func testPartition1(t *testing.T, syncRepl, minSync0, usePgrewind bool, standbyC
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

specOptions := []optionSetter{
withMinSync0(minSync0),
Expand Down Expand Up @@ -1010,7 +1010,7 @@ func testTimelineFork(t *testing.T, syncRepl, usePgrewind bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, usePgrewind, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func testMasterChangedAddress(t *testing.T, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -1215,7 +1215,7 @@ func testMasterChangedAddress(t *testing.T, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1301,7 +1301,7 @@ func TestFailedStandby(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1392,7 +1392,7 @@ func TestLoweredMaxStandbysPerSender(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1457,7 +1457,7 @@ func TestKeeperRemoval(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1565,7 +1565,7 @@ func testKeeperRemovalStolonCtl(t *testing.T, syncRepl bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1691,7 +1691,7 @@ func TestStandbyCantSync(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1821,7 +1821,7 @@ func TestDisappearedKeeperData(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1905,7 +1905,7 @@ func testForceFail(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -1914,7 +1914,7 @@ func testForceFail(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -2017,7 +2017,7 @@ func testSyncStandbyNotInSync(t *testing.T, minSync0 bool) {
t.Fatalf("unexpected err: %v", err)
}
defer os.RemoveAll(dir)
clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()
clusterOpts := []optionSetter{
withMinSync0(minSync0),
}
Expand Down
Loading

0 comments on commit 1551f11

Please sign in to comment.