mirror of
https://github.com/status-im/consul.git
synced 2025-02-18 08:36:46 +00:00
Sort slice of ServiceNames deterministically
This commit is contained in:
parent
a5fe2125e9
commit
62ed0250c3
@ -353,7 +353,9 @@ func (s *Store) ExportedServicesForAllPeersByName(ws memdb.WatchSet, entMeta acl
|
|||||||
}
|
}
|
||||||
m := list.ListAllDiscoveryChains()
|
m := list.ListAllDiscoveryChains()
|
||||||
if len(m) > 0 {
|
if len(m) > 0 {
|
||||||
out[peering.Name] = maps.SliceOfKeys(m)
|
sns := maps.SliceOfKeys[structs.ServiceName, structs.ExportedDiscoveryChainInfo](m)
|
||||||
|
sort.Sort(structs.ServiceList(sns))
|
||||||
|
out[peering.Name] = sns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/hashicorp/consul/agent/proxycfg"
|
"github.com/hashicorp/consul/agent/proxycfg"
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/consul/proto/pbpeering"
|
"github.com/hashicorp/consul/proto/pbpeering"
|
||||||
|
"github.com/hashicorp/consul/sdk/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServerExportedPeeredServices(t *testing.T) {
|
func TestServerExportedPeeredServices(t *testing.T) {
|
||||||
@ -59,7 +60,7 @@ func TestServerExportedPeeredServices(t *testing.T) {
|
|||||||
})
|
})
|
||||||
require.NoError(t, dataSource.Notify(ctx, &structs.DCSpecificRequest{}, "", eventCh))
|
require.NoError(t, dataSource.Notify(ctx, &structs.DCSpecificRequest{}, "", eventCh))
|
||||||
|
|
||||||
t.Run("initial state", func(t *testing.T) {
|
testutil.RunStep(t, "initial state", func(t *testing.T) {
|
||||||
result := getEventResult[*structs.IndexedExportedServiceList](t, eventCh)
|
result := getEventResult[*structs.IndexedExportedServiceList](t, eventCh)
|
||||||
require.Equal(t,
|
require.Equal(t,
|
||||||
map[string]structs.ServiceList{
|
map[string]structs.ServiceList{
|
||||||
@ -69,7 +70,7 @@ func TestServerExportedPeeredServices(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("update exported services", func(t *testing.T) {
|
testutil.RunStep(t, "update exported services", func(t *testing.T) {
|
||||||
require.NoError(t, store.EnsureConfigEntry(nextIndex(), &structs.ExportedServicesConfigEntry{
|
require.NoError(t, store.EnsureConfigEntry(nextIndex(), &structs.ExportedServicesConfigEntry{
|
||||||
Name: "default",
|
Name: "default",
|
||||||
Services: []structs.ExportedService{
|
Services: []structs.ExportedService{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user