我使用Macbook上的选项(4个真核,固态磁盘)并行运行Astropy测试python setup.py test --parallel N,它使用pytest-xdist并行运行~8000个测试.
我N在1到10范围内尝试了不同,但在所有情况下我只能获得大约2的加速,但我希望在3到4范围内获得加速(因为运行测试应该是CPU限制的).
为什么加速比较低,如何获得良好的加速(在一台计算机上使用多个内核)?
我尝试了来自@Iguananaut的ramdisk建议:
加速现在是~2.2与SSD相比~2.0.由于我有四个物理内核,我希望在3到4的范围内.由于某些原因,并行运行测试的开销可能非常大.
diskutil erasevolume HFS+ 'ramdisk' hdiutil attach -nomount ram://8388608
mkdir /Volumes/ramdisk/tmp
time python setup.py test -a '--basetemp=/Volumes/ramdisk/tmp' --parallel 8
我有带有黄瓜功能的Rails 4应用程序。在某些测试中,我想到了狮身人面像数据,例如:
@javascript @sphinx
Feature: Edit a service
Scenario: Editing
Given I exist as an "individual"
And I have few services as individual user
And Sphinx indexes all models
...
Then I should see I18n translation for key "views.messages.notices.add.updated"
Run Code Online (Sandbox Code Playgroud)
当@sphinx钩包含此逻辑:
Before('@sphinx') do
self.use_transactional_fixtures = false
ThinkingSphinx::Test.start
sleep 2 # Give some time for sphinx to start.
end
After('@sphinx') do
ThinkingSphinx::Test.stop
self.use_transactional_fixtures = true
end
Run Code Online (Sandbox Code Playgroud)
并Sphinx indexes all models包含以下内容:
Given(/^Sphinx indexes all models$/) do
ThinkingSphinx::Test.index
# Wait …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails thinking-sphinx cucumber parallel-testing
我有一个rails应用程序,在circleci中使用rspec运行parallel_test
在互联网上环顾四周,我把它添加到我的spec_helper.rb文件的开头:
if ENV['COVERAGE']
require 'simplecov'
# on circleci change the output dir to the artifacts
if ENV['CIRCLE_ARTIFACTS']
dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage")
SimpleCov.coverage_dir(dir)
SimpleCov.merge_timeout 3600
SimpleCov.command_name "rspec_#{Process.pid.to_s}#{ENV['TEST_ENV_NUMBER']}"
end
SimpleCov.start 'rails'
end
Run Code Online (Sandbox Code Playgroud)
问题是,因此我为每个circleci实例获得了一个不同的文件夹:

