Commit 8e7f2b0a authored by Phil Hughes's avatar Phil Hughes

Merge branch 'ashmckenzie/7708-allow-geo-node-removal' into 'master'

Geo: Allow nodes to be editable in more scenarios

See merge request gitlab-org/gitlab-ee!7832
parents 67d06dcf 18d0850c
......@@ -108,19 +108,15 @@ export default {
eventHub.$emit('nodeDetailsLoaded', this.store.getNodeDetails(nodeId));
})
.catch(err => {
if (err.response && err.response.data) {
this.store.setNodeDetails(nodeId, {
geo_node_id: nodeId,
health: err.message,
health_status: 'Unknown',
missing_oauth_application: false,
sync_status_unavailable: true,
storage_shards_match: null,
});
eventHub.$emit('nodeDetailsLoaded', this.store.getNodeDetails(nodeId));
} else {
eventHub.$emit('nodeDetailsLoadFailed', nodeId, err);
}
this.store.setNodeDetails(nodeId, {
geo_node_id: nodeId,
health: err.message,
health_status: 'Unknown',
missing_oauth_application: null,
sync_status_unavailable: true,
storage_shards_match: null,
});
eventHub.$emit('nodeDetailsLoaded', this.store.getNodeDetails(nodeId));
});
},
repairNode(targetNode) {
......
......@@ -46,14 +46,12 @@ export default {
},
created() {
eventHub.$on('nodeDetailsLoaded', this.handleNodeDetails);
eventHub.$on('nodeDetailsLoadFailed', this.handleNodeDetailsFailure);
},
mounted() {
this.handleMounted();
},
beforeDestroy() {
eventHub.$off('nodeDetailsLoaded', this.handleNodeDetails);
eventHub.$off('nodeDetailsLoadFailed', this.handleNodeDetailsFailure);
},
methods: {
handleNodeDetails(nodeDetails) {
......@@ -65,13 +63,6 @@ export default {
this.nodeHealthStatus = nodeDetails.health;
}
},
handleNodeDetailsFailure(nodeId, err) {
if (this.node.id === nodeId) {
this.isNodeDetailsLoading = false;
this.isNodeDetailsFailed = true;
this.errorMessage = err.message;
}
},
handleMounted() {
eventHub.$emit('pollNodeDetails', this.node);
},
......
---
title: 'Geo: Allow nodes to be editable in more scenarios'
merge_request: 7832
author:
type: changed
......@@ -156,9 +156,9 @@ describe('AppComponent', () => {
.catch(done.fail);
});
it('emits `nodeDetailsLoaded` event with fake nodeDetails object on 500 failure', done => {
it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a network error occurs', done => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(500, {});
mock.onGet(mockNode.statusPath).networkError();
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm
......@@ -168,26 +168,25 @@ describe('AppComponent', () => {
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
expect(nodeDetails.syncStatusUnavailable).toBe(true);
expect(nodeDetails.health).toBe('Request failed with status code 500');
expect(nodeDetails.health).toBe('Network Error');
})
.then(done)
.catch(done.fail);
});
it('emits `nodeDetailsLoadFailed` event on failure when there is no response', done => {
it('emits `nodeDetailsLoaded` event with fake nodeDetails object when a timeout occurs', done => {
spyOn(eventHub, '$emit');
mock.onGet(mockNode.statusPath).reply(500, null);
mock.onGet(mockNode.statusPath).timeout();
spyOn(vm.service, 'getGeoNodeDetails').and.callThrough();
vm
.fetchNodeDetails(mockNode)
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith(
'nodeDetailsLoadFailed',
mockNode.id,
jasmine.any(Object),
);
done();
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Object));
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
expect(nodeDetails.syncStatusUnavailable).toBe(true);
expect(nodeDetails.health).toBe('timeout of 0ms exceeded');
})
.then(done)
.catch(done.fail);
......
......@@ -99,16 +99,6 @@ describe('GeoNodeItemComponent', () => {
});
});
describe('handleNodeDetailsFailure', () => {
it('initializes props for Node details failure', () => {
const err = 'Something went wrong';
vm.handleNodeDetailsFailure(1, { message: err });
expect(vm.isNodeDetailsLoading).toBeFalsy();
expect(vm.isNodeDetailsFailed).toBeTruthy();
expect(vm.errorMessage).toBe(err);
});
});
describe('handleMounted', () => {
it('emits `pollNodeDetails` event and passes node ID', () => {
spyOn(eventHub, '$emit');
......@@ -125,7 +115,6 @@ describe('GeoNodeItemComponent', () => {
const vmX = createComponent();
expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoadFailed', jasmine.any(Function));
vmX.$destroy();
});
});
......@@ -137,7 +126,6 @@ describe('GeoNodeItemComponent', () => {
const vmX = createComponent();
vmX.$destroy();
expect(eventHub.$off).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('nodeDetailsLoadFailed', jasmine.any(Function));
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment