chore(portal-api): fix tests
This commit is contained in:
parent
454c37a3d6
commit
9f53c1fa17
@ -673,7 +673,7 @@ class Data extends EventEmitter {
|
||||
|
||||
_calcCurrentScale ({ config, currentVersion }, cb) {
|
||||
return config.map(({ name }) => {
|
||||
const currentScale = Find(ForceArray(currentVersion.scale), [
|
||||
const currentScale = Find(ForceArray(currentVersion ? currentVersion.scale : []), [
|
||||
'serviceName',
|
||||
name
|
||||
]);
|
||||
@ -699,6 +699,11 @@ class Data extends EventEmitter {
|
||||
return fallback();
|
||||
}
|
||||
|
||||
if (!this._machines) {
|
||||
this._server.log(['debug'], '-> watcher not yet defined');
|
||||
return fallback();
|
||||
}
|
||||
|
||||
const machines = ForceArray(this._machines.getContainers())
|
||||
.filter(({ tags = {} }) => {
|
||||
return tags[DEPLOYMENT_GROUP] === deploymentGroupName;
|
||||
|
@ -10,7 +10,7 @@
|
||||
"lint": "belly-button --fix",
|
||||
"lint-ci": "belly-button",
|
||||
"test": "lab -c",
|
||||
"test-docker": "docker-compose -f test-compose.yml up --abort-on-container-exit --build --force-recreate api",
|
||||
"test-docker": "docker-compose -f test-compose.yml down -v && docker-compose -f test-compose.yml up --abort-on-container-exit --build --force-recreate api",
|
||||
"test-ci": "echo 0",
|
||||
"start": "node server.js",
|
||||
"dev": "CORS=1 NAMESPACE=api node server.js",
|
||||
|
@ -35,9 +35,8 @@ rethinkdb:
|
||||
- CONSUL_AGENT=1
|
||||
ports:
|
||||
- 8080:8080
|
||||
expose:
|
||||
- 28015
|
||||
- 29015
|
||||
- 28015:28015
|
||||
- 29015:29015
|
||||
dns:
|
||||
- 127.0.0.1
|
||||
api:
|
||||
@ -51,5 +50,7 @@ api:
|
||||
- ../../_env
|
||||
environment:
|
||||
- CONSUL=consul
|
||||
expose:
|
||||
- 9090
|
||||
dns:
|
||||
- 127.0.0.1
|
||||
|
@ -23,5 +23,10 @@
|
||||
name: 'docker-compose-api',
|
||||
interval: 5
|
||||
}
|
||||
]
|
||||
],
|
||||
telemetry: {
|
||||
port: 9090,
|
||||
tags: ['op'],
|
||||
metrics: []
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,19 @@
|
||||
const Fs = require('fs');
|
||||
const Path = require('path');
|
||||
const Code = require('code');
|
||||
const { describe, it, afterEach, expect } = exports.lab = require('lab').script();
|
||||
const { describe, it, beforeEach, expect } = exports.lab = require('lab').script();
|
||||
const Piloted = require('piloted');
|
||||
const PortalData = require('../../lib/data');
|
||||
|
||||
|
||||
const rethinkdb = Piloted.service('rethinkdb');
|
||||
const internals = {
|
||||
options: {
|
||||
name: 'test',
|
||||
db: { test: true },
|
||||
db: {
|
||||
test: true,
|
||||
host: rethinkdb ? rethinkdb.address : 'rethinkdb'
|
||||
},
|
||||
server: {
|
||||
log: function () {}
|
||||
}
|
||||
@ -19,9 +24,13 @@ const internals = {
|
||||
};
|
||||
|
||||
|
||||
afterEach((done) => {
|
||||
const data = new PortalData({ name: 'test', db: { test: true } });
|
||||
data.connect(() => {
|
||||
beforeEach((done) => {
|
||||
const data = new PortalData(internals.options);
|
||||
data.connect((err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
data._db.r.dbDrop('test').run(data._db._connection, () => {
|
||||
done();
|
||||
});
|
||||
@ -98,7 +107,7 @@ describe('deployment groups', () => {
|
||||
expect(createdDeploymentGroup.id).to.exist();
|
||||
data.getDeploymentGroup({ id: createdDeploymentGroup.id }, (err, deploymentGroup) => {
|
||||
expect(err).to.not.exist();
|
||||
expect(deploymentGroup).to.equal(createdDeploymentGroup);
|
||||
expect(deploymentGroup.name).to.equal(createdDeploymentGroup.name);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -239,7 +248,7 @@ describe('versions', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
|
||||
@ -285,7 +294,7 @@ describe('versions', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
|
||||
@ -339,7 +348,7 @@ describe('versions', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
|
||||
@ -387,7 +396,7 @@ describe('versions', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
|
||||
@ -440,7 +449,7 @@ describe('manifests', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, result) => {
|
||||
@ -468,7 +477,7 @@ describe('manifests', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, result) => {
|
||||
@ -492,7 +501,7 @@ describe('manifests', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
|
||||
@ -551,7 +560,10 @@ describe('instances', () => {
|
||||
expect(result.id).to.exist();
|
||||
data.getInstance({ id: result.id }, (err, instance) => {
|
||||
expect(err).to.not.exist();
|
||||
expect(instance).to.equal(result);
|
||||
expect(instance.id).to.equal(result.id);
|
||||
expect(instance.name).to.equal(result.name);
|
||||
expect(instance.status).to.equal(result.status);
|
||||
expect(instance.machineId).to.equal(result.machineId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -679,7 +691,7 @@ describe.skip('scale()', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, manifest) => {
|
||||
@ -715,7 +727,7 @@ describe.skip('stopServices()', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, manifest) => {
|
||||
@ -749,7 +761,7 @@ describe.skip('startServices()', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, manifest) => {
|
||||
@ -783,7 +795,7 @@ describe.skip('restartServices()', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, manifest) => {
|
||||
@ -817,7 +829,7 @@ describe.skip('deleteServices()', () => {
|
||||
const clientManifest = {
|
||||
deploymentGroupId: deploymentGroup.id,
|
||||
type: 'compose',
|
||||
format: 'yml',
|
||||
format: 'yaml',
|
||||
raw: internals.composeFile
|
||||
};
|
||||
data.provisionManifest(clientManifest, (err, manifest) => {
|
||||
|
@ -7,7 +7,15 @@ const PortalApi = require('../');
|
||||
|
||||
|
||||
const internals = {
|
||||
options: { data: { name: 'test', db: { test: true } } }
|
||||
options: {
|
||||
data: {
|
||||
name: 'test',
|
||||
db: { test: true },
|
||||
server: {
|
||||
log: function () { }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
internals.register = { register: PortalApi, options: internals.options };
|
||||
@ -107,7 +115,7 @@ describe('graphql', () => {
|
||||
});
|
||||
|
||||
beforeEach((done) => {
|
||||
const data = new PortalData({ name: 'test', db: { test: true } });
|
||||
const data = new PortalData(internals.options.data);
|
||||
data.connect(() => {
|
||||
data.createDatacenter({ region: 'us-sw', name: 'us-sw' }, (err, datacenter) => {
|
||||
if (err) {
|
||||
|
@ -19,3 +19,14 @@ echo -e "${SDC_KEY}" | tr '#' '\n' > ~/.ssh/id_rsa
|
||||
chmod 400 ~/.ssh/id_rsa.pub
|
||||
chmod 400 ~/.ssh/id_rsa
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
|
||||
keyid=$(ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub | awk '{print $2}' | cut -d':' -f2-)
|
||||
|
||||
containerpilot -putenv "SSH_KEYID=$keyid"
|
||||
|
||||
|
||||
IS_RETHINK_DOWN=1
|
||||
until [ $IS_RETHINK_DOWN -eq 0 ]; do
|
||||
curl -o /dev/null --fail -s -m 10 http://rethinkdb:8080
|
||||
IS_RETHINK_DOWN=$(echo $?)
|
||||
done
|
@ -40,7 +40,7 @@ it('updates instances with the current status', (done) => {
|
||||
}
|
||||
};
|
||||
|
||||
const portalOptions = { data, url: 'url', account: 'account', keyId: 'de:e7:73:9a:aa:91:bb:3e:72:8d:cc:62:ca:58:a2:ec' };
|
||||
const portalOptions = { data, url: 'url', account: 'account', keyId: process.env.SSH_KEYID || 'de:e7:73:9a:aa:91:bb:3e:72:8d:cc:62:ca:58:a2:ec' };
|
||||
const portalWatch = new PortalWatch(portalOptions);
|
||||
portalWatch._tritonWatch.removeAllListeners('change');
|
||||
|
||||
@ -79,7 +79,7 @@ it('creates new instance', (done) => {
|
||||
}
|
||||
};
|
||||
|
||||
const portalOptions = { data, url: 'url', account: 'account', keyId: 'de:e7:73:9a:aa:91:bb:3e:72:8d:cc:62:ca:58:a2:ec' };
|
||||
const portalOptions = { data, url: 'url', account: 'account', keyId: process.env.SSH_KEYID || 'de:e7:73:9a:aa:91:bb:3e:72:8d:cc:62:ca:58:a2:ec' };
|
||||
const portalWatch = new PortalWatch(portalOptions);
|
||||
portalWatch._tritonWatch.removeAllListeners('change');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user