From 75d8abd5627b6d83796f97e0f4dae05eabf20f67 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 7 Mar 2019 11:51:39 +0100 Subject: [PATCH] UI: Add forking based on service instance id existence (#5392) * ui: Add forking based on service instance id existence Proxies come in 2 flavours, 'normal' and sidecar. We know when a proxy is a sidecar proxy based on whether a DestinationServiceID is set. LocalServiceAddress and LocalServicePort are only relevant for sidecar proxies. This adds template logic to show different text depending on this information. Additionally adds test around connect proxies (#5418) 1. Adds page object for the instance detail page 2. Adds further scenario steps used in the tests 3. Adds acceptance testing around the instance detail page. Services with proxies and the sidecar proxies and proxies themselves 4. Adds datacenter column for upstreams 5. Fixes bug routing bug for decision as to whether to request proxy information or not --- ui-v2/app/models/proxy.js | 2 +- ui-v2/app/routes/dc/services/instance.js | 6 +- ui-v2/app/services/repository/proxy.js | 6 +- ui-v2/app/services/repository/service.js | 10 ++- .../styles/components/tabular-collection.scss | 2 +- .../templates/components/healthcheck-list.hbs | 2 +- .../app/templates/dc/services/-upstreams.hbs | 18 +++-- ui-v2/app/templates/dc/services/instance.hbs | 11 ++- .../dc/services/instances/error.feature | 15 ++++ .../dc/services/instances/proxy.feature | 48 +++++++++++++ .../dc/services/instances/show.feature | 68 +++++++++++++++++++ .../services/instances/sidecar-proxy.feature | 29 ++++++++ .../dc/services/instances/with-proxy.feature | 20 ++++++ .../services/instances/with-sidecar.feature | 22 ++++++ .../dc/services/instances/error-steps.js | 10 +++ .../dc/services/instances/proxy-steps.js | 10 +++ .../steps/dc/services/instances/show-steps.js | 10 +++ .../services/instances/sidecar-proxy-steps.js | 10 +++ .../dc/services/instances/with-proxy-steps.js | 10 +++ .../services/instances/with-sidecar-steps.js | 10 +++ ui-v2/tests/helpers/type-to-url.js | 3 + ui-v2/tests/pages.js | 2 + ui-v2/tests/pages/dc/services/instance.js | 19 ++++++ ui-v2/tests/steps/assertions/dom.js | 6 ++ ui-v2/tests/steps/assertions/model.js | 5 +- ui-v2/tests/steps/assertions/page.js | 24 +++++-- ui-v2/yarn.lock | 6 +- 27 files changed, 356 insertions(+), 28 deletions(-) create mode 100644 ui-v2/tests/acceptance/dc/services/instances/error.feature create mode 100644 ui-v2/tests/acceptance/dc/services/instances/proxy.feature create mode 100644 ui-v2/tests/acceptance/dc/services/instances/show.feature create mode 100644 ui-v2/tests/acceptance/dc/services/instances/sidecar-proxy.feature create mode 100644 ui-v2/tests/acceptance/dc/services/instances/with-proxy.feature create mode 100644 ui-v2/tests/acceptance/dc/services/instances/with-sidecar.feature create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/error-steps.js create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/proxy-steps.js create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/show-steps.js create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/sidecar-proxy-steps.js create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/with-proxy-steps.js create mode 100644 ui-v2/tests/acceptance/steps/dc/services/instances/with-sidecar-steps.js create mode 100644 ui-v2/tests/pages/dc/services/instance.js diff --git a/ui-v2/app/models/proxy.js b/ui-v2/app/models/proxy.js index 9e0858219..3e4fb5822 100644 --- a/ui-v2/app/models/proxy.js +++ b/ui-v2/app/models/proxy.js @@ -8,5 +8,5 @@ export default Model.extend({ [SLUG_KEY]: attr('string'), ServiceName: attr('string'), ServiceID: attr('string'), - ServiceProxyDestination: attr('string'), + ServiceProxy: attr(), }); diff --git a/ui-v2/app/routes/dc/services/instance.js b/ui-v2/app/routes/dc/services/instance.js index b358fdd39..b4d0f1c5b 100644 --- a/ui-v2/app/routes/dc/services/instance.js +++ b/ui-v2/app/routes/dc/services/instance.js @@ -15,9 +15,9 @@ export default Route.extend({ }).then(function(model) { return hash({ proxy: - get(service, 'Kind') !== 'connect-proxy' - ? proxyRepo.findInstanceBySlug(params.id, params.name, dc) - : null, + get(model.item, 'Kind') === 'connect-proxy' + ? null + : proxyRepo.findInstanceBySlug(params.id, params.name, dc), ...model, }); }); diff --git a/ui-v2/app/services/repository/proxy.js b/ui-v2/app/services/repository/proxy.js index ce8c055d8..41f1207b4 100644 --- a/ui-v2/app/services/repository/proxy.js +++ b/ui-v2/app/services/repository/proxy.js @@ -22,7 +22,11 @@ export default RepositoryService.extend({ findInstanceBySlug: function(id, slug, dc, configuration) { return this.findAllBySlug(slug, dc, configuration).then(function(items) { if (get(items, 'length') > 0) { - const instance = items.findBy('ServiceProxyDestination', id); + let instance = items.findBy('ServiceProxy.DestinationServiceID', id); + if (instance) { + return instance; + } + instance = items.findBy('ServiceProxy.DestinationServiceName', slug); if (instance) { return instance; } diff --git a/ui-v2/app/services/repository/service.js b/ui-v2/app/services/repository/service.js index 2da90a3c7..61ef1d61c 100644 --- a/ui-v2/app/services/repository/service.js +++ b/ui-v2/app/services/repository/service.js @@ -35,7 +35,15 @@ export default RepositoryService.extend({ }); return service; } - // TODO: probably need to throw a 404 here? + // TODO: Add an store.error("404", "message") or similar + const e = new Error(); + e.errors = [ + { + status: '404', + title: 'Unable to find instance', + }, + ]; + throw e; }); }, }); diff --git a/ui-v2/app/styles/components/tabular-collection.scss b/ui-v2/app/styles/components/tabular-collection.scss index 53d6678ef..d26b72e65 100644 --- a/ui-v2/app/styles/components/tabular-collection.scss +++ b/ui-v2/app/styles/components/tabular-collection.scss @@ -181,5 +181,5 @@ html.template-node.template-show main table.sessions tr { width: calc(100% / 5); } %upstreams-row > * { - width: calc(100% / 3); + width: calc(100% / 4); } diff --git a/ui-v2/app/templates/components/healthcheck-list.hbs b/ui-v2/app/templates/components/healthcheck-list.hbs index 4b5774588..babca35d7 100644 --- a/ui-v2/app/templates/components/healthcheck-list.hbs +++ b/ui-v2/app/templates/components/healthcheck-list.hbs @@ -1,4 +1,4 @@ -