tests: Add test case for ascending ports issue

Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-01-02 11:27:57 +00:00
parent 557c32b80e
commit e82749e63a
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
3 changed files with 41 additions and 0 deletions

View File

@ -243,6 +243,17 @@ describe 'Ports', ->
})
])
describe 'Running container comparison', ->
it 'should not consider order when comparing current and target state', ->
portBindings = require('./data/ports/not-ascending/port-bindings.json')
compose = require('./data/ports/not-ascending/compose.json')
portMapsCurrent = PortMap.fromDockerOpts(portBindings)
portMapsTarget = compose.ports.map((p) -> new PortMap(p))
portMapsTarget = PortMap.normaliseComposePorts(portMapsTarget)
expect(portMapsTarget).to.deep.equal(portMapsCurrent)
describe 'normalisePortMaps', ->
it 'should correctly normalise PortMap lists', ->

View File

@ -0,0 +1,14 @@
{
"imageId": 730944,
"serviceName": "port-service",
"image": "sha256:6d101a6659bf5c10616bacd696feb80c927d56c0f14baadf8cf1f8956c492905",
"running": true,
"environment": {},
"labels": {},
"ports": ["80-90", "10:1000", "300/udp", "20/udp"],
"appId": 1032480,
"releaseId": 720081,
"serviceId": 155981,
"commit": "a41cede6b2dde6553476d02feba34a5e",
"imageName": "registry2.balena-cloud.com/v2/fa91ca88f7df77517ead234e4ea7e381@sha256:08a9abf8dbc21540a5db17caea829ac236bfa8c387c83fa56c8ec1c7975a0952"
}

View File

@ -0,0 +1,16 @@
{
"1000/tcp": [{ "HostIp": "", "HostPort": "10" }],
"20/udp": [{ "HostIp": "", "HostPort": "20" }],
"300/udp": [{ "HostIp": "", "HostPort": "300" }],
"80/tcp": [{ "HostIp": "", "HostPort": "80" }],
"81/tcp": [{ "HostIp": "", "HostPort": "81" }],
"82/tcp": [{ "HostIp": "", "HostPort": "82" }],
"83/tcp": [{ "HostIp": "", "HostPort": "83" }],
"84/tcp": [{ "HostIp": "", "HostPort": "84" }],
"85/tcp": [{ "HostIp": "", "HostPort": "85" }],
"86/tcp": [{ "HostIp": "", "HostPort": "86" }],
"87/tcp": [{ "HostIp": "", "HostPort": "87" }],
"88/tcp": [{ "HostIp": "", "HostPort": "88" }],
"89/tcp": [{ "HostIp": "", "HostPort": "89" }],
"90/tcp": [{ "HostIp": "", "HostPort": "90" }]
}