From 15e671ec5a7527dae9c006073ff6b25e85142e16 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 2 Nov 2018 13:43:06 -0700 Subject: [PATCH] build(bazel): upgrade benchmarks to protractor_web_test_suite for CI without local chrome (#26908) PR Close #26908 --- .../src/largetable/render3/BUILD.bazel | 6 +-- .../benchmarks/src/tree/render3/BUILD.bazel | 6 +-- .../bazel/src/protractor/protractor.conf.js | 40 +++++++++++++++---- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/modules/benchmarks/src/largetable/render3/BUILD.bazel b/modules/benchmarks/src/largetable/render3/BUILD.bazel index 5ee3abc817..df6a24d3a5 100644 --- a/modules/benchmarks/src/largetable/render3/BUILD.bazel +++ b/modules/benchmarks/src/largetable/render3/BUILD.bazel @@ -1,7 +1,7 @@ package(default_visibility = ["//visibility:public"]) load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle") -load("//packages/bazel:index.bzl", "protractor_web_test") +load("//packages/bazel:index.bzl", "protractor_web_test_suite") load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") ng_module( @@ -50,7 +50,7 @@ ts_devserver( tags = ["ivy-only"], ) -protractor_web_test( +protractor_web_test_suite( name = "perf", configuration = "//:protractor-perf.conf.js", data = [ @@ -64,8 +64,6 @@ protractor_web_test( on_prepare = ":protractor.on_prepare.js", server = ":devserver", tags = [ - "fixme-ivy-aot", - "fixme-ivy-jit", "ivy-only", ], deps = [ diff --git a/modules/benchmarks/src/tree/render3/BUILD.bazel b/modules/benchmarks/src/tree/render3/BUILD.bazel index ccddfe04e4..e9cb5f1d09 100644 --- a/modules/benchmarks/src/tree/render3/BUILD.bazel +++ b/modules/benchmarks/src/tree/render3/BUILD.bazel @@ -1,7 +1,7 @@ package(default_visibility = ["//visibility:public"]) load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle") -load("//packages/bazel:index.bzl", "protractor_web_test") +load("//packages/bazel:index.bzl", "protractor_web_test_suite") load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") ng_module( @@ -48,7 +48,7 @@ ts_devserver( tags = ["ivy-only"], ) -protractor_web_test( +protractor_web_test_suite( name = "perf", configuration = "//:protractor-perf.conf.js", data = [ @@ -58,8 +58,6 @@ protractor_web_test( on_prepare = ":protractor.on_prepare.js", server = ":devserver", tags = [ - "fixme-ivy-aot", - "fixme-ivy-jit", "ivy-only", ], deps = [ diff --git a/packages/bazel/src/protractor/protractor.conf.js b/packages/bazel/src/protractor/protractor.conf.js index 28b8e72156..1c26660bcb 100644 --- a/packages/bazel/src/protractor/protractor.conf.js +++ b/packages/bazel/src/protractor/protractor.conf.js @@ -5,9 +5,6 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ - -const path = require('path'); - const DEBUG = false; const configPath = 'TMPL_config'; @@ -32,15 +29,44 @@ function setConf(conf, name, value, msg) { conf[name] = value; } +function mergeCapabilities(conf, capabilities) { + if (conf.capabilities) { + if (conf.capabilities.browserName === capabilities.browserName) { + // there are capabilities to merge + if (capabilities.browserName === 'chrome') { + conf.capabilities.chromeOptions = conf.capabilities.chromeOptions || {}; + conf.capabilities.chromeOptions.binary = capabilities.chromeOptions.binary; + conf.capabilities.chromeOptions.args = conf.capabilities.chromeOptions.args || []; + conf.capabilities.chromeOptions.args.push(...capabilities.chromeOptions.args); + console.warn( + `Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}' +which will be merged with capabilities provided by Bazel resulting in:`, + JSON.stringify(conf.capabilities, null, 2)); + } else { + // TODO(gmagolan): implement firefox support for protractor + throw new Error( + `Unexpected browserName ${capabilities.browserName} for capabilities merging`); + } + } else { + console.warn( + `Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}' which will be overwritten by Bazel`); + conf.capabilities = capabilities; + } + } else { + conf.capabilities = capabilities; + } +} + let conf = {}; // Import the user's base protractor configuration if specified if (configPath) { const baseConf = require(configPath); if (!baseConf.config) { - throw new Error('Invalid base protractor configration. Expected config to be exported.'); + throw new Error('Invalid base protractor configuration. Expected config to be exported.'); } conf = baseConf.config; + if (DEBUG) console.info(`Base protractor configuration: ${JSON.stringify(conf, null, 2)}`); } // Import the user's on prepare function if specified @@ -109,8 +135,8 @@ if (process.env['WEB_TEST_METADATA']) { } setConf(conf, 'directConnect', true, 'is set to true for chrome'); setConf(conf, 'chromeDriver', chromeDriver, 'is determined by the browsers attribute'); - setConf( - conf, 'capabilities', { + mergeCapabilities( + conf, { browserName: 'chrome', chromeOptions: { binary: chromeBin, @@ -131,7 +157,7 @@ if (process.env['WEB_TEST_METADATA']) { // } // setConf(conf, 'seleniumAddress', process.env.WEB_TEST_HTTP_SERVER.trim() + "/wd/hub", 'is // configured by Bazel for firefox browser') - // setConf(conf, 'capabilities', { + // mergeCapabilities(conf, { // browserName: "firefox", // 'moz:firefoxOptions': { // binary: firefoxBin,