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, CorrelationID: envoyConfigPatchesID,
Result: structs.IndexedConfigEntries{ Result: &structs.IndexedConfigEntries{
Kind: structs.EnvoyPatchSet,
Entries: []structs.ConfigEntry{envoyPatchSet}, Entries: []structs.ConfigEntry{envoyPatchSet},
}, },
Err: nil, Err: nil,
}, },
{ {
CorrelationID: envoyConfigApplicationID, CorrelationID: envoyConfigApplicationID,
Result: structs.IndexedConfigEntries{ Result: &structs.IndexedConfigEntries{
Kind: structs.ApplyEnvoyPatchSet,
Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication}, Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication},
}, },
Err: nil, Err: nil,
@ -1660,14 +1662,14 @@ func TestState_WatchesAndUpdates(t *testing.T) {
events: []cache.UpdateEvent{ events: []cache.UpdateEvent{
{ {
CorrelationID: envoyConfigPatchesID, CorrelationID: envoyConfigPatchesID,
Result: structs.IndexedConfigEntries{ Result: &structs.IndexedConfigEntries{
Entries: []structs.ConfigEntry{envoyPatchSet}, Entries: []structs.ConfigEntry{envoyPatchSet},
}, },
Err: nil, Err: nil,
}, },
{ {
CorrelationID: envoyConfigApplicationID, CorrelationID: envoyConfigApplicationID,
Result: structs.IndexedConfigEntries{ Result: &structs.IndexedConfigEntries{
Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication}, Entries: []structs.ConfigEntry{serviceEnvoyPatchSetApplication, envoyPatchSetApplication},
}, },
Err: nil, 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) configEntries, ok := u.Result.(*structs.IndexedConfigEntries)
if !ok { 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) 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) envoyConfigPatch, ok := e.(*structs.EnvoyPatchSetConfigEntry)
if !ok { 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 patchSet[envoyConfigPatch.GetEnvoyPatchSetIdentifier()] = envoyConfigPatch
} }

3
agent/proxycfg/testing.go

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

Loading…
Cancel
Save