From 5debc74fa2909a7de24a07ed3155e341a5af22b3 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 5 Aug 2019 17:31:27 +0200 Subject: [PATCH] ui: Enable blocking queries by default (#6194) -Enable blocking queries by default -Change assertion to check for the last PUT request, not just any request for session destruction from a node page. Since we've now turned on blocking queries by default this means that a second GET request is made after the PUT request that we are asserting for but before the assertion itself, this meant the assertion failed. We double checked this by turning off blocking queries for this test using ``` And settings from yaml --- consul:client: blocking: 0 --- ``` which made the test pass again. As moving forwards blocking queries will be on by default, we didn't want to disable blocking queries for this test, so we now assert the last PUT request specifically. This means we continue to assert that the session has been destroyed but means we don't get into problems of ordering of requests here --- ui-v2/app/controllers/settings.js | 3 --- ui-v2/app/routes/settings.js | 5 ++++- ui-v2/app/services/repository/type/event-source.js | 2 +- ui-v2/tests/acceptance/dc/list-blocking.feature | 7 +------ .../tests/acceptance/dc/nodes/sessions/invalidate.feature | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ui-v2/app/controllers/settings.js b/ui-v2/app/controllers/settings.js index 8bb96673cd..7f0df20d36 100644 --- a/ui-v2/app/controllers/settings.js +++ b/ui-v2/app/controllers/settings.js @@ -34,9 +34,6 @@ export default Controller.extend({ const blocking = get(this, 'item.client.blocking'); switch (target.name) { case 'client[blocking]': - if (typeof blocking === 'undefined') { - set(this, 'item.client', {}); - } set(this, 'item.client.blocking', !blocking); this.send('update', get(this, 'item')); break; diff --git a/ui-v2/app/routes/settings.js b/ui-v2/app/routes/settings.js index d62cb6b9c8..567f5040cb 100644 --- a/ui-v2/app/routes/settings.js +++ b/ui-v2/app/routes/settings.js @@ -1,7 +1,7 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; import { hash } from 'rsvp'; -import { get } from '@ember/object'; +import { get, set } from '@ember/object'; export default Route.extend({ client: service('client/http'), @@ -12,6 +12,9 @@ export default Route.extend({ item: get(this, 'repo').findAll(), dcs: get(this, 'dcRepo').findAll(), }).then(model => { + if (typeof get(model.item, 'client.blocking') === 'undefined') { + set(model, 'item.client', { blocking: true }); + } return hash({ ...model, ...{ diff --git a/ui-v2/app/services/repository/type/event-source.js b/ui-v2/app/services/repository/type/event-source.js index 31c1b41ea9..7f45c0686f 100644 --- a/ui-v2/app/services/repository/type/event-source.js +++ b/ui-v2/app/services/repository/type/event-source.js @@ -65,7 +65,7 @@ const createProxy = function(repo, find, settings, cache, serialize = JSON.strin key: key, type: BlockingEventSource, settings: { - enabled: settings.blocking, + enabled: typeof settings.blocking === 'undefined' || settings.blocking, }, createEvent: createEvent, } diff --git a/ui-v2/tests/acceptance/dc/list-blocking.feature b/ui-v2/tests/acceptance/dc/list-blocking.feature index 7413ae8a7b..74e8f34bb6 100644 --- a/ui-v2/tests/acceptance/dc/list-blocking.feature +++ b/ui-v2/tests/acceptance/dc/list-blocking.feature @@ -5,11 +5,6 @@ Feature: dc / list-blocking I want to see changes if I change consul externally Background: Given 1 datacenter model with the value "dc-1" - And settings from yaml - --- - consul:client: - blocking: 1 - --- Scenario: Viewing the listing pages Given 3 [Model] models And a network latency of 100 @@ -51,4 +46,4 @@ Feature: dc / list-blocking ------------------------------------------------- | Page | Model | Url | | service | instance | services/service-0 | - ------------------------------------------------- \ No newline at end of file + ------------------------------------------------- diff --git a/ui-v2/tests/acceptance/dc/nodes/sessions/invalidate.feature b/ui-v2/tests/acceptance/dc/nodes/sessions/invalidate.feature index ba2288a38a..6ac9a7a2f1 100644 --- a/ui-v2/tests/acceptance/dc/nodes/sessions/invalidate.feature +++ b/ui-v2/tests/acceptance/dc/nodes/sessions/invalidate.feature @@ -25,7 +25,7 @@ Feature: dc / nodes / sessions / invalidate: Invalidate Lock Sessions Scenario: Invalidating the lock session And I click delete on the sessions And I click confirmDelete on the sessions - Then a PUT request is made to "/v1/session/destroy/7bbbd8bb-fff3-4292-b6e3-cfedd788546a?dc=dc1" + Then the last PUT request was made to "/v1/session/destroy/7bbbd8bb-fff3-4292-b6e3-cfedd788546a?dc=dc1" Then the url should be /dc1/nodes/node-0 And "[data-notification]" has the "notification-delete" class And "[data-notification]" has the "success" class