From 4c2a5c31dc04436499c1b9d28c18b8289adcd10d Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Thu, 13 Oct 2022 10:36:12 +0200 Subject: [PATCH] Update peering mocks --- .../mock-api/v1/internal/ui/exported-services | 31 +++++++++++++++++++ ui/packages/consul-ui/mock-api/v1/peering/_ | 9 ++++-- ui/packages/consul-ui/mock-api/v1/peerings | 4 +-- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 ui/packages/consul-ui/mock-api/v1/internal/ui/exported-services diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/exported-services b/ui/packages/consul-ui/mock-api/v1/internal/ui/exported-services new file mode 100644 index 000000000..8bfe71254 --- /dev/null +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/exported-services @@ -0,0 +1,31 @@ + +${[0].map( + () => { + let prevKind; + let name; + const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway']; + return ` +[ + ${ + range( + env( + 'CONSUL_SERVICE_COUNT', + Math.floor( + ( + Math.random() * env('CONSUL_SERVICE_MAX', 10) + ) + parseInt(env('CONSUL_SERVICE_MIN', 1)) + ) + ) + ).map( + function(item, i) + { + return ` + { + "Name": "service-${i}" + } + `; + } + ) + } +] +`})} diff --git a/ui/packages/consul-ui/mock-api/v1/peering/_ b/ui/packages/consul-ui/mock-api/v1/peering/_ index 46c1a1af2..306990c9c 100644 --- a/ui/packages/consul-ui/mock-api/v1/peering/_ +++ b/ui/packages/consul-ui/mock-api/v1/peering/_ @@ -1,7 +1,5 @@ { "ID": "${fake.random.uuid()}", - "ImportedServiceCount": ${fake.random.number({min: 0, max: 4000})}, - "ExportedServiceCount": ${fake.random.number({min: 0, max: 4000})}, "Name": "${location.pathname.get(2)}", "State": "${fake.helpers.randomize([ 'ACTIVE', @@ -12,6 +10,13 @@ 'TERMINATED', 'UNDEFINED' ])}", + "StreamStatus": { + "LastHeartbeat": "${fake.date.past(10).toISOString()}", + "LastReceive": "${fake.date.past(10).toISOString()}", + "LastSend": "${fake.date.past(10).toISOString()}", + "ExportedServices": [${range(0, Math.floor(Math.random() * 10)).map((i) => `"exported-service-${i}"`)}], + "ImportedServices": [${range(0, Math.floor(Math.random() * 10)).map((i) => `"imported-service-${i}"`)}] + }, "PeerID": "${fake.random.uuid()}", "PeerServerName": "${fake.internet.domainName()}", "PeerServerAddresses": [ diff --git a/ui/packages/consul-ui/mock-api/v1/peerings b/ui/packages/consul-ui/mock-api/v1/peerings index f240e49d2..059fc83f3 100644 --- a/ui/packages/consul-ui/mock-api/v1/peerings +++ b/ui/packages/consul-ui/mock-api/v1/peerings @@ -22,8 +22,8 @@ "LastHeartbeat": "${fake.date.past(10).toISOString()}", "LastReceive": "${fake.date.past(10).toISOString()}", "LastSend": "${fake.date.past(10).toISOString()}", - "ExportedServices": ["${`export-service-${i}`}"], - "ImportedServices": ["${`import-service-${i}`}"] + "ExportedServices": [${range(0, Math.floor(Math.random() * 10)).map((i) => `"exported-service-${i}"`)}], + "ImportedServices": [${range(0, Math.floor(Math.random() * 10)).map((i) => `"imported-service-${i}"`)}] }, "PeerID": "${id}", "PeerServerName": "${fake.internet.domainName()}",