首页 > 解决方案 > 在并行模式下运行时的 Simulink 测试迭代问题

问题描述

语境:

我正在以编程方式运行一些 Simulink 测试工具以用于控制工程目的。首先,每个测试使用预加载回调来加载变量并设置缓存文件夹来管理模拟工件。然后它并行或串行运行每组测试。

行动:

我尝试将参数迭代添加到组中的 1 个测试中。(参见 #1)它在 simulink 测试管理器 GUI 中按顺序运行良好。它以编程方式顺序运行良好,但是当我尝试并行运行它时发生了意外。

预期的:

它将所有测试分组并在并行池中运行,没有任何问题,如#3,并在测试结果中显示迭代#4。

结果:

它将所有测试分组并在并行池中运行,但它有一个 fetch 下一个问题,如 #2。

任何想法?

信息:

1. 为了每次测试都没有数据并发问题,我确实使用 simulink test callbacks 为每个测试创建了 1 个工件缓存文件夹。但我每次迭代都没有这样做,我希望没关系,我对如何做有点迷茫。但是,我认为这可能是相关的。参考:

在并行模式下运行测试时,如何解决冲突的 simulink 仿真加速工件问题? https://www.mathworks.com/help/simulink/ug/model-reference-simulation-targets-1.html

2. 这是我读过的一些关于这些主题的文献

https://www.mathworks.com/help/sltest/ug/run-multiple-combinations-of-tests-using-iterations.html https://www.mathworks.com/help/sltest/ref/sltest.testmanager .testcase.additeration.html

3. 我正在使用 matlab.unittest.TestRunner 插件中的 runInParallel 命令。我也在使用 matlab.unittest.plugins.DiagnosticsRecordingPlugin。

代码和日志:

#1 在这里,我尝试使用 Parameter Override 和 Iterations 在 2 次迭代中拆分 1 次测试。所有其他测试都是单独测试。

for i = 1:6
    if regexp(requirement{i},'FOO' ,'once')
        for j = 1:2%7
            %% Generate Variant Scenarios
            Foo= TS_Foo(j);
            %% Parameter Set
            currParamName = char(strcat("Parameter Set ",string(j)));
            ps{i,j} = addParameterSet(tcase{i},'Name',currParamName);
            po{i,j} = addParameterOverride(ps{i,j},'A',Foo.A);
            po{i,j} = addParameterOverride(ps{i,j},'B',Foo.B);
            po{i,j} = addParameterOverride(ps{i,j},'C',Foo.C);
            po{i,j} = addParameterOverride(ps{i,j},'D',Foo.D);
            %% Iterations
            % Create test iteration object    
            testItr = sltest.testmanager.TestIteration();
            % Use the parameter set in this iteration
            testItr.setTestParam('ParameterSet', currParamName);
            % Add the iteration object to the test case
            addIteration(tcase{i},testItr,currParamName);
        end

#2 在这里,我运行 6 个测试,其中 1 个测试并行进行 2 次迭代。所以它是 7 测试总拆分。

Split tests into 7 groups and running them on 6 workers.
Error using parallel.FevalFuture/fetchNext (line 255)
The function evaluation completed with an error.

Error in
matlab.unittest.internal.TestRunnerExtension/runInParallel>printFinishedOutput
(line 85)
    groupIdx = fetchNext(groups);

Error in matlab.unittest.internal.TestRunnerExtension/runInParallel (line 58)
printFinishedOutput(groups, stream);

Error in runTest (line 141)
results = runInParallel(runner,suite);

Caused by:
    Error using
    matlab.unittest.plugins.testrunprogress.ConciseProgressPlugin/runTestClass
    (line 59)
    In 'MATLAB:unittest:TestRunProgressPlugin:Running', parameter {0} must be
    a scalar.

#3 在这里我并行运行了 35 个测试,没有迭代,没有任何问题。我还并行运行了 6 个测试,没有迭代没有问题。

2021-08-26T18:39:18.9495254Z Split tests into 22 groups and running them on 8 workers.

2021-08-26T19:37:12.5841596Z ans =
2021-08-26T19:37:12.5842363Z 
2021-08-26T19:37:12.5842546Z   35x6 table
2021-08-26T19:37:12.5842637Z 
2021-08-26T19:37:12.6891297Z                                   Name                                  Passed    Failed    Incomplete    Duration      Details   
2021-08-26T19:37:12.6913253Z     ________________________________________________________________    ______    ______    __________    ________    ____________
2021-08-26T19:37:12.6913549Z 
2021-08-26T19:37:12.6919980Z     'API_Test_Files28 > API_Test_Suites/MUT_Harness_****#1'              true      false     false         1824.4      [1x1 struct]
...
...
2021-08-26T19:37:12.6943686Z     'API_Test_Files28 > API_Test_Suites/MUT_Harness_****#35'             true      false     false         323.12      [1x1 struct]

#4 在这里,我以顺序模式运行了 6 次测试和迭代。


  7×6 table

                                                Name                                                 Passed    Failed    Incomplete    Duration      Details   
    _____________________________________________________________________________________________    ______    ______    __________    ________    ____________

    'API_Test_Files49 > API_Test_Suites/MUT_Harness_****'                                          true      false     false         1002.2      [1×1 struct]
    'API_Test_Files49 > API_Test_Suites/MUT_Harness_***(TableIteration=ParameterSet1)'    true      false     false          502.1      [1×1 struct]
    'API_Test_Files49 > API_Test_Suites/MUT_Harness_***(TableIteration=ParameterSet2)'    true      false     false          277.4      [1×1 struct]
    

标签: matlabtestingparallel-processingsimulink

解决方案


推荐阅读