|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
describe('startContainerController', function () {
|
|
|
|
|
describe('startContainerController', function() {
|
|
|
|
|
var scope, $location, createController, mockContainer, $httpBackend;
|
|
|
|
|
|
|
|
|
|
beforeEach(angular.mock.module('dockerui'));
|
|
|
|
|
|
|
|
|
|
beforeEach(inject(function ($rootScope, $controller, _$location_) {
|
|
|
|
|
beforeEach(inject(function($rootScope, $controller, _$location_) {
|
|
|
|
|
$location = _$location_;
|
|
|
|
|
scope = $rootScope.$new();
|
|
|
|
|
|
|
|
|
@ -13,13 +13,13 @@ describe('startContainerController', function () {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
angular.mock.inject(function (_Container_, _$httpBackend_) {
|
|
|
|
|
angular.mock.inject(function(_Container_, _$httpBackend_) {
|
|
|
|
|
mockContainer = _Container_;
|
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
describe('Create and start a container with port bindings', function () {
|
|
|
|
|
describe('Create and start a container with port bindings', function() {
|
|
|
|
|
it('should issue a correct create request to the Docker remote API', function() {
|
|
|
|
|
var controller = createController();
|
|
|
|
|
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
|
|
|
@ -29,19 +29,90 @@ describe('startContainerController', function () {
|
|
|
|
|
"MemorySwap": 0,
|
|
|
|
|
"CpuShares": 1024,
|
|
|
|
|
"Cmd": null,
|
|
|
|
|
"VolumesFrom": "",
|
|
|
|
|
"VolumesFrom": [],
|
|
|
|
|
"Env": [],
|
|
|
|
|
"ExposedPorts":{
|
|
|
|
|
"ExposedPorts": {
|
|
|
|
|
"9000/tcp": {},
|
|
|
|
|
},
|
|
|
|
|
"HostConfig": {
|
|
|
|
|
"PortBindings":{
|
|
|
|
|
"PortBindings": {
|
|
|
|
|
"9000/tcp": [{
|
|
|
|
|
"HostPort": "9999",
|
|
|
|
|
"HostIp": "10.20.10.15",
|
|
|
|
|
}]
|
|
|
|
|
},
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectGET('/dockerapi/containers/json?all=1').respond([{
|
|
|
|
|
"Command": "./dockerui -e /docker.sock",
|
|
|
|
|
"Created": 1421817232,
|
|
|
|
|
"Id": "b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f",
|
|
|
|
|
"Image": "dockerui:latest",
|
|
|
|
|
"Names": ["/dockerui"],
|
|
|
|
|
"Ports": [{
|
|
|
|
|
"IP": "0.0.0.0",
|
|
|
|
|
"PrivatePort": 9000,
|
|
|
|
|
"PublicPort": 9000,
|
|
|
|
|
"Type": "tcp"
|
|
|
|
|
}],
|
|
|
|
|
"Status": "Up 2 minutes"
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectPOST('/dockerapi/containers/create?name=container-name', expectedBody).respond({
|
|
|
|
|
"Id": id,
|
|
|
|
|
"Warnings": null
|
|
|
|
|
});
|
|
|
|
|
$httpBackend.expectPOST('/dockerapi/containers/' + id + '/start?').respond({
|
|
|
|
|
"Id": id,
|
|
|
|
|
"Warnings": null
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
scope.config.name = 'container-name';
|
|
|
|
|
scope.config.portBindings = [{
|
|
|
|
|
ip: '10.20.10.15',
|
|
|
|
|
extPort: '9999',
|
|
|
|
|
intPort: '9000'
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
scope.create();
|
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Create and start a container with environment variables', function() {
|
|
|
|
|
it('should issue a correct create request to the Docker remote API', function() {
|
|
|
|
|
var controller = createController();
|
|
|
|
|
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
|
|
|
|
var expectedBody = {
|
|
|
|
|
"name": "container-name",
|
|
|
|
|
"Memory": 0,
|
|
|
|
|
"MemorySwap": 0,
|
|
|
|
|
"CpuShares": 1024,
|
|
|
|
|
"Cmd": null,
|
|
|
|
|
"VolumesFrom": [],
|
|
|
|
|
"Env": ["SHELL=/bin/bash", "TERM=xterm-256color"],
|
|
|
|
|
"ExposedPorts": {},
|
|
|
|
|
"HostConfig": {
|
|
|
|
|
"PortBindings": {}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectGET('/dockerapi/containers/json?all=1').respond([{
|
|
|
|
|
"Command": "./dockerui -e /docker.sock",
|
|
|
|
|
"Created": 1421817232,
|
|
|
|
|
"Id": "b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f",
|
|
|
|
|
"Image": "dockerui:latest",
|
|
|
|
|
"Names": ["/dockerui"],
|
|
|
|
|
"Ports": [{
|
|
|
|
|
"IP": "0.0.0.0",
|
|
|
|
|
"PrivatePort": 9000,
|
|
|
|
|
"PublicPort": 9000,
|
|
|
|
|
"Type": "tcp"
|
|
|
|
|
}],
|
|
|
|
|
"Status": "Up 2 minutes"
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectPOST('/dockerapi/containers/create?name=container-name', expectedBody).respond({
|
|
|
|
|
"Id": id,
|
|
|
|
|
"Warnings": null
|
|
|
|
@ -52,14 +123,20 @@ describe('startContainerController', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
scope.config.name = 'container-name';
|
|
|
|
|
scope.config.portBindings = [{ip: '10.20.10.15', extPort: '9999', intPort: '9000'}]
|
|
|
|
|
scope.config.env = [{
|
|
|
|
|
name: 'SHELL',
|
|
|
|
|
value: '/bin/bash'
|
|
|
|
|
}, {
|
|
|
|
|
name: 'TERM',
|
|
|
|
|
value: 'xterm-256color'
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
scope.create();
|
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Create and start a container with environment variables', function () {
|
|
|
|
|
describe('Create and start a container with volumesFrom', function() {
|
|
|
|
|
it('should issue a correct create request to the Docker remote API', function() {
|
|
|
|
|
var controller = createController();
|
|
|
|
|
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
|
|
|
@ -69,11 +146,29 @@ describe('startContainerController', function () {
|
|
|
|
|
"MemorySwap": 0,
|
|
|
|
|
"CpuShares": 1024,
|
|
|
|
|
"Cmd": null,
|
|
|
|
|
"VolumesFrom": "",
|
|
|
|
|
"Env":["SHELL=/bin/bash", "TERM=xterm-256color"],
|
|
|
|
|
"ExposedPorts":{},
|
|
|
|
|
"HostConfig": {"PortBindings":{}}
|
|
|
|
|
"VolumesFrom": ["parent", "other:ro"],
|
|
|
|
|
"Env": [],
|
|
|
|
|
"ExposedPorts": {},
|
|
|
|
|
"HostConfig": {
|
|
|
|
|
"PortBindings": {}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectGET('/dockerapi/containers/json?all=1').respond([{
|
|
|
|
|
"Command": "./dockerui -e /docker.sock",
|
|
|
|
|
"Created": 1421817232,
|
|
|
|
|
"Id": "b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f",
|
|
|
|
|
"Image": "dockerui:latest",
|
|
|
|
|
"Names": ["/dockerui"],
|
|
|
|
|
"Ports": [{
|
|
|
|
|
"IP": "0.0.0.0",
|
|
|
|
|
"PrivatePort": 9000,
|
|
|
|
|
"PublicPort": 9000,
|
|
|
|
|
"Type": "tcp"
|
|
|
|
|
}],
|
|
|
|
|
"Status": "Up 2 minutes"
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
$httpBackend.expectPOST('/dockerapi/containers/create?name=container-name', expectedBody).respond({
|
|
|
|
|
"Id": id,
|
|
|
|
|
"Warnings": null
|
|
|
|
@ -84,7 +179,7 @@ describe('startContainerController', function () {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
scope.config.name = 'container-name';
|
|
|
|
|
scope.config.env = [{name: 'SHELL', value: '/bin/bash'}, {name: 'TERM', value: 'xterm-256color'}];
|
|
|
|
|
scope.config.volumesFrom = [{name: "parent"}, {name:"other:ro"}];
|
|
|
|
|
|
|
|
|
|
scope.create();
|
|
|
|
|
$httpBackend.flush();
|
|
|
|
|