TeamCity:PhantomJS 没有在 60000 毫秒内捕获,正在杀死
TeamCity: PhantomJS have not captured in 60000 ms, killing
我在 CI 环境中进行 运行 测试时遇到问题。该配置在 MacOS 10.11.6 (El Capitan) 和 Node v6.0.0 / npm 3.8.6 上运行良好,但在 TeamCity 9.1.6 代理 运行 Windows 上与 Node v4.2.2 / npm 2.14.7,惨败,报错PhantomJS have not captured in 60000 ms
.
这是 TeamCity 上的示例堆栈跟踪:
[08:58:40][exec] 02 11 2016 08:58:41.095:DEBUG [config]: autoWatch set to false, because of singleRun
[08:58:40][exec] 02 11 2016 08:58:41.102:DEBUG [plugin]: Loading plugin karma-jasmine.
[08:58:40][exec] 02 11 2016 08:58:41.107:DEBUG [plugin]: Loading plugin karma-chrome-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.121:DEBUG [plugin]: Loading plugin karma-firefox-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.128:DEBUG [plugin]: Loading plugin karma-phantomjs-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.263:DEBUG [web-server]: Instantiating middleware
[08:58:41][exec] 02 11 2016 08:58:41.595:INFO [karma]: Karma v1.3.0 server started at http://localhost:9877/
[08:58:41][exec] 02 11 2016 08:58:41.596:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
[08:58:41][exec] 02 11 2016 08:58:41.616:INFO [launcher]: Starting browser PhantomJS
[08:58:41][exec] 02 11 2016 08:58:41.618:DEBUG [temp-dir]: Creating temp dir at E:\TCA\temp\buildTmp\karma-47802965
[08:58:41][exec] 02 11 2016 08:58:41.631:DEBUG [launcher]: E:\TCA\work\f900f2fe23d6c9b0\Preview\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs E:\TCA\temp\buildTmp\karma-47802965/capture.js
[08:59:41][exec] 02 11 2016 08:59:41.621:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
[08:59:43][exec] 02 11 2016 08:59:43.624:WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
[08:59:45][exec] 02 11 2016 08:59:45.627:WARN [launcher]: PhantomJS was not killed by SIGKILL in 2000 ms, continuing.
[08:59:45][exec] 02 11 2016 08:59:45.628:DEBUG [launcher]: Process PhantomJS exited with code -1
[08:59:45][exec] 02 11 2016 08:59:45.629:DEBUG [temp-dir]: Cleaning temp dir E:\TCA\temp\buildTmp\karma-47802965
[08:59:45][exec] 02 11 2016 08:59:45.637:DEBUG [launcher]: PhantomJS failed (timeout). Not restarting.
[08:59:45][exec] 02 11 2016 08:59:45.638:DEBUG [karma]: Run complete, exiting.
[08:59:45][exec] 02 11 2016 08:59:45.639:DEBUG [launcher]: Disconnecting all browsers
[08:59:45][exec] Warning: Task "karma:unit" failed. Use --force to continue.
[08:59:45][exec]
[08:59:45][exec] Aborted due to warnings.
[08:59:45][exec] npm ERR! Test failed. See above for more details.
这是 package.json 的片段:
"devDependencies": {
"bower": "latest",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-istanbul-coverage": "^0.1.4",
"grunt-karma": "^2.0.0",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"jasmine-core": "^2.5.2",
"matchdep": "^1.0.1"
},
"scripts": {
"postinstall": "node ./node_modules/bower/bin/bower install",
"test": "node ./node_modules/.bin/grunt default"
}
这里是 karma.conf.js 的片段:
module.exports = function (config) {
'use strict';
config.set({
frameworks: ['jasmine'],
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
],
files: [
<...>
],
exclude: [],
preprocessors: {
},
reporters: ['progress']
port: 9877,
runnerPort: 9101,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['PhantomJS'],
captureTimeout: 60000,
singleRun: true
});
我在本地遇到了 PhantomJS have not captured in 60000 ms, killing
问题,经过一些试验后发现它可能是由以下原因引起的:
- 可从类路径获得的 PhantomJS 与可获得的 PhantomJS 之间的冲突
phatomjs-prebuilt
下载到项目的 node_modules。我刚刚删除了全球可用的。
- 缺少
PHANTOMJS_CDNURL
环境(系统)变量,指向 Maven 存储库,检查 where to get PhantomJS。
问题已解决!在我们的 CI 环境中,我们没有通过 运行 npm install
获取节点模块 - 我们在本地压缩 node_modules 目录并将其添加到我们的源代码中。
将其压缩到 Mac 并在 Windows 上将其分解并尝试使用这些模块,尤其是 phantomjs-prebuilt
,这就是它没有捕获的原因。
我从 Windows 压缩了它,它工作得很好。
我在 CI 环境中进行 运行 测试时遇到问题。该配置在 MacOS 10.11.6 (El Capitan) 和 Node v6.0.0 / npm 3.8.6 上运行良好,但在 TeamCity 9.1.6 代理 运行 Windows 上与 Node v4.2.2 / npm 2.14.7,惨败,报错PhantomJS have not captured in 60000 ms
.
这是 TeamCity 上的示例堆栈跟踪:
[08:58:40][exec] 02 11 2016 08:58:41.095:DEBUG [config]: autoWatch set to false, because of singleRun
[08:58:40][exec] 02 11 2016 08:58:41.102:DEBUG [plugin]: Loading plugin karma-jasmine.
[08:58:40][exec] 02 11 2016 08:58:41.107:DEBUG [plugin]: Loading plugin karma-chrome-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.121:DEBUG [plugin]: Loading plugin karma-firefox-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.128:DEBUG [plugin]: Loading plugin karma-phantomjs-launcher.
[08:58:40][exec] 02 11 2016 08:58:41.263:DEBUG [web-server]: Instantiating middleware
[08:58:41][exec] 02 11 2016 08:58:41.595:INFO [karma]: Karma v1.3.0 server started at http://localhost:9877/
[08:58:41][exec] 02 11 2016 08:58:41.596:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
[08:58:41][exec] 02 11 2016 08:58:41.616:INFO [launcher]: Starting browser PhantomJS
[08:58:41][exec] 02 11 2016 08:58:41.618:DEBUG [temp-dir]: Creating temp dir at E:\TCA\temp\buildTmp\karma-47802965
[08:58:41][exec] 02 11 2016 08:58:41.631:DEBUG [launcher]: E:\TCA\work\f900f2fe23d6c9b0\Preview\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs E:\TCA\temp\buildTmp\karma-47802965/capture.js
[08:59:41][exec] 02 11 2016 08:59:41.621:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
[08:59:43][exec] 02 11 2016 08:59:43.624:WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
[08:59:45][exec] 02 11 2016 08:59:45.627:WARN [launcher]: PhantomJS was not killed by SIGKILL in 2000 ms, continuing.
[08:59:45][exec] 02 11 2016 08:59:45.628:DEBUG [launcher]: Process PhantomJS exited with code -1
[08:59:45][exec] 02 11 2016 08:59:45.629:DEBUG [temp-dir]: Cleaning temp dir E:\TCA\temp\buildTmp\karma-47802965
[08:59:45][exec] 02 11 2016 08:59:45.637:DEBUG [launcher]: PhantomJS failed (timeout). Not restarting.
[08:59:45][exec] 02 11 2016 08:59:45.638:DEBUG [karma]: Run complete, exiting.
[08:59:45][exec] 02 11 2016 08:59:45.639:DEBUG [launcher]: Disconnecting all browsers
[08:59:45][exec] Warning: Task "karma:unit" failed. Use --force to continue.
[08:59:45][exec]
[08:59:45][exec] Aborted due to warnings.
[08:59:45][exec] npm ERR! Test failed. See above for more details.
这是 package.json 的片段:
"devDependencies": {
"bower": "latest",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-istanbul-coverage": "^0.1.4",
"grunt-karma": "^2.0.0",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"jasmine-core": "^2.5.2",
"matchdep": "^1.0.1"
},
"scripts": {
"postinstall": "node ./node_modules/bower/bin/bower install",
"test": "node ./node_modules/.bin/grunt default"
}
这里是 karma.conf.js 的片段:
module.exports = function (config) {
'use strict';
config.set({
frameworks: ['jasmine'],
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
],
files: [
<...>
],
exclude: [],
preprocessors: {
},
reporters: ['progress']
port: 9877,
runnerPort: 9101,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['PhantomJS'],
captureTimeout: 60000,
singleRun: true
});
我在本地遇到了 PhantomJS have not captured in 60000 ms, killing
问题,经过一些试验后发现它可能是由以下原因引起的:
- 可从类路径获得的 PhantomJS 与可获得的 PhantomJS 之间的冲突
phatomjs-prebuilt
下载到项目的 node_modules。我刚刚删除了全球可用的。 - 缺少
PHANTOMJS_CDNURL
环境(系统)变量,指向 Maven 存储库,检查 where to get PhantomJS。
问题已解决!在我们的 CI 环境中,我们没有通过 运行 npm install
获取节点模块 - 我们在本地压缩 node_modules 目录并将其添加到我们的源代码中。
将其压缩到 Mac 并在 Windows 上将其分解并尝试使用这些模块,尤其是 phantomjs-prebuilt
,这就是它没有捕获的原因。
我从 Windows 压缩了它,它工作得很好。