当我在我的 Mac 上使用 Docker 本地运行以下设置时,一切正常。
但相同的设置不适用于在 Ubuntu 16.04 上运行的 Jenkins
ChromiumHeadless 在 60000 毫秒内没有捕获,正在杀死。
以下错误日志来自 Jenkins 控制台:
25 05 2018 06:35:09.076:INFO [karma]: Karma v2.0.2 server started at http://0.0.0.0:9222/
25 05 2018 06:35:09.079:INFO [launcher]: Launching browser Chromium_no_sandbox with unlimited concurrency
25 05 2018 06:35:09.090:INFO [launcher]: Starting browser ChromiumHeadless
25 05 2018 06:36:09.128:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
25 05 2018 06:36:09.139:INFO [launcher]: Trying to start ChromiumHeadless again (1/2).
25 05 2018 06:37:09.140:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
25 05 2018 06:37:09.147:INFO [launcher]: Trying to start ChromiumHeadless again (2/2).
Package.json ...
"testProd": "./node_modules/karma/bin/karma start karma.conf-prod.js --single-run",
Dockerfile
FROM zenika/alpine-node:latest
LABEL name="product-web"
# Update apk repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
# Install chromium
RUN apk -U --no-cache \
--allow-untrusted add \
zlib-dev \
chromium \
xvfb \
wait4ports \
xorg-server \
dbus \
ttf-freefont \
mesa-dri-swrast \
grep \
udev \
&& apk del --purge --force linux-headers binutils-gold gnupg zlib-dev libc-utils \
&& rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
/usr/share/man \
/tmp/* \
/usr/lib/node_modules/npm/man \
/usr/lib/node_modules/npm/doc \
/usr/lib/node_modules/npm/html \
/usr/lib/node_modules/npm/scripts
WORKDIR /home/dev/code
COPY . .
#RUN rm -rf node_modules && npm cache clear --force
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/
RUN npm install
RUN npm run testProd && npm run buildProd
karma.conf-prod.js
const path = require('path');
module.exports = function(config) {
config.set({
basePath: '',
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
'--user-data-dir=/tmp/chrome-test-profile',
'--disable-web-security'
]
}
},
frameworks: ['mocha', 'chai'],
captureConsole: true,
files: [
'node_modules/babel-polyfill/dist/polyfill.js',
'test/root.js'
],
preprocessors: {
'src/index.js': ['webpack', 'sourcemap'],
'test/root.js': ['webpack']
},
webpack: {
devtool: 'inline-source-map',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname, 'node_modules'),
query: {
plugins: ['transform-decorators-legacy', 'transform-regenerator'],
presets: ['env', 'stage-1', 'react']
}
},
{
test: /\.json$/,
loader: 'json-loader',
},
]
},
externals: {
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
}
},
webpackServer: {
noInfo: true
},
reporters: ['spec'],
port: 9222,
logLevel: config.LOG_INFO
});
};
我什至尝试使用 logLevel: config.LOG_DEBUG 但没有显示任何缺失或异常。
最佳答案
基于 issue Karma 1.6 breaks Headless support for Chrome创建于 github ,它与较慢的机器有关并且发生,因为在 Chrome 解析和执行测试包之前花费了 > 60 秒,因此启动了测试运行并将其传回给 Karma 服务器。可能需要很长时间的原因各不相同。
有两种处理超时的方法:
调查您的测试包加载超过 60 秒的原因并确保加载速度更快。
基于 Derek's评论
有一个连接过早断开。
他发现在/static/karma.js 中,当创建套接字时,有一个超时值被硬编码为 2 秒(见下文)。他只是添加了另一个 0 以使其达到 20 秒,并且连接保持打开的时间足够长,以使服务器能够响应初始请求。 karma/客户端/main.js
e79463b 中的第 14 到 20 行
var socket = io(location.host, {
reconnectionDelay: 500,
reconnectionDelayMax: Infinity,
timeout: 2000,
path: KARMA_PROXY_PATH + KARMA_URL_ROOT.substr(1) + 'socket.io',
'sync disconnect on unload': true
})
他面临的下一个问题是,Karma 认为没有任何事件,即使套接字上有来回的流量。为了解决这个问题,他刚刚在 Karma 配置中添加了 browserNoActivityTimeout: 60000。
您需要更改的超时配置比配置文件中的更多。
关于javascript - Karma Chrome Headless 无法在 Jenkins 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50526682/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)