2016-04-07 22:10:50 +00:00
'use strict' ;
const assert = require ( 'assert' ) ;
const TestServer = require ( './resources/test-server.js' ) ;
2017-03-15 03:19:02 +00:00
const prepareServerTest = require ( './resources/common-operations.js' ) . prepareServerTest ;
2016-04-07 22:10:50 +00:00
const submitReport = require ( './resources/common-operations.js' ) . submitReport ;
describe ( "/admin/platforms" , function ( ) {
2017-03-15 03:19:02 +00:00
prepareServerTest ( this ) ;
2016-04-07 22:10:50 +00:00
function reportsForDifferentPlatforms ( )
{
return [
{
2019-10-24 22:00:37 +00:00
"buildTag" : "3001" ,
2016-04-07 22:10:50 +00:00
"buildTime" : "2013-02-28T09:01:47" ,
"builderName" : "someBuilder" ,
"builderPassword" : "somePassword" ,
"platform" : "Mavericks" ,
"tests" : { "test" : { "metrics" : { "FrameRate" : { "current" : [ [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] ] } } } } ,
} ,
{
2019-10-24 22:00:37 +00:00
"buildTag" : "3001" ,
2016-04-07 22:10:50 +00:00
"buildTime" : "2013-02-28T10:12:03" ,
"builderName" : "someBuilder" ,
"builderPassword" : "somePassword" ,
"platform" : "Mountain Lion" ,
"tests" : { "test" : { "metrics" : { "FrameRate" : { "current" : [ [ 2 , 2 , 2 ] , [ 2 , 2 , 2 ] ] } , "Combined" : { "current" : [ [ 3 , 3 , 3 ] , [ 3 , 3 , 3 ] ] } } } } ,
} ,
{
2019-10-24 22:00:37 +00:00
"buildTag" : "3003" ,
2016-04-07 22:10:50 +00:00
"buildTime" : "2013-02-28T12:56:26" ,
"builderName" : "someBuilder" ,
"builderPassword" : "somePassword" ,
"platform" : "Trunk Mountain Lion" ,
"tests" : { "test" : { "metrics" : { "FrameRate" : { "current" : [ [ 4 , 4 , 4 ] , [ 4 , 4 , 4 ] ] } } } }
} ] ;
}
2017-03-15 03:19:02 +00:00
it ( "should delete the platform that got merged into another one" , ( ) => {
2016-04-07 22:10:50 +00:00
const db = TestServer . database ( ) ;
2017-03-15 03:19:02 +00:00
let oldPlatforms ;
return submitReport ( reportsForDifferentPlatforms ( ) ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . selectAll ( 'platforms' , 'name' ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( platforms ) => {
2016-04-07 22:10:50 +00:00
oldPlatforms = platforms ;
2021-03-06 14:31:56 +00:00
assert . strictEqual ( oldPlatforms . length , 3 ) ;
assert . strictEqual ( oldPlatforms [ 0 ] [ 'name' ] , 'Mavericks' ) ;
assert . strictEqual ( oldPlatforms [ 1 ] [ 'name' ] , 'Mountain Lion' ) ;
assert . strictEqual ( oldPlatforms [ 2 ] [ 'name' ] , 'Trunk Mountain Lion' ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return TestServer . remoteAPI ( ) . postFormUrlencodedData ( '/admin/platforms.php' ,
{ 'action' : 'merge' , 'id' : oldPlatforms [ 1 ] [ 'id' ] , 'destination' : oldPlatforms [ 2 ] [ 'id' ] } ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . selectAll ( 'platforms' ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( newPlatforms ) => {
2021-03-06 14:31:56 +00:00
assert . strictEqual ( newPlatforms . length , 2 ) ;
assert . deepStrictEqual ( newPlatforms [ 0 ] , oldPlatforms [ 0 ] ) ;
assert . deepStrictEqual ( newPlatforms [ 1 ] , oldPlatforms [ 2 ] ) ;
2017-03-15 03:19:02 +00:00
} ) ;
2016-04-07 22:10:50 +00:00
} ) ;
2017-03-15 03:19:02 +00:00
it ( "should move test runs from the merged platform to the destination platform" , ( ) => {
2016-04-07 22:10:50 +00:00
let oldTestRuns ;
const queryForRuns = 'SELECT * FROM test_runs, test_configurations, platforms WHERE run_config = config_id AND config_platform = platform_id ORDER by run_mean_cache' ;
const db = TestServer . database ( ) ;
2017-03-15 03:19:02 +00:00
return submitReport ( reportsForDifferentPlatforms ( ) ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . query ( queryForRuns ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( result ) => {
2016-04-07 22:10:50 +00:00
oldTestRuns = result . rows ;
2021-03-06 14:31:56 +00:00
assert . strictEqual ( oldTestRuns . length , 4 ) ;
assert . strictEqual ( oldTestRuns [ 0 ] [ 'platform_name' ] , 'Mavericks' ) ;
assert . strictEqual ( oldTestRuns [ 0 ] [ 'run_sum_cache' ] , 6 ) ;
assert . strictEqual ( oldTestRuns [ 1 ] [ 'platform_name' ] , 'Mountain Lion' ) ;
assert . strictEqual ( oldTestRuns [ 1 ] [ 'run_sum_cache' ] , 12 ) ;
assert . strictEqual ( oldTestRuns [ 2 ] [ 'platform_name' ] , 'Mountain Lion' ) ;
assert . strictEqual ( oldTestRuns [ 2 ] [ 'run_sum_cache' ] , 18 ) ;
assert . strictEqual ( oldTestRuns [ 3 ] [ 'platform_name' ] , 'Trunk Mountain Lion' ) ;
assert . strictEqual ( oldTestRuns [ 3 ] [ 'run_sum_cache' ] , 24 ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return TestServer . remoteAPI ( ) . postFormUrlencodedData ( '/admin/platforms.php' ,
{ 'action' : 'merge' , 'id' : oldTestRuns [ 1 ] [ 'platform_id' ] , 'destination' : oldTestRuns [ 3 ] [ 'platform_id' ] } ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . query ( queryForRuns ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( result ) => {
2016-04-07 22:10:50 +00:00
const newTestRuns = result . rows ;
2021-03-06 14:31:56 +00:00
assert . strictEqual ( newTestRuns . length , 4 ) ;
assert . strictEqual ( newTestRuns [ 0 ] [ 'run_id' ] , oldTestRuns [ 0 ] [ 'run_id' ] ) ;
assert . strictEqual ( newTestRuns [ 0 ] [ 'platform_name' ] , 'Mavericks' ) ;
assert . strictEqual ( newTestRuns [ 0 ] [ 'run_sum_cache' ] , 6 ) ;
assert . strictEqual ( newTestRuns [ 1 ] [ 'run_id' ] , oldTestRuns [ 1 ] [ 'run_id' ] ) ;
assert . strictEqual ( newTestRuns [ 1 ] [ 'platform_name' ] , 'Trunk Mountain Lion' ) ;
assert . strictEqual ( newTestRuns [ 1 ] [ 'run_sum_cache' ] , 12 ) ;
assert . strictEqual ( newTestRuns [ 2 ] [ 'run_id' ] , oldTestRuns [ 2 ] [ 'run_id' ] ) ;
assert . strictEqual ( newTestRuns [ 2 ] [ 'platform_name' ] , 'Trunk Mountain Lion' ) ;
assert . strictEqual ( newTestRuns [ 2 ] [ 'run_sum_cache' ] , 18 ) ;
assert . strictEqual ( newTestRuns [ 3 ] [ 'run_id' ] , oldTestRuns [ 3 ] [ 'run_id' ] ) ;
assert . strictEqual ( newTestRuns [ 3 ] [ 'platform_name' ] , 'Trunk Mountain Lion' ) ;
assert . strictEqual ( newTestRuns [ 3 ] [ 'run_sum_cache' ] , 24 ) ;
assert . strictEqual ( newTestRuns [ 1 ] [ 'run_config' ] , newTestRuns [ 3 ] [ 'run_config' ] ) ;
2017-03-15 03:19:02 +00:00
} ) ;
2016-04-07 22:10:50 +00:00
} ) ;
2017-03-15 03:19:02 +00:00
it ( "should move test configurations from the merged platform to the destination platform" , ( ) => {
2016-04-07 22:10:50 +00:00
let oldConfigs ;
const reports = reportsForDifferentPlatforms ( ) ;
reports [ 0 ] [ 'tests' ] = { "test" : { "metrics" : { "FrameRate" : { "baseline" : [ [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] ] } } } } ;
const queryForConfig = 'SELECT * from test_configurations, platforms, test_metrics'
+ ' where config_platform = platform_id and config_metric = metric_id and platform_name in ($1, $2) order by config_id' ;
const db = TestServer . database ( ) ;
2017-03-15 03:19:02 +00:00
return submitReport ( reports ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . query ( queryForConfig , [ reports [ 0 ] [ 'platform' ] , reports [ 2 ] [ 'platform' ] ] ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( result ) => {
2016-04-07 22:10:50 +00:00
oldConfigs = result . rows ;
2021-03-06 14:31:56 +00:00
assert . strictEqual ( oldConfigs . length , 2 ) ;
assert . strictEqual ( oldConfigs [ 0 ] [ 'platform_name' ] , reports [ 0 ] [ 'platform' ] ) ;
assert . strictEqual ( oldConfigs [ 0 ] [ 'metric_name' ] , 'FrameRate' ) ;
assert . strictEqual ( oldConfigs [ 0 ] [ 'config_type' ] , 'baseline' ) ;
assert . strictEqual ( oldConfigs [ 1 ] [ 'platform_name' ] , reports [ 2 ] [ 'platform' ] ) ;
assert . strictEqual ( oldConfigs [ 1 ] [ 'metric_name' ] , 'FrameRate' ) ;
assert . strictEqual ( oldConfigs [ 1 ] [ 'config_type' ] , 'current' ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return TestServer . remoteAPI ( ) . postFormUrlencodedData ( '/admin/platforms.php' ,
{ 'action' : 'merge' , 'id' : oldConfigs [ 0 ] [ 'platform_id' ] , 'destination' : oldConfigs [ 1 ] [ 'platform_id' ] } ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( ) => {
2016-04-07 22:10:50 +00:00
return db . query ( queryForConfig , [ reports [ 0 ] [ 'platform' ] , reports [ 2 ] [ 'platform' ] ] ) ;
2017-03-15 03:19:02 +00:00
} ) . then ( ( result ) => {
2016-04-07 22:10:50 +00:00
const newConfigs = result . rows ;
2021-03-06 14:31:56 +00:00
assert . strictEqual ( newConfigs . length , 2 ) ;
assert . strictEqual ( newConfigs [ 0 ] [ 'platform_name' ] , reports [ 2 ] [ 'platform' ] ) ;
assert . strictEqual ( newConfigs [ 0 ] [ 'metric_name' ] , 'FrameRate' ) ;
assert . strictEqual ( newConfigs [ 0 ] [ 'config_type' ] , 'baseline' ) ;
assert . strictEqual ( newConfigs [ 1 ] [ 'platform_name' ] , reports [ 2 ] [ 'platform' ] ) ;
assert . strictEqual ( newConfigs [ 1 ] [ 'metric_name' ] , 'FrameRate' ) ;
assert . strictEqual ( newConfigs [ 1 ] [ 'config_type' ] , 'current' ) ;
2017-03-15 03:19:02 +00:00
} ) ;
2016-04-07 22:10:50 +00:00
} ) ;
} ) ;