Vet/race fixes (#4421)
This addresses all found vet/race fixes in community edition. --------- Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
This commit is contained in:
1 parent
4535af25aa
commit
014a5a7aae
46 files changed
+411
-176
No files matched your search
@@ -61,7 +61,7 @@ type Manager interface {
|
||||
|
||||
type manager struct {
|
||||
controllerSessionConn pbs.SessionServiceClient
|
||||
sessionMap sync.Map
|
||||
sessionMap *sync.Map
|
||||
}
|
||||
|
||||
var _ Manager = (*manager)(nil)
|
||||
@@ -74,6 +74,7 @@ func NewManager(client pbs.SessionServiceClient) (*manager, error) {
|
||||
}
|
||||
return &manager{
|
||||
controllerSessionConn: client,
|
||||
sessionMap: new(sync.Map),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
sessionCloseInfo map[string][]*pbs.CloseConnectionResponseData
|
||||
sessionInfoMap func() sync.Map
|
||||
sessionInfoMap func() *sync.Map
|
||||
expected []string
|
||||
expectedClosed map[string]struct{}
|
||||
expectedErr []error
|
||||
@@ -288,8 +288,8 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
{ConnectionId: "bar", Status: pbs.CONNECTIONSTATUS_CONNECTIONSTATUS_CLOSED},
|
||||
},
|
||||
},
|
||||
sessionInfoMap: func() sync.Map {
|
||||
var m sync.Map
|
||||
sessionInfoMap: func() *sync.Map {
|
||||
m := new(sync.Map)
|
||||
m.Store("one", &sess{
|
||||
resp: &pbs.LookupSessionResponse{Authorization: &targets.SessionAuthorizationData{
|
||||
SessionId: "one",
|
||||
@@ -333,8 +333,8 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
{ConnectionId: "bar", Status: pbs.CONNECTIONSTATUS_CONNECTIONSTATUS_CONNECTED},
|
||||
},
|
||||
},
|
||||
sessionInfoMap: func() sync.Map {
|
||||
var m sync.Map
|
||||
sessionInfoMap: func() *sync.Map {
|
||||
m := new(sync.Map)
|
||||
m.Store("one", &sess{
|
||||
resp: &pbs.LookupSessionResponse{Authorization: &targets.SessionAuthorizationData{
|
||||
SessionId: "one",
|
||||
@@ -369,8 +369,8 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
{ConnectionId: "bar", Status: pbs.CONNECTIONSTATUS_CONNECTIONSTATUS_CLOSED},
|
||||
},
|
||||
},
|
||||
sessionInfoMap: func() sync.Map {
|
||||
var m sync.Map
|
||||
sessionInfoMap: func() *sync.Map {
|
||||
m := new(sync.Map)
|
||||
m.Store("one", &sess{
|
||||
resp: &pbs.LookupSessionResponse{Authorization: &targets.SessionAuthorizationData{
|
||||
SessionId: "one",
|
||||
@@ -400,8 +400,8 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
{ConnectionId: "bar", Status: pbs.CONNECTIONSTATUS_CONNECTIONSTATUS_CLOSED},
|
||||
},
|
||||
},
|
||||
sessionInfoMap: func() sync.Map {
|
||||
var m sync.Map
|
||||
sessionInfoMap: func() *sync.Map {
|
||||
m := new(sync.Map)
|
||||
m.Store("one", &sess{
|
||||
resp: &pbs.LookupSessionResponse{Authorization: &targets.SessionAuthorizationData{
|
||||
SessionId: "one",
|
||||
@@ -431,8 +431,8 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
{
|
||||
name: "empty",
|
||||
sessionCloseInfo: make(map[string][]*pbs.CloseConnectionResponseData),
|
||||
sessionInfoMap: func() sync.Map {
|
||||
var m sync.Map
|
||||
sessionInfoMap: func() *sync.Map {
|
||||
m := new(sync.Map)
|
||||
m.Store("one", &sess{
|
||||
resp: &pbs.LookupSessionResponse{Authorization: &targets.SessionAuthorizationData{
|
||||
SessionId: "one",
|
||||
@@ -453,7 +453,7 @@ func TestWorkerSetCloseTimeForResponse(t *testing.T) {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
manager := &manager{}
|
||||
manager := &manager{sessionMap: new(sync.Map)}
|
||||
manager.sessionMap = tc.sessionInfoMap()
|
||||
actual, actualErr := setCloseTimeForResponse(manager, tc.sessionCloseInfo)
|
||||
|
||||
|
||||
Reference in new issue
Block a user