Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
#

[codespell]
ignore-words-list = thirdparty,afterall,AfterAll
ignore-words-list = thirdparty,afterall,AfterAll,assignin
24 changes: 24 additions & 0 deletions build-tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ RUN apt-get update && apt-get install --no-install-recommends -y nodejs npm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /root/.npm

#####################
# Install Chrome Required for tez-ui ember tests #
#####################
# hadolint ignore=DL3008
RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg \
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get -q update \
&& apt-get -q install --no-install-recommends -y google-chrome-stable \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Create a google-chrome wrapper so that testem 0.9.11 (bundled in ember-cli
# 1.13.14) can find and launch Chrome headlessly. testem 0.9.11 calls
# 'google-chrome' via 'which' with hardcoded non-headless args and ignores
# browser_args/CHROME_BIN config. This wrapper injects the required headless
# flags before forwarding all arguments to the real binary.
# hadolint ignore=DL3059
RUN printf '#!/bin/bash\nexec /usr/bin/google-chrome-stable --headless --disable-gpu --no-sandbox --disable-dev-shm-usage "$@"\n' \
> /usr/local/bin/google-chrome \
&& chmod +x /usr/local/bin/google-chrome
ENV CHROME_BIN=google-chrome-stable

################################
# Copy over parallel downloads #
################################
Expand Down
54 changes: 53 additions & 1 deletion tez-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,59 @@ You will need the following things properly installed on your computer.

### Running Tests

* `yarn test`
Tests run in **headless Chrome**.

The build automatically resolves a Chrome/Chromium binary using the following priority:

1. `$CHROME_BIN` environment variable (if set and executable)
2. Well-known system locations (`/Applications/Google Chrome.app` on macOS,
`google-chrome-stable` / `chromium-browser` on Linux)
3. **Puppeteer's bundled Chromium** — downloaded automatically during `yarn install`
(which Maven runs as part of the build), so the build works on a vanilla machine
with no pre-installed Chrome.

#### Step 1 (optional): Set `CHROME_BIN` to override Chrome detection

On Linux:

```bash
export CHROME_BIN=google-chrome-stable
```

On macOS:

```bash
export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
```

If `CHROME_BIN` is not set, the launcher falls back to the steps above automatically.

#### Step 2: Run the tests

Via Maven (from the `tez-ui` directory):

```bash
mvn clean install
```

If `CHROME_BIN` is not set in your environment, you can also pass the Chrome path
directly as a Maven property:

```bash
mvn clean install -Dchrome.bin="/path/to/Google Chrome"
```

Via Yarn (from inside `src/main/webapp`):

```bash
yarn test
```

To skip tests:

```bash
mvn clean package -DskipTests
```

### Building

Expand Down
13 changes: 9 additions & 4 deletions tez-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
<allow-root-build>--allow-root=false</allow-root-build>

<skipTests>false</skipTests>

<!--
Chrome binary used by testem for headless UI tests.
Override on the command line: -Dchrome.bin="/path/to/chrome"
Falls back to google-chrome-stable when not overridden.
-->
<chrome.bin>google-chrome-stable</chrome.bin>
</properties>

<profiles>
Expand Down Expand Up @@ -92,8 +99,7 @@
<argument>test:mvn</argument>
</arguments>
<environmentVariables>
<!-- workaround for systems using a newer OpenSSL (3+) which is incompatible with PhantomJS -->
<OPENSSL_CONF>/dev/null</OPENSSL_CONF>
<CHROME_BIN>${chrome.bin}</CHROME_BIN>
</environmentVariables>
</configuration>
</execution>
Expand Down Expand Up @@ -154,8 +160,7 @@
<argument>test:mvn</argument>
</arguments>
<environmentVariables>
<!-- workaround for systems using a newer OpenSSL (3+) which is incompatible with PhantomJS -->
<OPENSSL_CONF>/dev/null</OPENSSL_CONF>
<CHROME_BIN>${chrome.bin}</CHROME_BIN>
</environmentVariables>
</configuration>
</execution>
Expand Down
8 changes: 4 additions & 4 deletions tez-ui/src/main/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"start": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember server",
"test": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember test",
"test-serve": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember test --serve",

"build:mvn": "TMPDIR=tmp node/node ./node_modules/ember-cli/bin/ember build -prod",
"test:mvn": "TMPDIR=tmp node/node ./node_modules/ember-cli/bin/ember test"
},
Expand All @@ -26,6 +25,7 @@
},
"devDependencies": {
"bower": "1.8.4",
"bower-shrinkwrap-resolver-ext": "^0.1.0",
"broccoli-asset-rev": "2.4.2",
"broccoli-funnel": "1.0.1",
"broccoli-merge-trees": "1.1.1",
Expand Down Expand Up @@ -55,15 +55,15 @@
"ember-export-application-global": "1.0.5",
"ember-resolver": "^2.0.3",
"ember-truth-helpers": "1.3.0",
"bower-shrinkwrap-resolver-ext": "^0.1.0",
"loader.js": "4.2.3",
"testem": "0.9.11",
"phantomjs-prebuilt": "2.1.13"
"puppeteer": "1.20.0",
"testem": "1.18.5"
},
"dependencies": {
"em-tgraph": "0.0.14"
},
"resolutions": {
"moment": "2.30.1",
"**/form-data/async": "2.6.4",
"**/mkdirp/minimist": "1.2.6",
"**/optimist/minimist": "1.2.6",
Expand Down
73 changes: 73 additions & 0 deletions tez-ui/src/main/webapp/scripts/chrome-launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Locates Chrome/Chromium and launches it with the given arguments.
# Search order:
# 1. $CHROME_BIN (if set and executable)
# 2. Platform-specific well-known locations / PATH entries
# 3. puppeteer's auto-downloaded Chromium
#
# Adding "puppeteer" as a devDependency in package.json means that
# "yarn install" (run automatically by Maven) will download a bundled
# Chromium, so the build works on a vanilla machine with no pre-installed
# Chrome/Chromium.

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
WEBAPP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

# Returns the path to puppeteer's bundled Chromium binary, if present.
find_puppeteer_chromium() {
_pptr_dir="$WEBAPP_DIR/node_modules/puppeteer/.local-chromium"
if [ -d "$_pptr_dir" ]; then
find "$_pptr_dir" \( -name "chrome" -o -name "Chromium" \) -type f 2>/dev/null | head -1
fi
}

# 1. Honour an explicit CHROME_BIN override
if [ -n "$CHROME_BIN" ] && command -v "$CHROME_BIN" > /dev/null 2>&1; then
exec "$CHROME_BIN" "$@" > /dev/null 2>&1
fi

# 2. Platform-specific well-known locations
case "$(uname -s)" in
Darwin)
MAC_CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
if [ -x "$MAC_CHROME" ]; then
exec "$MAC_CHROME" "$@" > /dev/null 2>&1
fi
;;
*)
# Linux and other Unix-like systems – try common binary names in PATH
for CHROME in google-chrome-stable google-chrome chromium-browser chromium; do
if command -v "$CHROME" > /dev/null 2>&1; then
exec "$CHROME" "$@" > /dev/null 2>&1
fi
done
;;
esac