我究竟做错了什么 ?
我正在使用sbt和JUnit来运行大型Scala项目的测试.我正在为测试分配多个JVM,并定义如何使用JVM中的测试进行分组testGrouping in Test.
测试是并行运行的,但它们的输出是交错的,因此难以通读.我已经设定了logBuffered in Test := true,但这似乎没有做任何事情.
这是我的一个片段settings:
parallelExecution in Test := true,
testForkedParallel in Test := false,
concurrentRestrictions in Global := Seq(Tags.limit(Tags.ForkedTestGroup, 8)),
testGrouping in Test := (definedTests in Test, javaOptions in Test) map groupBySuite,
testGrouping in Test := {
val original: Seq[Tests.Group] = (testGrouping in Test).value
original.map { group =>
val forkOptions = ForkOptions(
bootJars = Nil,
javaHome = javaHome.value,
connectInput = connectInput.value,
outputStrategy = outputStrategy.value,
runJVMOptions = (javaOptions …Run Code Online (Sandbox Code Playgroud) 我最近开始使用pytest运行我的自动化测试套件。依次运行时成功完成的测试运行,现在当我使用xdist并行运行套件时随机失败。我将pytest配置如下:
[pytest]
addopts = -nauto --rerun 3 -ra --timeout=180 --junit-xml=pyresult.xml
python_files=test*.py
Run Code Online (Sandbox Code Playgroud)
随机测试将无法启动Chromedriver,并且最终将引发超时。对于其他由于种种原因失败的测试失败的情况,pytest会很乐意为我重新运行测试。但是在这种情况下,当抛出超时时,pytest输出超时然后挂起。我的测试运行永远不会结束,因此詹金斯没有得到等待的结果。完成pytest的唯一方法是手动发送控制中断。
我的驱动程序如下启动(注意,我认为我的代码不是这里的问题);
@classmethod
def open_browser(cls, browser_name, configuration, down_dir=""):
"""
Returns the driver for the required browser
"""
if browser_name == 'Chrome':
chrome_options = webdriver.ChromeOptions()
prefs = {"download.default_directory" : down_dir}
chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(
executable_path=configuration, chrome_options=chrome_options)
Run Code Online (Sandbox Code Playgroud)
超时消息如下:
~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack of <unknown> (8460) ~~~~~~~~~~~~~~~~~~~~~~~~~~~
File "c:\python27\lib\site-packages\execnet\gateway_base.py", line 277, in _perform_spawn
reply.run()
File "c:\python27\lib\site-packages\execnet\gateway_base.py", line 213, in run
self._result = func(*args, **kwargs)
File "c:\python27\lib\site-packages\execnet\gateway_base.py", line 954, in _thread_receiver
msg = Message.from_io(io) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在声明性 jenkins 管道上的不同kubernetes pod 上并行运行一些端到端测试,但 jenkins 似乎尝试在相同的kubernetes pod 上运行并行阶段。这会导致数据库死锁,因为两个进程都尝试插入/截断/更新/查询相同的表。有没有办法可以为每个并行阶段启动不同的 Pod?
kubernetes 插件配置:
agent {
kubernetes {
label 'my-label'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
name: dind
spec:
containers:
- name: < default container >
image: < image >
securityContext:
privileged: true
fsGroup: 1000
command:
- cat
tty: true
volumeMounts:
- name: jenkins-bundle-gems
mountPath: /usr/local/bundle
- name: <tests-container-name>
image: < image >
securityContext:
privileged: true
fsGroup: 1000
volumeMounts:
- name: jenkins-bundle-gems …Run Code Online (Sandbox Code Playgroud) parallel-testing jenkins jenkins-pipeline jenkins-declarative-pipeline jenkins-kubernetes
我正在使用带有Cucumber的 BDD (带有page_object gem),Watir和Jenkins运行一个项目.现在,我们正在寻找并行化测试的最佳方法,以减少多个虚拟机上的测试时间,使用不同的导航器等.
我认为有两种方法:
为了在正确的方式上付出努力...你认为Jenkins是在多台机器上进行并行测试的好选择还是我应该给另一个工具机会?欢迎提出建议:)
我试图与多进程插件并行运行功能测试,有时我会给出随机的TimeoutException
我的测试非常简单,每个测试都只是进入一个网页并检查是否存在某些元素.
有谁知道可能是什么原因?
谢谢
我已经看到了很多关于与maven surefire并行运行JUnit测试的主题,但是我没有看到处理这个特定问题的答案.
简而言之:测试方法是并行执行的(好消息),但是道具不能限制我的线程.最终目标是并行化我的Web驱动程序和appium运行,但我希望能够首先控制总可能的线程.
下面的代码片段来自虚拟项目,仅用于演示.在apache文档之后,它看起来并不比下面的内容更多.
的pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<parallel>methods</parallel>
<threadCountMethods>2</threadCountMethods>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
ExampleTest.class
public class ExampleTest {
@Test
public void one() throws InterruptedException {
Thread.sleep(5000);
}
@Test
public void two() throws InterruptedException {
Thread.sleep(5000);
}
@Test
public void three() throws InterruptedException {
Thread.sleep(5000);
}
@Test
public void four() throws InterruptedException {
Thread.sleep(5000);
}
@Test
public void five() …Run Code Online (Sandbox Code Playgroud) 目前我正在使用并行测试 rspec allure 0.8.0
运行测试后,我收到以下错误:
RSpec::Core::MultipleExceptionError
我需要错误的整个回溯。是不是我需要传递给我用来运行的命令的某个参数,是否有一种永久的方式,以便它始终打印整个错误