Vlad
Vlad

Reputation: 2773

Build run all the tests but it hangs - Jenkins

I have configured Jenkins server to build a JS project with Karma JS and export tests in xml format for JUnit reports inside Jenkins. The tests were created using QUnit. It was working well but now something changed and build runs all the tests but its never actually finishing. My repository is on a computer on my local network and I use VisualSVN and access it trough https.

Here is the output of the last build(Deleted most of the tests output):

Started by user admin
[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/workspace/Furniture Constructor
Updating https://my_server_address/FurnitureConstructor/dev at revision '2016-10-27T11:01:17.530 +0200'
U         karma.conf.js
At revision 240

[EnvInject] - Executing scripts and injecting environment variables after the SCM step.
[EnvInject] - Injecting as environment variables the properties content 
$=PHANTOMJS_BIN=/usr/local/bin/phantomjs #or wherever PhantomJS happens to be installed

[EnvInject] - Variables injected successfully.
[Furniture Constructor] $ /bin/sh -xe /tmp/hudson7184342012546118229.sh
+ npm install
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN unmet dependency /var/lib/jenkins/workspace/Furniture Constructor/node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/node_modules/tap/node_modules/nyc/node_modules/yargs/node_modules/cliui requires string-width@'^1.0.1' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
[Furniture Constructor] $ /bin/sh -xe /tmp/hudson2287766122018752412.sh
+ karma start
[33m27 10 2016 11:01:23.629:WARN [karma]: [39mNo captured browser, open http://localhost:9876/
[32m27 10 2016 11:01:23.654:INFO [karma]: [39mKarma v1.3.0 server started at http://localhost:9876/
[32m27 10 2016 11:01:23.655:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[32m27 10 2016 11:01:23.750:INFO [launcher]: [39mStarting browser PhantomJS
[32m27 10 2016 11:01:24.400:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: [39mConnected on socket /#IAfAEFc2pEmxR12RAAAA with id 75925426
PhantomJS 2.1.1 (Linux 0.0.0) LOG: Object{millsPerPixel: 7, millsPerPixelForDepth: 16, cupboardWidth: 2500, cupboardHeight: 2500, cupboardDepth: 700, leftShelveWidth: 250, rightShelveWidth: 250, thickness: 30, floorChkBox: true, ceilingChkBox: true, leftShelveChkBox: true, rightShelveChkBox: true, rearChkBox: true, standLeftChkBox: true, standRightChkBox: true, standChkBox: true, shelveCssColor: '#3d6990', fullWidth: 3000, maxNumOfShelves: 25, maxNumOfInnerShelves: 25, maxNumOfBeams: 25}

PhantomJS 2.1.1 (Linux 0.0.0) LOG: Object{millsPerPixel: 7, millsPerPixelForDepth: 16, cupboardWidth: 2500, cupboardHeight: 2500, cupboardDepth: 700, leftShelveWidth: 250, rightShelveWidth: 250, thickness: 30, floorChkBox: true, ceilingChkBox: true, leftShelveChkBox: true, rightShelveChkBox: true, rearChkBox: true, standLeftChkBox: true, standRightChkBox: true, standChkBox: true, shelveCssColor: '#3d6990', fullWidth: 3000, maxNumOfShelves: 25, maxNumOfInnerShelves: 25, maxNumOfBeams: 25}


[1A[2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 1070 SUCCESS (0 secs / 0 secs)
[1A[2KLOG: 'QUnit Parametrize Plugin Meta Tests'
PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 1070 SUCCESS (0 secs / 0 secs)
[1A[2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 1070 SUCCESS (0 secs / 0.003 secs)
[1A[2KLOG: 'QUnit Parametrize Plugin Meta Tests'
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 1070 SUCCESS (0 secs / 0.003 secs)
[1A[2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 1069 of 1070 (46 FAILED) (0 secs / 4.852 secs)
[1A[2KLOG: 'QUnit Parametrize Plugin Meta Tests'
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1069 of 1070 (46 FAILED) (0 secs / 4.852 secs)
[1A[2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 1070 of 1070 (46 FAILED) (0 secs / 4.852 secs)
[1A[2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 1070 of 1070 (46 FAILED) (5.106 secs / 4.852 secs)

My Karma config file looks like this:

// Karma configuration
// Generated on Tue Oct 25 2016 13:03:04 GMT+0200 (CEST)

module.exports = function(config) {'use strict';
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['qunit'],


    // list of files / patterns to load in the browser
    files: [
    'js/jquery.min.js',
    'js/phaser.min.js',
    'Testing/unit_tests/js/qunit-parameterize.js',
    'Testing/unit_tests/js/tests/FrnConstrMock.js',
    'js/utils/Utility.js',
    'js/utils/Constants.js',
    'js/utils/InnerSlotMatrixUtility.js',
    'js/utils/GraphicsUtility.js',
    'js/utils/ProcessDataUtility.js',
    'js/utils/FrnConstrErrors.js',
    'js/utils/FrnConstrMessages.js',
    'js/State.js',
    'js/Screens/Boot.js',
    'js/UI/FrnConstrButton.js',
    'js/UI/GoToScreen.js',
    'js/UI/GoToUrl.js',
    'js/Screens/Screen.js',
    'js/Screens/Preloader.js',
    'js/Screens/EnteriorScreen.js',
    'js/Screens/ExteriorScreen.js',
    'js/Screens/SendApplicationScreen.js',
    'js/Screens/TestScreen.js',
    'js/InitFrnConstrForm.js',
    'Testing/unit_tests/js/tests/stubs/**/*.js',
    'Testing/unit_tests/js/tests/*.js'
    ],


    // list of files to exclude
    exclude: [
    'Testing/unit_tests/js/tests/**/FrnConstrStub.js'
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    //'Testing/unit_tests/js/**/*.js': ['coverage'],
    //'js/**/*.js': ['coverage']
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress', 'junit'/*, 'coverage'*/],

    // the default configuration
    junitReporter: {
      outputDir: 'test-reports', // results will be saved as $outputDir/$browserName.xml
      outputFile: 'test-results.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
      suite: '', // suite will become the package name attribute in xml testsuite element
      useBrowserName: true, // add browser name to report and classes names
      nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
      classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
      properties: {} // key value pair of properties to add to the <properties> section of the report
    },


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [/*'Chrome', 'Firefox', */'PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity,

    // client configuration
    client: {
      clearContext: false,
      qunit: {
    showUI: true,
    testTimeout: 5000,
    filter: ''
      }
    }//,

    // optionally, configure the reporter
    /*coverageReporter: {
    type : 'html',
    dir : 'coverage/'
    }*/
  });
}

I thought the "coverage" reporter was causing it to hang so I commented it out. No, it is still hanging even without "coverage" reporter.

I also found Thread Dump page, and it has lot of info which I don't understand. I have to find a way to share it, it surpasses 30000 number of characters to post it. Would it be useful?

Any ideas why the build hangs?

Upvotes: 0

Views: 2065

Answers (1)

Vlad
Vlad

Reputation: 2773

This

singleRun: false

was causing PhantomJS to hang. Set it to true, to stop PhantomJS when the tests are over.

You can also make separate config file for karma, like karma.conf.local.js and run it using the command:

karma start karma.conf.local.js // useful for local testing, no Jenkins

This will prevent the need to edit the config file all the time for Jenkins.

Upvotes: 1

Related Questions