# 3. Fall back to puppeteer's auto-downloaded Chromium
PUPPETEER_CHROME="$(find_puppeteer_chromium)"
if [ -n "$PUPPETEER_CHROME" ] && [ -x "$PUPPETEER_CHROME" ]; then
exec "$PUPPETEER_CHROME" "$@" > /dev/null 2>&1
fi

echo "ERROR: No Chrome/Chromium found. Install Google Chrome or Chromium, or set CHROME_BIN." >&2
echo " Alternatively, run 'yarn install' inside src/main/webapp to let puppeteer download Chromium automatically." >&2
exit 1


12 changes: 10 additions & 2 deletions tez-ui/src/main/webapp/testem.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"browser_start_timeout": 120,
"timeout": 300,
"exit_timeout": 5,
"launchers": {
"Chrome": {
"command": "scripts/chrome-launcher.sh --headless --disable-gpu --no-sandbox --disable-dev-shm-usage --no-default-browser-check --no-first-run --ignore-certificate-errors --test-type <url>",
"protocol": "browser"
}
},
"launch_in_ci": [
"PhantomJS"
"Chrome"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
}
3 changes: 2 additions & 1 deletion tez-ui/src/main/webapp/tests/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"andThen",
"currentURL",
"currentPath",
"currentRouteName"
"currentRouteName",
"QUnit"
],
"node": false,
"browser": false,
Expand Down
9 changes: 9 additions & 0 deletions tez-ui/src/main/webapp/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ import {
} from 'ember-qunit';

setResolver(resolver);

QUnit.done(function() {
// After all tests complete, the qunit_adapter sends 'all-test-results' to testem
// via Socket.IO through two nested setTimeout(0) calls. We wait 500ms to ensure
// the message is flushed before we close the browser.
setTimeout(function() {
window.close();
}, 500);
});
Loading