Skip to content

Commit a6e4e94

Browse files
authored
Merge pull request #2200 from CodeNow/SAN-5818-rerun-containers
San 5818 rerun containers
2 parents 93a6cc5 + 9927015 commit a6e4e94

4 files changed

Lines changed: 54 additions & 1 deletion

File tree

client/directives/components/containerStatusButton/containerStatusButtonController.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function ContainerStatusButtonController(
1414
keypather,
1515
loading,
1616
promisify,
17+
redeployClusterMasterInstance,
1718
updateInstanceWithNewAcvData,
1819
updateInstanceWithNewBuild
1920
) {
@@ -56,6 +57,21 @@ function ContainerStatusButtonController(
5657
restartInstance: function () {
5758
modInstance('restart');
5859
},
60+
redeployCluster: function () {
61+
$rootScope.$broadcast('close-popovers');
62+
loading('main', true);
63+
var instance = CSBC.instance;
64+
var instanceId = keypather.get(instance, 'attrs.id');
65+
return redeployClusterMasterInstance(instanceId)
66+
.catch(errs.handler)
67+
.finally(function () {
68+
loading('main', false);
69+
return $state.go('base.instances.instance', {
70+
instanceName: $state.params.instanceName,
71+
userName: $state.params.userName
72+
});
73+
});
74+
},
5975
rebuildWithoutCache: function () {
6076
$rootScope.$broadcast('close-popovers');
6177
loading('main', true);

client/directives/components/containerStatusButton/containerStatusOptionsPopoverView.jade

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
.icons-status.green
2020
| Restart
2121

22+
li.popover-list-item(
23+
ng-if = "!$root.featureFlags.testMenu && !CSBC.instance.attrs.masterPod && !CSBC.instance.isMigrating() && CSBC.isTesting()"
24+
ng-click = "actions.redeployCluster()"
25+
)
26+
.icons-status.green
27+
| Rerun tests
28+
2229
li.popover-list-item(
2330
ng-if = "$root.featureFlags.internalDebugging"
2431
ng-click = "CSBC.instance.redeploy(angular.noop)"

client/services/createNewCluster.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
require('app')
4-
.factory('createNewCluster', createNewCluster);
4+
.factory('createNewCluster', createNewCluster)
5+
.factory('redeployClusterMasterInstance', redeployClusterMasterInstance);
56

67
function createNewCluster(
78
$http,
@@ -25,3 +26,19 @@ function createNewCluster(
2526
});
2627
};
2728
}
29+
30+
function redeployClusterMasterInstance(
31+
$http,
32+
configAPIHost
33+
) {
34+
return function (instanceId) {
35+
var data = {
36+
instanceId: instanceId
37+
};
38+
return $http({
39+
method: 'POST',
40+
url: configAPIHost + '/docker-compose-cluster/redeploy',
41+
data: data
42+
});
43+
};
44+
}

test/unit/directives/components/containerStatusButton/containerStatusButtonController.unit.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var keypather;
77
var $q;
88
var CSBC;
99
var apiMocks = require('./../../../apiMocks/index');
10+
var redeployClusterMasterInstanceStub;
1011

1112
describe('containerStatusButtonController'.bold.underline.blue, function () {
1213
var ctx;
@@ -37,6 +38,10 @@ describe('containerStatusButtonController'.bold.underline.blue, function () {
3738
});
3839
return promisifyMock;
3940
});
41+
$provide.factory('redeployClusterMasterInstance', function ($q) {
42+
redeployClusterMasterInstanceStub = sinon.stub().returns($q.when({}));
43+
return redeployClusterMasterInstanceStub
44+
});
4045
});
4146
angular.mock.inject(function (
4247
_$controller_,
@@ -159,6 +164,14 @@ describe('containerStatusButtonController'.bold.underline.blue, function () {
159164
sinon.assert.calledOnce(closePopoversListener);
160165
});
161166

167+
it('should allow the user to redeploy a test cluster', function () {
168+
keypather.set(CSBC.instance, 'attrs.id', 'runnable.rocks!');
169+
var $state
170+
CSBC.actions.redeployCluster();
171+
sinon.assert.calledWith(redeployClusterMasterInstanceStub, 'runnable.rocks!');
172+
sinon.assert.calledOnce(closePopoversListener);
173+
})
174+
162175
it('should allow the user to update the configuration to match master', function () {
163176
var mainAcv = {
164177
args: {

0 commit comments

Comments
 (0)