2017-03-15 08:35:07 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const OSBuildFetcher = require('../tools/js/os-build-fetcher.js').OSBuildFetcher;
|
|
|
|
const MockRemoteAPI = require('../unit-tests/resources/mock-remote-api.js').MockRemoteAPI;
|
|
|
|
const TestServer = require('./resources/test-server.js');
|
2021-03-22 21:23:38 +00:00
|
|
|
const addWorkerForReport = require('./resources/common-operations.js').addWorkerForReport;
|
2017-03-15 08:35:07 +00:00
|
|
|
const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
|
|
|
|
const MockSubprocess = require('./resources/mock-subprocess.js').MockSubprocess;
|
|
|
|
const MockLogger = require('./resources/mock-logger.js').MockLogger;
|
|
|
|
|
|
|
|
|
|
|
|
describe('OSBuildFetcher', function() {
|
2017-03-16 06:29:02 +00:00
|
|
|
this.timeout(5000);
|
2018-04-24 17:17:42 +00:00
|
|
|
TestServer.inject('node');
|
2017-03-15 08:35:07 +00:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
MockRemoteAPI.reset('http://build.webkit.org');
|
|
|
|
MockSubprocess.reset();
|
|
|
|
});
|
|
|
|
|
|
|
|
const emptyReport = {
|
2021-03-22 21:23:38 +00:00
|
|
|
'workerName': 'someWorker',
|
|
|
|
'workerPassword': 'somePassword',
|
2017-03-15 08:35:07 +00:00
|
|
|
};
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
const workerAuth = {
|
|
|
|
'name': 'someWorker',
|
2017-03-15 08:35:07 +00:00
|
|
|
'password': 'somePassword'
|
|
|
|
};
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
const ownedCommitWithWebKit = {
|
2017-03-15 08:35:07 +00:00
|
|
|
'WebKit': {'revision': '141978'}
|
|
|
|
};
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
const anotherownedCommitWithWebKit = {
|
2017-03-16 06:29:02 +00:00
|
|
|
'WebKit': {'revision': '141999'}
|
2017-03-15 08:35:07 +00:00
|
|
|
};
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
const anotherownedCommitWithWebKitAndJavaScriptCore = {
|
2017-03-15 08:35:07 +00:00
|
|
|
'WebKit': {'revision': '142000'},
|
|
|
|
'JavaScriptCore': {'revision': '142000'}
|
|
|
|
};
|
|
|
|
|
|
|
|
const osxCommit = {
|
|
|
|
'repository': 'OSX',
|
|
|
|
'revision': 'Sierra16D32',
|
|
|
|
'order': 1603003200
|
|
|
|
};
|
|
|
|
|
|
|
|
const anotherOSXCommit = {
|
|
|
|
'repository': 'OSX',
|
|
|
|
'revision': 'Sierra16E32',
|
|
|
|
'order': 1603003200
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
'name': 'OSX',
|
|
|
|
'customCommands': [
|
|
|
|
{
|
|
|
|
'command': ['list', 'all osx 16Dxx builds'],
|
2017-09-19 21:47:41 +00:00
|
|
|
'ownedCommitCommand': ['list', 'ownedCommit', 'for', 'revision'],
|
2017-03-15 08:35:07 +00:00
|
|
|
'linesToIgnore': '^\\.*$',
|
|
|
|
'minRevision': 'Sierra16D0',
|
|
|
|
'maxRevision': 'Sierra16D999'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'command': ['list', 'all osx 16Exx builds'],
|
2017-09-19 21:47:41 +00:00
|
|
|
'ownedCommitCommand': ['list', 'ownedCommit', 'for', 'revision'],
|
2017-03-15 08:35:07 +00:00
|
|
|
'linesToIgnore': '^\\.*$',
|
|
|
|
'minRevision': 'Sierra16E0',
|
|
|
|
'maxRevision': 'Sierra16E999'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
const configWithoutOwnedCommitCommand = {
|
2017-03-15 08:35:07 +00:00
|
|
|
'name': 'OSX',
|
|
|
|
'customCommands': [
|
|
|
|
{
|
|
|
|
'command': ['list', 'all osx 16Dxx builds'],
|
|
|
|
'linesToIgnore': '^\\.*$',
|
|
|
|
'minRevision': 'Sierra16D0',
|
|
|
|
'maxRevision': 'Sierra16D999'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'command': ['list', 'all osx 16Exx builds'],
|
|
|
|
'linesToIgnore': '^\\.*$',
|
|
|
|
'minRevision': 'Sierra16E0',
|
|
|
|
'maxRevision': 'Sierra16E999'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
const configTrackingOneOS = {
|
|
|
|
'name': 'OSX',
|
|
|
|
'customCommands': [
|
|
|
|
{
|
|
|
|
'command': ['list', 'all osx 16Dxx builds'],
|
|
|
|
'linesToIgnore': '^\\.*$',
|
|
|
|
'minRevision': 'Sierra16D100',
|
|
|
|
'maxRevision': 'Sierra16D999'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2017-03-15 08:35:07 +00:00
|
|
|
describe('OSBuilderFetcher._computeOrder', () => {
|
|
|
|
it('should calculate the right order for a given valid revision', () => {
|
2017-10-31 10:01:18 +00:00
|
|
|
const fetcher = new OSBuildFetcher({});
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(fetcher._computeOrder('Sierra16D32'), 1603003200);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('16D321'), 1603032100);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('16d321'), 1603032100);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('16D321z'), 1603032126);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('16d321Z'), 1603032126);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('10.12.3 16D32'), 1603003200);
|
|
|
|
assert.strictEqual(fetcher._computeOrder('10.12.3 Sierra16D32'), 1603003200);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should throw assertion error when given a invalid revision', () => {
|
2017-10-31 10:01:18 +00:00
|
|
|
const fetcher = new OSBuildFetcher({});
|
2018-01-18 06:06:50 +00:00
|
|
|
assert.throws(() => fetcher._computeOrder('invalid'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder(''), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('16'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('16D'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('123'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('D123'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('123z'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('16[163'), 'AssertionError [ERR_ASSERTION]');
|
|
|
|
assert.throws(() => fetcher._computeOrder('16D163['), 'AssertionError [ERR_ASSERTION]');
|
2017-03-15 08:35:07 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('OSBuilderFetcher._commitsForAvailableBuilds', () => {
|
2018-12-21 02:05:39 +00:00
|
|
|
it('should compatible with command output only contains lines of revision', async () => {
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2018-05-24 01:18:20 +00:00
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchCommitsPromise = fetcher._commitsForAvailableBuilds(['list', 'build1'], '^\\.*$');
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['list', 'build1']);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
const expectedResults = {allRevisions: ["16D321", "16E321z", "16F321"], commitsWithTestability: {}};
|
|
|
|
await MockSubprocess.invocations[0].resolve('16D321\n16E321z\n\n16F321');
|
|
|
|
const buildInfo = await fetchCommitsPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(expectedResults, buildInfo);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
it('should parse the command output as JSON format', async () => {
|
2018-05-24 01:18:20 +00:00
|
|
|
const logger = new MockLogger;
|
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchCommitsPromise = fetcher._commitsForAvailableBuilds(['list', 'build1']);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['list', 'build1']);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
const outputObject = {allRevisions: ["16D321", "16E321z", "16F321"], commitsWithTestability: {"16D321": "Panic"}};
|
|
|
|
await MockSubprocess.invocations[0].resolve(JSON.stringify(outputObject));
|
|
|
|
const buildInfo = await fetchCommitsPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(outputObject, buildInfo);
|
2018-12-21 02:05:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('OSBuilderFetcher._commitsWithinRange', () => {
|
|
|
|
it('should only return commits whose orders are higher than specified order', async () => {
|
|
|
|
const logger = new MockLogger;
|
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
|
|
|
const results = fetcher._commitsWithinRange(["16D321", "16E321z", "16F321"], "OSX", 1604000000, 1606000000);
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(results.length, 2);
|
|
|
|
assert.deepStrictEqual(results[0], {repository: 'OSX', order: 1604032126, revision: '16E321z'});
|
|
|
|
assert.deepStrictEqual(results[1], {repository: 'OSX', order: 1605032100, revision: '16F321'});
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should only return commits whose orders are higher than minOrder and lower than the maxOrder', async () => {
|
|
|
|
const logger = new MockLogger;
|
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
|
|
|
const results = fetcher._commitsWithinRange(["16D321", "16E321z", "16F321"], "OSX", 1604000000, 1605000000);
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(results.length, 1);
|
|
|
|
assert.deepStrictEqual(results[0], {repository: 'OSX', order: 1604032126, revision: '16E321z'});
|
2018-05-24 01:18:20 +00:00
|
|
|
});
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
describe('OSBuildFetcher._addOwnedCommitsForBuild', () => {
|
|
|
|
it('should add owned-commit info for commits', () => {
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2018-05-24 01:18:20 +00:00
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-05-24 01:18:20 +00:00
|
|
|
const addownedCommitPromise = fetcher._addOwnedCommitsForBuild([osxCommit, anotherOSXCommit], ['ownedCommit', 'for', 'revision']);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2017-03-20 22:36:40 +00:00
|
|
|
return waitForInvocationPromise.then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['ownedCommit', 'for', 'revision', 'Sierra16D32']);
|
2017-09-19 21:47:41 +00:00
|
|
|
MockSubprocess.invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
2017-03-15 08:35:07 +00:00
|
|
|
MockSubprocess.reset();
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.waitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['ownedCommit', 'for', 'revision', 'Sierra16E32']);
|
2017-09-19 21:47:41 +00:00
|
|
|
MockSubprocess.invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
|
|
|
return addownedCommitPromise;
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then((results) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(results.length, 2);
|
|
|
|
assert.strictEqual(results[0]['repository'], osxCommit['repository']);
|
|
|
|
assert.strictEqual(results[0]['revision'], osxCommit['revision']);
|
|
|
|
assert.deepStrictEqual(results[0]['ownedCommits'], ownedCommitWithWebKit);
|
|
|
|
assert.strictEqual(results[1]['repository'], anotherOSXCommit['repository']);
|
|
|
|
assert.strictEqual(results[1]['revision'], anotherOSXCommit['revision']);
|
|
|
|
assert.deepStrictEqual(results[1]['ownedCommits'], anotherownedCommitWithWebKit);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
it('should fail if the command to get owned-commit info fails', () => {
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2018-05-24 01:18:20 +00:00
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-05-24 01:18:20 +00:00
|
|
|
const addownedCommitPromise = fetcher._addOwnedCommitsForBuild([osxCommit], ['ownedCommit', 'for', 'revision'])
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2017-03-20 22:36:40 +00:00
|
|
|
return waitForInvocationPromise.then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['ownedCommit', 'for', 'revision', 'Sierra16D32']);
|
2017-09-19 21:47:41 +00:00
|
|
|
MockSubprocess.invocations[0].reject('Failed getting owned-commit');
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
return addownedCommitPromise.then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
assert(false, 'should never be reached');
|
|
|
|
}, (error_output) => {
|
|
|
|
assert(error_output);
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(error_output, 'Failed getting owned-commit');
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
it('should fail if entries in owned-commits does not contain revision', () => {
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2018-05-24 01:18:20 +00:00
|
|
|
const fetcher = new OSBuildFetcher({}, null, null, MockSubprocess, logger);
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-05-24 01:18:20 +00:00
|
|
|
const addownedCommitPromise = fetcher._addOwnedCommitsForBuild([osxCommit], ['ownedCommit', 'for', 'revision'])
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2017-03-20 22:36:40 +00:00
|
|
|
return waitForInvocationPromise.then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(MockSubprocess.invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(MockSubprocess.invocations[0].command, ['ownedCommit', 'for', 'revision', 'Sierra16D32']);
|
2017-03-15 08:35:07 +00:00
|
|
|
MockSubprocess.invocations[0].resolve('{"WebKit":{"RandomKey": "RandomValue"}}');
|
|
|
|
|
2017-09-19 21:47:41 +00:00
|
|
|
return addownedCommitPromise.then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
assert(false, 'should never be reached');
|
|
|
|
}, (error_output) => {
|
|
|
|
assert(error_output);
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(error_output.name, 'AssertionError');
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
2018-12-21 02:05:39 +00:00
|
|
|
});
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
describe('OSBuildFetcher.fetchReportAndUpdateBuilds', () => {
|
2017-03-20 22:36:40 +00:00
|
|
|
const invocations = MockSubprocess.invocations;
|
2017-03-16 06:29:02 +00:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
TestServer.database().connect({keepAlive: true});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
TestServer.database().disconnect();
|
|
|
|
});
|
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
it('should be backward compatible and report all build commits with owned-commits', () => {
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(config, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2017-03-15 08:35:07 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
let fetchReportAndUpdateBuildsPromise = null;
|
2017-03-15 08:35:07 +00:00
|
|
|
let fetchAvailableBuildsPromise = null;
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
return addWorkerForReport(emptyReport).then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
return Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
}).then(() => {
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(parseInt(result['commits'][0]['order'])), 1603006800);
|
2017-03-15 08:35:07 +00:00
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-05-24 01:18:20 +00:00
|
|
|
fetchAvailableBuildsPromise = fetcher._fetchAvailableBuilds();
|
2017-03-20 22:36:40 +00:00
|
|
|
return waitForInvocationPromise;
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2017-03-20 22:36:40 +00:00
|
|
|
invocations[0].resolve('\n\nSierra16D68\nSierra16D69\n');
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2017-03-20 22:36:40 +00:00
|
|
|
invocations[0].resolve('\n\nSierra16E32\nSierra16E33\nSierra16E33h\nSierra16E34');
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKitAndJavaScriptCore));
|
2017-03-15 08:35:07 +00:00
|
|
|
return fetchAvailableBuildsPromise;
|
2018-12-21 02:05:39 +00:00
|
|
|
}).then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
MockSubprocess.reset();
|
2018-12-21 02:05:39 +00:00
|
|
|
fetchReportAndUpdateBuildsPromise = fetcher.fetchReportAndUpdateBuilds();
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.waitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2017-03-20 22:36:40 +00:00
|
|
|
invocations[0].resolve('\n\nSierra16D68\nSierra16D69\n');
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2017-03-20 22:36:40 +00:00
|
|
|
invocations[0].resolve('\n\nSierra16E32\nSierra16E33\nSierra16E33h\nSierra16E34');
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKitAndJavaScriptCore));
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
return fetchReportAndUpdateBuildsPromise;
|
|
|
|
}).then(() => {
|
|
|
|
return Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E33h'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E34'})]);
|
|
|
|
}).then((results) => {
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16E33h = results[3];
|
|
|
|
const osxCommit16E34 = results[4];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 1);
|
|
|
|
assert.strictEqual(webkitRepository[0]['owner'], 10);
|
|
|
|
assert.strictEqual(jscRepository.length, 1);
|
|
|
|
assert.strictEqual(jscRepository[0]['owner'], 10);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D69[0]['order']), 1603006900);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E33h.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E33h[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E33h[0]['order']), 1604003308);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E34.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E34[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E34[0]['order']), 1604003400);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D69');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006900);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E34');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003400);
|
2018-12-21 02:05:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should report all build commits with owned-commits', () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(config, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2018-12-21 02:05:39 +00:00
|
|
|
const db = TestServer.database();
|
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34"], commitsWithTestability: {}};
|
|
|
|
|
|
|
|
let fetchReportAndUpdateBuildsPromise = null;
|
|
|
|
let fetchAvailableBuildsPromise = null;
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
return addWorkerForReport(emptyReport).then(() => {
|
2018-12-21 02:05:39 +00:00
|
|
|
return Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
}).then(() => {
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2018-12-21 02:05:39 +00:00
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2018-12-21 02:05:39 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
|
|
|
fetchAvailableBuildsPromise = fetcher._fetchAvailableBuilds();
|
|
|
|
return waitForInvocationPromise;
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKitAndJavaScriptCore));
|
|
|
|
return fetchAvailableBuildsPromise;
|
|
|
|
}).then(() => {
|
|
|
|
MockSubprocess.reset();
|
|
|
|
fetchReportAndUpdateBuildsPromise = fetcher.fetchReportAndUpdateBuilds();
|
|
|
|
return MockSubprocess.waitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKitAndJavaScriptCore));
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
return fetchReportAndUpdateBuildsPromise;
|
|
|
|
}).then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
return Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E33h'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E34'})]);
|
|
|
|
}).then((results) => {
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16E33h = results[3];
|
|
|
|
const osxCommit16E34 = results[4];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 1);
|
|
|
|
assert.strictEqual(webkitRepository[0]['owner'], 10);
|
|
|
|
assert.strictEqual(jscRepository.length, 1);
|
|
|
|
assert.strictEqual(jscRepository[0]['owner'], 10);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D69[0]['order']), 1603006900);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E33h.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E33h[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E33h[0]['order']), 1604003308);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E34.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E34[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E34[0]['order']), 1604003400);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D69');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006900);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E34');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003400);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-19 09:08:11 +00:00
|
|
|
it('should update testability message for commits', async () => {
|
2018-12-21 02:05:39 +00:00
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(config, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2018-12-21 02:05:39 +00:00
|
|
|
const db = TestServer.database();
|
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {"Sierra16D68": "Panic", "Sierra16D69": "Spin CPU"}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34"], commitsWithTestability: {"Sierra16E31": "WebKit crashes"}};
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E31', 'order': 1604003100, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
|
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2018-12-21 02:05:39 +00:00
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
const fetchReportAndUpdatePromise = fetcher.fetchReportAndUpdateBuilds();
|
|
|
|
await MockSubprocess.waitForInvocation();
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
|
|
|
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKitAndJavaScriptCore));
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
await fetchReportAndUpdatePromise;
|
|
|
|
|
|
|
|
const webkitRepository = await db.selectRows('repositories', {'name': 'WebKit'});
|
|
|
|
const jscRepository = await db.selectRows('repositories', {'name': 'JavaScriptCore'});
|
|
|
|
const osxCommit16D68 = await db.selectRows('commits', {'revision': 'Sierra16D68'});
|
|
|
|
const osxCommit16D69 = await db.selectRows('commits', {'revision': 'Sierra16D69'});
|
|
|
|
const osxCommit16E31 = await db.selectRows('commits', {'revision': 'Sierra16E31'});
|
|
|
|
const osxCommit16E33h = await db.selectRows('commits', {'revision': 'Sierra16E33h'});
|
|
|
|
const osxCommit16E34 = await db.selectRows('commits', {'revision': 'Sierra16E34'});
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 1);
|
|
|
|
assert.strictEqual(webkitRepository[0]['owner'], 10);
|
|
|
|
assert.strictEqual(jscRepository.length, 1);
|
|
|
|
assert.strictEqual(jscRepository[0]['owner'], 10);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D68.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D68[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D68[0]['order']), 1603006800);
|
|
|
|
assert.strictEqual(osxCommit16D68[0]['testability'], "Panic");
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D69[0]['order']), 1603006900);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['testability'], "Spin CPU");
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E31.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E31[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E31[0]['order']), 1604003100);
|
|
|
|
assert.strictEqual(osxCommit16E31[0]['testability'], "WebKit crashes");
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E33h.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E33h[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E33h[0]['order']), 1604003308);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E34.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E34[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E34[0]['order']), 1604003400);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D69');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006900);
|
2018-12-21 02:05:39 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E34');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003400);
|
2018-12-21 02:05:39 +00:00
|
|
|
});
|
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
it('should report commits without owned-commits if "ownedCommitCommand" is not specified in config', async () => {
|
|
|
|
|
2017-03-15 08:35:07 +00:00
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(configWithoutOwnedCommitCommand, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2017-03-15 08:35:07 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34"], commitsWithTestability: {}};
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2018-05-24 01:18:20 +00:00
|
|
|
await Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
|
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchReportAndUpdatePromise = fetcher.fetchReportAndUpdateBuilds();
|
2018-05-24 01:18:20 +00:00
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
result = await fetchReportAndUpdatePromise;
|
2018-05-24 01:18:20 +00:00
|
|
|
const results = await Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E33h'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E34'})]);
|
|
|
|
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16E33h = results[3];
|
|
|
|
const osxCommit16E34 = results[4];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 0);
|
|
|
|
assert.strictEqual(jscRepository.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D69[0]['order']), 1603006900);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E33h.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E33h[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E33h[0]['order']), 1604003308);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E34.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E34[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E34[0]['order']), 1604003400);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D69');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006900);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E34');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003400);
|
2018-05-24 01:18:20 +00:00
|
|
|
});
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
it('should report commits within specified revision range', async () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(configWithoutOwnedCommitCommand, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2018-05-24 01:18:20 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69", "Sierra16D10000"], commitsWithTestability: {}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34", "Sierra16E10000"], commitsWithTestability: {}};
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2018-05-24 01:18:20 +00:00
|
|
|
await Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
|
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2018-05-24 01:18:20 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchReportAndUpdatePromise = fetcher.fetchReportAndUpdateBuilds();
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
result = await fetchReportAndUpdatePromise;
|
2018-05-24 01:18:20 +00:00
|
|
|
const results = await Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E33h'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16E34'})]);
|
|
|
|
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16E33h = results[3];
|
|
|
|
const osxCommit16E34 = results[4];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 0);
|
|
|
|
assert.strictEqual(jscRepository.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D69[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D69[0]['order']), 1603006900);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E33h.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E33h[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E33h[0]['order']), 1604003308);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16E34.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16E34[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16E34[0]['order']), 1604003400);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D69');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006900);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E34');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003400);
|
2018-05-24 01:18:20 +00:00
|
|
|
});
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2019-01-19 09:08:11 +00:00
|
|
|
it('should update commits within specified revision range', async () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(configWithoutOwnedCommitCommand, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2019-01-19 09:08:11 +00:00
|
|
|
const db = TestServer.database();
|
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {"Sierra16D10000": "Panic"}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34", "Sierra16E10000"], commitsWithTestability: {}};
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2019-01-19 09:08:11 +00:00
|
|
|
await Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
|
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2019-01-19 09:08:11 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2019-01-19 09:08:11 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
|
|
|
const fetchAvailableBuildsPromise = fetcher._fetchAvailableBuilds();
|
|
|
|
|
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2019-01-19 09:08:11 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
|
|
|
|
|
|
|
await MockSubprocess.resetAndWaitForInvocation();
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2019-01-19 09:08:11 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
|
|
|
|
|
|
|
result = await fetchAvailableBuildsPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result.commitsToUpdate.length, 0);
|
2019-01-19 09:08:11 +00:00
|
|
|
});
|
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
it('should use "last-reported" order + 1 as "minOrder"', async () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(configTrackingOneOS, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2018-05-24 01:18:20 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69", "Sierra16D100", "Sierra16D100a"], commitsWithTestability: {}};
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2018-05-24 01:18:20 +00:00
|
|
|
await db.insert('repositories', {'id': 10, 'name': 'OSX'});
|
|
|
|
await db.insert('commits', {'repository': 10, 'revision': 'Sierra16D100', 'order': 1603010000, 'reported': true});
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603010000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D100');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603010000);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2018-05-24 01:18:20 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchAndReportPromise = fetcher.fetchReportAndUpdateBuilds();
|
2018-05-24 01:18:20 +00:00
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await fetchAndReportPromise;
|
|
|
|
const results = await Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D100a'})]);
|
|
|
|
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16D100a = results[3];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 0);
|
|
|
|
assert.strictEqual(jscRepository.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D100a.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D100a[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D100a[0]['order']), 1603010001);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603010000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D100a');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603010001);
|
2018-05-24 01:18:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should use minRevision in the config if there is no commit', async () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(configTrackingOneOS, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2018-05-24 01:18:20 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69", "Sierra16D100", "Sierra16D101"], commitsWithTestability: {}};
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
await addWorkerForReport(emptyReport);
|
2018-05-24 01:18:20 +00:00
|
|
|
await db.insert('repositories', {'id': 10, 'name': 'OSX'});
|
|
|
|
|
|
|
|
let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603010000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
const fetchReportAndUpdatePromise = fetcher.fetchReportAndUpdateBuilds();
|
2018-05-24 01:18:20 +00:00
|
|
|
await waitForInvocationPromise;
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2018-12-21 02:05:39 +00:00
|
|
|
result = await fetchReportAndUpdatePromise;
|
2018-05-24 01:18:20 +00:00
|
|
|
const results = await Promise.all([
|
|
|
|
db.selectRows('repositories', {'name': 'WebKit'}),
|
|
|
|
db.selectRows('repositories', {'name': 'JavaScriptCore'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D69'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D100'}),
|
|
|
|
db.selectRows('commits', {'revision': 'Sierra16D101'})]);
|
|
|
|
|
|
|
|
const webkitRepository = results[0];
|
|
|
|
const jscRepository = results[1];
|
|
|
|
const osxCommit16D69 = results[2];
|
|
|
|
const osxCommit16D100 = results[3];
|
|
|
|
const osxCommit16D101 = results[4];
|
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(webkitRepository.length, 0);
|
|
|
|
assert.strictEqual(jscRepository.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D69.length, 0);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D100.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D100[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D100[0]['order']), 1603010000);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(osxCommit16D101.length, 1);
|
|
|
|
assert.strictEqual(osxCommit16D101[0]['repository'], 10);
|
|
|
|
assert.strictEqual(parseInt(osxCommit16D101[0]['order']), 1603010100);
|
2018-05-24 01:18:20 +00:00
|
|
|
|
|
|
|
result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603010000&to=1603099900');
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D101');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603010100);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should stop reporting if any custom command fails', () => {
|
|
|
|
const logger = new MockLogger;
|
2021-03-22 21:23:38 +00:00
|
|
|
const fetcher = new OSBuildFetcher(config, TestServer.remoteAPI(), workerAuth, MockSubprocess, logger);
|
2017-03-15 08:35:07 +00:00
|
|
|
const db = TestServer.database();
|
2018-12-21 02:05:39 +00:00
|
|
|
const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {}};
|
|
|
|
const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34"], commitsWithTestability: {}};
|
2017-03-15 08:35:07 +00:00
|
|
|
let fetchAndReportPromise = null;
|
|
|
|
|
2021-03-22 21:23:38 +00:00
|
|
|
return addWorkerForReport(emptyReport).then(() => {
|
2017-03-15 08:35:07 +00:00
|
|
|
return Promise.all([
|
|
|
|
db.insert('repositories', {'id': 10, 'name': 'OSX'}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
|
|
|
|
db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
|
|
|
|
}).then(() => {
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
2017-03-20 22:36:40 +00:00
|
|
|
const waitForInvocationPromise = MockSubprocess.waitForInvocation();
|
2018-12-21 02:05:39 +00:00
|
|
|
fetchAndReportPromise = fetcher.fetchReportAndUpdateBuilds();
|
2017-03-20 22:36:40 +00:00
|
|
|
return waitForInvocationPromise;
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraD));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16D69']);
|
2017-09-19 21:47:41 +00:00
|
|
|
MockSubprocess.invocations[0].resolve(JSON.stringify(ownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
2017-03-15 08:35:07 +00:00
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
|
2018-12-21 02:05:39 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(resultsForSierraE));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E33h']);
|
2017-09-19 21:47:41 +00:00
|
|
|
invocations[0].resolve(JSON.stringify(anotherownedCommitWithWebKit));
|
2017-03-20 22:36:40 +00:00
|
|
|
return MockSubprocess.resetAndWaitForInvocation();
|
|
|
|
}).then(() => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(invocations.length, 1);
|
|
|
|
assert.deepStrictEqual(invocations[0].command, ['list', 'ownedCommit', 'for', 'revision', 'Sierra16E34']);
|
2017-03-20 22:36:40 +00:00
|
|
|
invocations[0].reject('Command failed');
|
2017-03-15 08:35:07 +00:00
|
|
|
return fetchAndReportPromise.then(() => {
|
|
|
|
assert(false, 'should never be reached');
|
|
|
|
}, (error_output) => {
|
|
|
|
assert(error_output);
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(error_output, 'Command failed');
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
}).then(() => {
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16D68');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1603006800);
|
2017-03-15 08:35:07 +00:00
|
|
|
|
|
|
|
return TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
|
|
|
|
}).then((result) => {
|
2021-03-06 14:31:56 +00:00
|
|
|
assert.strictEqual(result['commits'].length, 1);
|
|
|
|
assert.strictEqual(result['commits'][0]['revision'], 'Sierra16E33g');
|
|
|
|
assert.strictEqual(parseInt(result['commits'][0]['order']), 1604003307);
|
2017-03-15 08:35:07 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|