Get help with testing, discuss unit testing strategies etc.


Post by stenjo »

Have been trying to find if anyone else has had the same issue, but have had no luck so far.
I'm running unittests in a docker container using a ubuntu image.
Siesta 5.5.1 is installed and seems to be running.

Trying to run tests gives this result:

2021-04-13_15-50-00.png
2021-04-13_15-50-00.png (14.28 KiB) Viewed 4281 times

That is, running:

root@5f633c56c5e8:/home/pp/wellcom-mono/ProjectPlannerUI# ../sdk/siesta/bin/webdriver localhost/tests/unittests-no-ui.html?onserver=1 --browser chrome --pause 0 --headless

Produces:

[ERROR] Setup failed: Error: Can't create first page, runner: a Siesta.Launcher.Runner.WebDriverNodeJS, exception: WebDriverError: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

I know google-chrome is available and runnable - but later changes to chrome does not allow for running headless from root. May this be the cause, or are there other options?

Chrome is installed and available in path;

whereis google-chrome
google-chrome: /usr/bin/google-chrome
google-chrome --headless
[0413/160831.834003:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
google-chrome --headless --no-sandbox
[0413/160941.923451:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[0413/160941.923835:WARNING:headless_browser_main_parts.cc(83)] Cannot create Pref Service with no user data dir.

Post by nickolay »

Hi,

It might be possible that there's a mismatch between the installed Chrome and ChromeDriver version. Those versions need to match. Please try downloading the matching version of ChromeDriver from https://chromedriver.chromium.org/ and place the binaries to the /siesta/bin/binary/chromedriver


Post by nickolay »

You can check the ChromeDriver version with siesta/bin/binary/chromedriver/linux64/chromedriver --version


Post by stenjo »

root@5f633c56c5e8:/home/pp/wellcom-mono/ProjectPlannerUI# google-chrome --version
Google Chrome 89.0.4389.114 
root@5f633c56c5e8:/home/pp/wellcom-mono/ProjectPlannerUI# ../sdk/siesta/bin/binary/chromedriver/linux64/chromedriver --version
ChromeDriver 89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294})

Sufficiently equal? Still failing the same way


Post by nickolay »

Yes, should be sufficiently equal.

Can you try with puppeteer launcher? If Chrome really fails to start in the container it should also fail..

Perhaps this line is the rootcause:

[0413/160941.923451:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

May be no dbus package in the container?


Post by stenjo »

Created a test file test.js containing:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('localhost/tests');
  await page.screenshot({ path: 'example.png' });

  await browser.close();
})();
root@5f633c56c5e8:/home/pp/wellcom-mono/ProjectPlannerUI# node test.js 
(node:260) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0413/164606.524645:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/home/pp/wellcom-mono/ProjectPlannerUI/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at Interface.helper_js_1.helper.addEventListener (/home/pp/wellcom-mono/ProjectPlannerUI/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
at Interface.emit (events.js:203:15)
at Interface.close (readline.js:397:8)
at Socket.onend (readline.js:173:10)
at Socket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:260) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:260) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Post by nickolay »

Yup, something with the Chrome prerequisites I guess


Post by stenjo »

In spite of heavy googling, I have not been successful in solving the issue with dbus. Might be some chrome prerequisites, but really difficult to debug (that is: have had no success).
Your suggestion on running puppeteer inspired me to try that path as well:
Running in github actions:

##[debug]Loading env
Run chmod a+x ../sdk/siesta/bin/puppeteer
  chmod a+x ../sdk/siesta/bin/puppeteer
  chmod a+x ../sdk/siesta/bin/binary/nodejs/linux64/node
  # ../sdk/siesta/bin/puppeteer https://127.0.0.1:80/tests/unittests-no-ui.html?onserver=1 --browser chrome --pause 0 --headless
  ../sdk/siesta/bin/puppeteer https://127.0.0.1:80/tests/unittests-no-ui.html
  shell: /usr/bin/bash -e {0}
  env:
    TEST_BASE_URL: https://127.0.0.1:80
    SENCHA_CMD_V: 7.3.0.19
    _JAVA_OPTIONS: -Xms512m -Xmx1512m -XX:-UseGCOverheadLimit
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/12.0.2-3/x64
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]/usr/bin/bash -e /home/runner/work/_temp/9bb84811-2ae1-4c60-86dd-09600661ee06.sh

[ERROR] The project page you are targeting contains Siesta Lite distribution. To use automation facilities, 
make sure project page uses `siesta-all.js` from Standard or Trial packages
[ERROR] Setup failed: Error: Error while opening project page: 5
Error: Process completed with exit code 5.
##[debug]Finishing: Run tests on SchedulerUI

Have tried to find out of this error - what does it mean?


Post by nickolay »

Hm.. Perhaps you could start with some docker container that already has Chrome? May be there's "official" container for Chrome?

Anyway, this error means that the project web page https://127.0.0.1:80/tests/unittests-no-ui.html contains a Siesta version w/o the automation package (Siesta Lite). Need to make sure the project web page and the launcher binary uses the same Siesta package.


Post by stenjo »

We've managed to run the siesta unit tests in a github workflow using the below script.
This serves as a first check on any pull-requests we create that modifies any of the sencha-based code.

To make this work we have all the siesta files checked stored in a common "sdk" directory that is checked out together with the code to be tested. Then we install Node, Java and installs sencha command (created a simple action to do that). Part of this workflow is to run jshint before the tests are run using puppeteer after starting a local webserver.

There is most certainly simplifications possible, but for us, this works like charm.

For others benefit, I leave a simplified script here:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      TEST_BASE_URL: localhost:80
      _JAVA_OPTIONS: -Xms512m -Xmx1512m -XX:-UseGCOverheadLimit
      SDK_PATH: /home/runner/work/wellcom-mono/wellcom-mono/sdk
      BUILD_PATH: ProjectPlannerUI
      TEST_PATH: tests
        
steps: - name: Use Java 12 - zulu distro uses: actions/setup-java@v2 with: distribution: 'zulu' java-version: '12' - name: Use Node.js 10.x uses: actions/setup-node@v1 with: node-version: 10.x - name: Chekcout ${{ env.BUILD_PATH }}/ and sdk/ run: | *** sparse checkout of both the sdk folder and the code to be tested *** - uses: equinor/sencha-cmd@v1 - name: Lint ${{ env.BUILD_PATH }}/app working-directory: ./${{ env.BUILD_PATH }} run: | npm install jshint --save-dev ./node_modules/jshint/bin/jshint app/ - name: Build app working-directory: ./${{ env.BUILD_PATH }} run: sencha app build - name: Set up webserver working-directory: ./${{ env.BUILD_PATH }} run: | sudo cp -R ./* /var/www/html sudo service apache2 restart curl $TEST_BASE_URL/${{env.TEST_PATH}}/unittests-no-ui.html - name: Run tests on ${{ env.BUILD_PATH }} working-directory: ./${{ env.BUILD_PATH }} run: | ${{ env.SDK_PATH}}/siesta/bin/puppeteer ${{ env.TEST_BASE_URL}}/${{env.TEST_PATH}}/unittests-no-ui.html?onserver=1 --max-workers 4

Post Reply