Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running large test sets with chrome headless #137

Open
cullsin opened this issue Jun 12, 2017 · 19 comments
Open

Running large test sets with chrome headless #137

cullsin opened this issue Jun 12, 2017 · 19 comments

Comments

@cullsin
Copy link

cullsin commented Jun 12, 2017

Hi,

We are executing almost 2000 karma test cases. I am getting the following message. Can you please guide me.

12 06 2017 10:37:34.562:WARN [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Disconnected (1 times)
HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
Disconnectedundefined
HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
Disconnectedundefined
HeadlessChrome 0.0.0 (Linux 0.0.0): Executed 1900 of 2600 (skipped 68) DISCONNECTED (3 mins 30.945 secs / 50.046 secs)

Thanks,
Raja K

@rafinskipg
Copy link

same issue (running on , latest chrome and also with version 58)

@weikinhuang
Copy link

Happening for us as well, we have ~2000 tests. It passes completely fine when run in OSX, however when we run it in CI with chrome and karma in a docker container, it will fail about 1500 tests in.

@weikinhuang
Copy link

Additional notes: our Dockerfile is based off node:6.11-slim and google-chrome-stable installed via https://dl.google.com/linux/chrome/deb/

@javigd
Copy link

javigd commented Jul 3, 2017

Hi @weikinhuang we experienced the exact same problem as you and managed to fix it by chance by defining a custom launcher for it:

                browsers: ["Chrome-headless"],
                customLaunchers: {
                    "Chrome-headless": {
                        base: 'Chrome',
                        flags: ['--headless', '--remote-debugging-port=9222', '--no-sandbox']
                    }
                }

still a mystery why this solves the problem. Hope this helps 👍

@dafuster
Copy link

dafuster commented Aug 22, 2017

I was able to overcome the Chrome disconnects by adding this additional flag in my custom launcher:
--js-flags="--max_old_space_size=4096"

@rogeriopvl
Copy link
Collaborator

@javigd the only difference between your custom launcher and the default one is that it has the --no-sandbox flag and doesn't have the --disable-gpu flag. So I would say that one of these may be causing the issue.

I'm going to need help investigating this, since I don't have large enough battery of tests to replicate
the issue 🤔

@martynchamberlin
Copy link

Just wanted to weigh in and say that we were having this issue with 445 tests. Passing --no-sandbox also seems to have fixed the problem.

@martynchamberlin
Copy link

Update: scratch that. Only about half the time does running our test suite cause this error, so it's hard to know when it's actually been fixed. Still getting this error.

@x3igh7
Copy link

x3igh7 commented Nov 16, 2017

@dafuster what exactly does your customer launcher look like with --js-flags="--max_old_space_size=4096" ? doesn't really seem to do anything for me

@macjohnny
Copy link

macjohnny commented Feb 9, 2018

we are also experiencing the issue described.
Using karma-spec-reporter we get an information about which test causes an issue.

@mashhoodr
Copy link

Also experiencing this problem, we have around 5700 tests but it breaks on 5600ish. Started happening a 2-3 weeks ago. Running fine on OSX, causing problem inside headless chrome docker container.

@jressey
Copy link

jressey commented Mar 1, 2018

This is probably not a satisfying response but I ran in to this today and solved by restarting my Mac.

@StoneMorKnight
Copy link

Also experiencing this issue with only 73 tests. Any movement on this? Restarting my Mac fixed it once but our environment is too heavy to rebuild constantly to get this working properly. Any other workarounds or solutions?

@cyrus-mc
Copy link

Experiencing this issue as well;

The oddity is it only fails during an actual docker build. If I exec into the intermediate container just prior to the RUN tests command and run the tests, it succeeds.

@ajorquera
Copy link

we had this issue the last couple of days. We solve it by using puppeteer. Hope it helps

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

process.env.CHROME_BIN = require('puppeteer').executablePath()

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
      require('karma-scss-preprocessor')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [{
        pattern: './test.ts',
        watched: false
      },
      {
        pattern: './styles/**/*.*',
        watched: true,
        included: true,
        served: true
      },
      {
        pattern: '../node_modules/cookieconsent/build/cookieconsent.min.js',
        watched: true,
        included: true,
        served: true
      },
      {
        pattern: '../node_modules/cookieconsent/build/cookieconsent.min.css',
        watched: true,
        included: true,
        served: true
      }
    ],
    preprocessors: {
      './styles/**/*.*': ['scss']
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    singleRun: false,
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox']
      }
    },
  });
};

@erwinheitzman
Copy link

We experienced the same and for us the cause was a memory leak in our tests which was causing these seemingly random errors while in reality we where sometimes hitting the memory limit. We fixed this by using the npm package karma-parallel after which we had the time to fix the actual memory leak. Hope this helps anyone struggling with this.

@ns89-web
Copy link

We experienced the same and for us the cause was a memory leak in our tests which was causing these seemingly random errors while in reality we where sometimes hitting the memory limit. We fixed this by using the npm package karma-parallel after which we had the time to fix the actual memory leak. Hope this helps anyone struggling with this.

Could you please explain how you tried to identify the memory leaks in your tests?

@hhyyg
Copy link

hhyyg commented Dec 6, 2020

I faced the same problem. Removing the extra component and module imports from the test fixed it. I also referred to this article. https://www.forbes.com/sites/forbesdigitalgroup/2019/05/14/improve-your-angular-jasmine-unit-test-speeds-by-500/

@cullsin
Copy link
Author

cullsin commented Dec 6, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests