Browse Source

fix remaining tests

add-patches
Eric 3 years ago
parent
commit
25287944f2
  1. 10
      agent/proxycfg/state_test.go
  2. 4
      agent/proxycfg/terminating_gateway.go
  3. 3
      agent/proxycfg/testing.go

10
agent/proxycfg/state_test.go

@ -657,14 +657,16 @@ func TestState_WatchesAndUpdates(t *testing.T) {
},
{
CorrelationID: envoyConfigPatchesID,
Result: structs.IndexedConfigEntries{
Result: &structs.IndexedConfigEntries{
Kind: structs.EnvoyPatchSet,
Entries: []structs.ConfigEntry{envoyPatchSet},
},
Err: nil,
},
{
CorrelationID: envoyConfigApplicationID,
Result: structs.IndexedConfigEntries{
Result: &structs.IndexedConfigEntries{
Kind: structs.ApplyEnvoyPatchSet,
Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication},
},
Err: nil,
@ -1660,14 +1662,14 @@ func TestState_WatchesAndUpdates(t *testing.T) {
events: []cache.UpdateEvent{
{
CorrelationID: envoyConfigPatchesID,
Result: structs.IndexedConfigEntries{
Result: &structs.IndexedConfigEntries{
Entries: []structs.ConfigEntry{envoyPatchSet},
},
Err: nil,
},
{
CorrelationID: envoyConfigApplicationID,
Result: structs.IndexedConfigEntries{
Result: &structs.IndexedConfigEntries{
Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication},
},
Err: nil,

4
agent/proxycfg/terminating_gateway.go

@ -99,7 +99,7 @@ func (s *handlerTerminatingGateway) handleUpdate(ctx context.Context, u cache.Up
configEntries, ok := u.Result.(*structs.IndexedConfigEntries)
if !ok {
return fmt.Errorf("invalid type for response thingy: %T, %+v", u.Result, u.Result)
return fmt.Errorf("invalid type for response thingy: %T", u.Result)
}
patchSet := make(map[structs.ApplyEnvoyPatchSetIdentifier]*structs.EnvoyPatchSetConfigEntry)
@ -107,7 +107,7 @@ func (s *handlerTerminatingGateway) handleUpdate(ctx context.Context, u cache.Up
envoyConfigPatch, ok := e.(*structs.EnvoyPatchSetConfigEntry)
if !ok {
return fmt.Errorf("invalid type for response stuff: %T, %+v", u.Result, u.Result)
return fmt.Errorf("invalid type for response stuff: %T", u.Result)
}
patchSet[envoyConfigPatch.GetEnvoyPatchSetIdentifier()] = envoyConfigPatch
}

3
agent/proxycfg/testing.go

@ -33,6 +33,7 @@ type TestCacheTypes struct {
query *ControllableCacheType
compiledChain *ControllableCacheType
serviceHTTPChecks *ControllableCacheType
configEntries *ControllableCacheType
}
// NewTestCacheTypes creates a set of ControllableCacheTypes for all types that
@ -47,6 +48,7 @@ func NewTestCacheTypes(t testing.T) *TestCacheTypes {
query: NewControllableCacheType(t),
compiledChain: NewControllableCacheType(t),
serviceHTTPChecks: NewControllableCacheType(t),
configEntries: NewControllableCacheType(t),
}
ct.query.blocking = false
return ct
@ -63,6 +65,7 @@ func TestCacheWithTypes(t testing.T, types *TestCacheTypes) *cache.Cache {
c.RegisterType(cachetype.PreparedQueryName, types.query)
c.RegisterType(cachetype.CompiledDiscoveryChainName, types.compiledChain)
c.RegisterType(cachetype.ServiceHTTPChecksName, types.serviceHTTPChecks)
c.RegisterType(cachetype.ConfigEntriesName, types.configEntries)
return c
}

Loading…
Cancel
Save