13

I'm testing Jenkins to see if it will fit our build and testing framework. I found that Jenkins and its available plugins fit most of our needs. Except that I can't seem to find help on how to do one particular type of task.

We are creating application for embedded devices. We have 100s of tests that need to be run on these devices. If we run all the tests on one device after a build then it will take several hours to get the results. However, if we run the tests on 100 of the devices in parallel then we can get results in much shorter time.

All the tests will have very similar starting point. A test script is called with IP address of device to run the test on and user name/pw. The script would do the necessary test on the device and report back pass/fail for each test item.

I think the long/painful way of doing this is writing 100 jobs in Jenkins, each will be a different test script directly (with above parameters) and run these in parallel using available plugins. However, maintaining all these jobs will be very difficult in the long run.

So, the better way to do this would be to create a Job (let's call it child_tester) that can take parameters such as: test script name, IP address of device, user name/pw, etc. Then use another job (let's call it mother_tester) to call child_tester job 100 times with different IP addresses and run them in parallel. I would need some way of accumulating all the test results of each individual run of the child_tester jobs and report them back to mother_tester.

My question is there a plugin or any way of accomplishing this in Jenkins? I have looked into the information of the plugins called "Build Flow", "Parallel Test Executor", and "Parameterized Trigger". However, they don't seem to fit my needs.

4

2 回答 2

15

我知道您已经查看了 Build Flow 插件,但我不确定您为什么将其关闭。或许你可以指出我提议中的漏洞。

假设您的系统中有足够的执行程序来并行运行作业,我认为Build Flow 插件Build Flow Test Aggregator 插件可以满足您的需求。

  • Build Flow 插件支持并行运行作业。我看不出为什么 Build Flow 无法安排您的“子”作业与不同的参数并行运行。

  • 构建流程测试聚合器从构建流程作业的计划构建中获取测试结果,因此您的“子”作业将需要发布自己的测试结果。

  • 您将需要配置您的“子”作业,以便它可以通过检查作业配置中的“如有必要执行并发构建”来并行运行。

  • 无论哪组从站提供与嵌入式设备的连接,都需要足够的执行器来并行运行您的作业。


更新:使用简单的构建流程定义:

parallel (
  { build("dbacher flow child", VALUE: 1) },
  { build("dbacher flow child", VALUE: 2) },
  { build("dbacher flow child", VALUE: 3) },
  { build("dbacher flow child", VALUE: 4) }
)

我得到输出:

parallel {
    Schedule job dbacher flow child
    Schedule job dbacher flow child
    Schedule job dbacher flow child
    Schedule job dbacher flow child
    Build dbacher flow child #5 started
    Build dbacher flow child #6 started
    Build dbacher flow child #7 started
    Build dbacher flow child #8 started
    dbacher flow child #6 completed 
    dbacher flow child #7 completed 
    dbacher flow child #5 completed 
    dbacher flow child #8 completed 
}

作业历史显示所有四个作业都是在几秒钟内安排的。但是作业构建步骤包含人为延迟(睡眠),这将阻止任何单个构建快速完成。


更新 2:这是从另一个数据结构动态生成并行任务列表的示例:

// create a closure for the deploy job for each server 
def paramValues = (1..4)
def testJobs = [] 
for (param in paramValues) { 
  def jobParams = [VALUE: param] 
  def testJob = { 
    // call build 
    build(jobParams, "dbacher flow child") 
  } 
  println jobParams
  testJobs.add(testJob) 
} 

parallel(testJobs)

传递给 parallel 的列表是一个闭包列表,这些闭包调用具有唯一参数的构建。我必须确保在闭包函数之外定义作业参数,以确保单独安排作业。

我从另一个答案和詹金斯邮件列表上的这个线程中抄袭了语法。

于 2015-02-24T23:04:06.210 回答
3

请确保 Manage Jenkins -> Manage Nodes 设置中的 executor 数量大于 MultiJob 项目中单个作业的数量。默认情况下,我猜它是 2。因此我们需要增加它。

于 2017-01-02T13:58:59.710 回答