diff --git a/command/agent/consul/check_watcher_test.go b/command/agent/consul/check_watcher_test.go index 7e961bf2214..118148fc19e 100644 --- a/command/agent/consul/check_watcher_test.go +++ b/command/agent/consul/check_watcher_test.go @@ -219,12 +219,8 @@ func TestCheckWatcher_Healthy(t *testing.T) { cw.Run(ctx) // Ensure restart was never called - if n := len(restarter1.restarts); n > 0 { - t.Errorf("expected check 1 to not be restarted but found %d:\n%s", n, restarter1) - } - if n := len(restarter2.restarts); n > 0 { - t.Errorf("expected check 2 to not be restarted but found %d:\n%s", n, restarter2) - } + must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted")) + must.SliceEmpty(t, restarter2.restarts, must.Sprint("expected check 2 to not be restarted")) } // TestCheckWatcher_Unhealthy asserts unhealthy tasks are restarted exactly once. @@ -272,9 +268,7 @@ func TestCheckWatcher_HealthyWarning(t *testing.T) { cw.Run(ctx) // Ensure restart was never called on check 1 - if n := len(restarter1.restarts); n > 0 { - t.Errorf("expected check 1 to not be restarted but found %d", n) - } + must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted")) } // TestCheckWatcher_Flapping asserts checks that flap from healthy to unhealthy @@ -302,9 +296,7 @@ func TestCheckWatcher_Flapping(t *testing.T) { cw.Run(ctx) // Ensure restart was never called on check 1 - if n := len(restarter1.restarts); n > 0 { - t.Errorf("expected check 1 to not be restarted but found %d\n%s", n, restarter1) - } + must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted")) } // TestCheckWatcher_Unwatch asserts unwatching checks prevents restarts. @@ -329,9 +321,7 @@ func TestCheckWatcher_Unwatch(t *testing.T) { cw.Run(ctx) // Ensure restart was never called on check 1 - if n := len(restarter1.restarts); n > 0 { - t.Errorf("expected check 1 to not be restarted but found %d\n%s", n, restarter1) - } + must.SliceEmpty(t, restarter1.restarts, must.Sprint("expected check 1 to not be restarted")) } // TestCheckWatcher_MultipleChecks asserts that when there are multiple checks diff --git a/go.mod b/go.mod index a0e1726e982..ecd0d680b11 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/hashicorp/go-msgpack v1.1.5 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-plugin v1.4.3 - github.com/hashicorp/go-set v0.1.4 + github.com/hashicorp/go-set v0.1.6 github.com/hashicorp/go-sockaddr v1.0.2 github.com/hashicorp/go-syslog v1.0.0 github.com/hashicorp/go-uuid v1.0.2 @@ -107,8 +107,8 @@ require ( github.com/ryanuber/columnize v2.1.1-0.20170703205827-abc90934186a+incompatible github.com/ryanuber/go-glob v1.0.0 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 - github.com/shirou/gopsutil/v3 v3.21.12 - github.com/shoenig/test v0.3.1 + github.com/shirou/gopsutil/v3 v3.22.7 + github.com/shoenig/test v0.4.0 github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c github.com/stretchr/testify v1.8.0 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 @@ -238,8 +238,8 @@ require ( github.com/stretchr/objx v0.4.0 // indirect github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 // indirect github.com/tj/go-spin v1.1.0 // indirect - github.com/tklauser/go-sysconf v0.3.9 // indirect - github.com/tklauser/numcpus v0.3.0 // indirect + github.com/tklauser/go-sysconf v0.3.10 // indirect + github.com/tklauser/numcpus v0.4.0 // indirect github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/vishvananda/netlink v1.1.0 // indirect diff --git a/go.sum b/go.sum index 8a1a5e11e18..068d95521a4 100644 --- a/go.sum +++ b/go.sum @@ -531,8 +531,8 @@ github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5O github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= -github.com/hashicorp/go-set v0.1.4 h1:LADVZzgPFLNI20TII1l75bnBI0LTnxpoCOPNjozNpi8= -github.com/hashicorp/go-set v0.1.4/go.mod h1:XFMEKCP3rGoZUBvdYwC9k2YVDj8PsMU/B0ITuYkl8IA= +github.com/hashicorp/go-set v0.1.6 h1:fj/JG5B97sAOd9OQN4GL880yCE384fz3asNDpGbxkPo= +github.com/hashicorp/go-set v0.1.6/go.mod h1:ELvMcE+1mRHYPVgTFSQiecObIwZRxY5Q11EhbtmM5KQ= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= @@ -840,11 +840,11 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20200314001724-bdab42bd5128/go.mod github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.21.12 h1:VoGxEW2hpmz0Vt3wUvHIl9fquzYLNpVpgNNB7pGJimA= -github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA= +github.com/shirou/gopsutil/v3 v3.22.7 h1:flKnuCMfUUrO+oAvwAd6GKZgnPzr098VA/UJ14nhJd4= +github.com/shirou/gopsutil/v3 v3.22.7/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shoenig/test v0.3.1 h1:dhGZztS6nQuvJ0o0RtUiQHaEO4hhArh/WmWwik3Ols0= -github.com/shoenig/test v0.3.1/go.mod h1:xYtyGBC5Q3kzCNyJg/SjgNpfAa2kvmgA0i5+lQso8x0= +github.com/shoenig/test v0.4.0 h1:3X4xG/Chx7mzi0h71Sm6Vo38q0EYaQIBZpYFRcA1HVM= +github.com/shoenig/test v0.4.0/go.mod h1:xYtyGBC5Q3kzCNyJg/SjgNpfAa2kvmgA0i5+lQso8x0= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= @@ -889,10 +889,10 @@ github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6 github.com/tencentcloud/tencentcloud-sdk-go v1.0.162/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI= github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= -github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= -github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= -github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -1166,17 +1166,17 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/helper/boltdd/boltdd_test.go b/helper/boltdd/boltdd_test.go index 796015bd902..b3b45e55628 100644 --- a/helper/boltdd/boltdd_test.go +++ b/helper/boltdd/boltdd_test.go @@ -135,7 +135,7 @@ func TestBucket_DedupeWrites(t *testing.T) { // Assert there was at least 1 write origWrites := db.BoltDB().Stats().TxStats.Write - require.NotZero(origWrites) + must.Positive(t, origWrites) // Write the same values again and expect no new writes require.NoError(db.Update(func(tx *Tx) error { diff --git a/helper/funcs_test.go b/helper/funcs_test.go index 0ac8f3326c2..5c2ec62b661 100644 --- a/helper/funcs_test.go +++ b/helper/funcs_test.go @@ -64,7 +64,7 @@ func TestIsSubset(t *testing.T) { sub, offending := IsSubset(l, l[:1]) must.True(t, sub) - must.EmptySlice(t, offending) + must.SliceEmpty(t, offending) sub, offending = IsSubset(l, s) must.False(t, sub) @@ -77,7 +77,7 @@ func TestIsDisjoint(t *testing.T) { b := []string{"d", "f"} dis, offending := IsDisjoint(a, b) must.True(t, dis) - must.EmptySlice(t, offending) + must.SliceEmpty(t, offending) }) t.Run("no", func(t *testing.T) { diff --git a/nomad/acl_test.go b/nomad/acl_test.go index 867150639aa..dbdefde0883 100644 --- a/nomad/acl_test.go +++ b/nomad/acl_test.go @@ -130,5 +130,4 @@ func TestResolveSecretToken(t *testing.T) { if assert.NotNil(t, respToken) { assert.NotEmpty(t, respToken.AccessorID) } - } diff --git a/nomad/structs/config/vault.go b/nomad/structs/config/vault.go index 4deb4c2f743..81e2a2a1bfe 100644 --- a/nomad/structs/config/vault.go +++ b/nomad/structs/config/vault.go @@ -188,6 +188,11 @@ func (c *VaultConfig) Copy() *VaultConfig { return nc } +// Equal is a rename of Equals. +func (c *VaultConfig) Equal(b *VaultConfig) bool { + return c.Equals(b) +} + // Equals compares two Vault configurations and returns a boolean indicating // if they are equal. func (c *VaultConfig) Equals(b *VaultConfig) bool { diff --git a/nomad/structs/config/vault_test.go b/nomad/structs/config/vault_test.go index 6f5e2909c98..fb358ba8f21 100644 --- a/nomad/structs/config/vault_test.go +++ b/nomad/structs/config/vault_test.go @@ -101,7 +101,7 @@ func TestVaultConfig_Equals(t *testing.T) { TLSServerName: "1", } - must.Equals(t, c1, c2) + must.Equal(t, c1, c2) c3 := &VaultConfig{ Enabled: pointer.Of(true), @@ -137,5 +137,5 @@ func TestVaultConfig_Equals(t *testing.T) { TLSServerName: "1", } - must.NotEquals(t, c3, c4) + must.NotEqual(t, c3, c4) }