noconnor / JUnitPerf

API performance testing framework built using JUnit
Apache License 2.0
68 stars 18 forks source link

JUnit4:always statistics.errorCount=statistics.evlauationCount=2000 #116

Open azizamohamedabdelsalam opened 1 year ago

azizamohamedabdelsalam commented 1 year ago

i transfer the following JUniTest case (snippet of the code) to the performance test using your JUnitPerf library (version 1.34) as follow:

public class RawDataSet2PamWritePerformanceTest { //specifies that the performance test should be run using the JUnitPerfRule class. @Rule public JUnitPerfRule perfRule = new JUnitPerfRule( new ConsoleReportGenerator());

@Before
public void setup() throws InterruptedException
{
    pamDDService.createMDProcCharRelation( 1, xRelation, defaultDataObjectName );
    pamDDService.createMDProcCharDataType( 1, dataType );
    generatedRequest = generator.generateData( config, 1, 1);  // used to generate the request 
}

@Test

@JUnitPerfTest(threads = 1, durationMs = 3_000, warmUpMs = 2_000, rampUpPeriodMs = 2_000, totalExecutions = 2000,maxExecutionsPerSecond = 2000)
@JUnitPerfTestRequirement( allowedErrorPercentage = 0.26F)
public void testWritePerformanceOneThread() throws InterruptedException
{
    SPEnvelope< RawDataSet2PamDto > scenarioOneEnvelope = new SPEnvelope<>();
     SPEnvelope< RawDataSet2PamDto > envelope =
         new SPEnvelope<>( DtoTestDataFactory.createHeader( String.valueOf( 1 ) ), generatedRequest ); // create an envelope of the generated request through setup method 
    Response response = service.create( envelope );
}

java.lang.AssertionError: Error threshold not achieved

at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThat(PerformanceEvaluationStatement.java:122)
at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThresholdsMet(PerformanceEvaluationStatement.java:104)
at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.runParallelEvaluation(PerformanceEvaluationStatement.java:79)
at com.github.noconnor.junitperf.JUnitPerfRule$1.evaluate(JUnitPerfRule.java:107)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
noconnor commented 1 year ago

if error count == evaluation count, it suggests that each call to testWritePerformanceOneThread is generating an exception.

For debugging you can enable trace logging for the com.github.noconnor.junitperf package (how to do this will depend on the logging framework you are using) or you can temporarily wrap your test in a try/catch and print the error, ie.:

@JUnitPerfTest(threads = 1, durationMs = 3_000, warmUpMs = 2_000, rampUpPeriodMs = 2_000, totalExecutions = 2000,maxExecutionsPerSecond = 2000)
@JUnitPerfTestRequirement( allowedErrorPercentage = 0.26F)
public void testWritePerformanceOneThread() throws InterruptedException
{
  try {
      SPEnvelope< RawDataSet2PamDto > scenarioOneEnvelope = new SPEnvelope<>();
      SPEnvelope< RawDataSet2PamDto > envelope =
         new SPEnvelope<>( DtoTestDataFactory.createHeader( String.valueOf( 1 ) ), generatedRequest ); 
      Response response = service.create( envelope );
  } catch(Exception e) {
   e.printStackTrace();
  }
}
azizamohamedabdelsalam commented 1 year ago

another point i didn't mention above: is it supposed to be an issue if the test environment is not only JUnit4 where in our maven project we are based on also CDI as a transaction management framework and the test environment is configured using Deltaspike so the test runner suit is not what could be provided by JUnitPerf, but it is CdiTestRunner.->the example explained below.

the same performance metrics for the same test method logic give different results according to it depends on deltaspike and CDI or not as below:

1- Pure JUnit4 Test Class-> the test will pass :

> @Slf4j
> public class TryPerformanceTest  {
> 
>     @Rule
>     public JUnitPerfRule perfTestRule = new JUnitPerfRule();
>     
>     @Test
>     @JUnitPerfTest(threads = 1, durationMs = 3_000, warmUpMs = 2_000, maxExecutionsPerSecond = 2_000)
>     @JUnitPerfTestRequirement(percentiles = "90:7,95:7,98:7,99:8", executionsPerSec = 1_900, allowedErrorPercentage = 0.10F)
>     public void tryPerformanceTestByIUnitPerf(){
>         int i=0;
>         i++;
>     }
> }

its log and report generated succesfully and show no error count :

> 01:13:55.812 [main] INFO  c.g.n.j.r.providers.HtmlReportGenerator  - Rendering report to: C:\Projects11\sp-met-global\trunk\components\pam\sp-met-global-pam-test\build\reports\junitperf_report.html

2- the same test case with the same performance metrices ,but extends CdiTest Runner and configured by deltaspike-> the test will fail : (JUnit4 , CDI transaction management and Deltaspike for test environment configuration)

> @Slf4j
> public class TryPerformanceTest **extends BusinessComponentTestBase** {
> 
>     @Rule
>     public JUnitPerfRule perfTestRule = new JUnitPerfRule();
> 
>     @Override
>     @Before
>     public void setup()
>     {
>         super.setup();
>     }
> 
>     @Test
>     @JUnitPerfTest(threads = 1, durationMs = 3_000, warmUpMs = 2_000, maxExecutionsPerSecond = 2_000)
>     @JUnitPerfTestRequirement(percentiles = "90:7,95:7,98:7,99:8", executionsPerSec = 1_900, allowedErrorPercentage = 0.10F)
>     public void tryPerformanceTestByIUnitPerf(){
>         int i=0;
>         i++;
>     }
> }

its log and generated report show error count =evaluation count:

> Juli 04, 2023 1:25:20 VORM. ### org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testStarted
> INFORMATION: [run] de.psi.metals.sp.met.global.pam.test.performance.TryPerformanceTest#tryPerformanceTestByIUnitPerf
> 01:25:23.393 [main] INFO  c.g.n.j.r.providers.HtmlReportGenerator  - Rendering report to: C:\Projects11\sp-met-global\trunk\components\pam\sp-met-global-pam-test\build\reports\junitperf_report.html
> Juli 04, 2023 1:25:23 VORM. org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testFailure
> INFORMATION: [failed] de.psi.metals.sp.met.global.pam.test.performance.TryPerformanceTest#tryPerformanceTestByIUnitPerf message: Error threshold not achieved
> 
> java.lang.AssertionError: Error threshold not achieved
> 
>   at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThat(PerformanceEvaluationStatement.java:122)
>   at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThresholdsMet(PerformanceEvaluationStatement.java:104)
>   at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.runParallelEvaluation(PerformanceEvaluationStatement.java:79)
>   at com.github.noconnor.junitperf.JUnitPerfRule$1.evaluate(JUnitPerfRule.java:107)
>   at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>   at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:177)
>   at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:76)
>   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>   at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$BeforeClassStatement.evaluate(CdiTestRunner.java:372)
>   at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$AfterClassStatement.evaluate(CdiTestRunner.java:393)
>   at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>   at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.run(CdiTestRunner.java:144)
>   at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
>   at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
>   at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
>   at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
>   at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
>   at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

why then this diffrence in the evaluatio between these code snippets for the same test method to evaluate the same performance metrices

noconnor commented 1 year ago

You would need to enable the TRACE level logging for the com.github.noconnor.junitperf package to understand what error is being thrown.

If you can get that logging, particularly for the EvaluationTask class, we'll be able to see why you are getting 100% errors when you extend the BusinessComponentTestBase class.

azizamohamedabdelsalam commented 1 year ago

ok that is what i did. Kindly check this simple test case i depend on to try your tool with configuring Logging(logback.xml) on debug level for the JUnitPerf to show on console

package de.psi.metals.sp.met.global.pam.test.performance;

import com.github.noconnor.junitperf.JUnitPerfRule;
import com.github.noconnor.junitperf.JUnitPerfTest;
import com.github.noconnor.junitperf.JUnitPerfTestRequirement;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

@Slf4j
public class TryPerfomanceTestDbWithoutDeltaspike {

    @Rule
    public JUnitPerfRule perfTestRule = new JUnitPerfRule();

    private Connection connection;
    int i;

    @Before
    public void setup() throws SQLException {
        connection = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MYSQL", "", "");
    }

    @Test
    @JUnitPerfTest(threads = 1, durationMs = 10_000, warmUpMs = 1_000,totalExecutions = 2_000)
    public void testPerformanceCreate() throws SQLException {
        log.debug("Starting testPerformanceCreate");

        Statement    statement = connection.createStatement();

        log.debug("Created statement");
        // Create the "employees" table
        statement.executeUpdate("CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(255))");
        log.debug("Created table 'employees'");
        i++;
        // Insert data into the table
       int rowsAffected = statement.executeUpdate("INSERT INTO employees (id, name) VALUES ("+ i +", 'xyz')");
        log.debug("Inserted {} row(s) into 'employees'", rowsAffected);

      //  Assert.assertEquals(1, rowsAffected);
    }

}

the Log on the console shows the test is failed as below output:

C:\Tools\Java\jdk-11.0.17+8\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:65449,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\aabdelsalam\AppData\Local\JetBrains\IdeaIC2021.3\captureAgent\debugger-agent.jar=file:/C:/Users/aabdelsalam/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 @C:\Users\aabdelsalam\AppData\Local\Temp\idea_arg_file891476478 com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 de.psi.metals.sp.met.global.pam.test.performance.TryPerfomanceTestDbWithoutDeltaspike
Connected to the target VM, address: '127.0.0.1:65449', transport: 'socket'
12:03:16,559 |-INFO in ch.qos.logback.classic.LoggerContext[default] - This is logback-classic version 1.4.7
12:03:16,607 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:03:16,621 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/test-classes/logback.xml]
12:03:16,623 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@28d18df5 - Resource [logback.xml] occurs multiple times on the classpath.
12:03:16,623 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@28d18df5 - Resource [logback.xml] occurs at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/test-classes/logback.xml]
12:03:16,623 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@28d18df5 - Resource [logback.xml] occurs at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/classes/logback.xml]
12:03:16,623 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@28d18df5 - Resource [logback.xml] occurs at [jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-testing/5.26.0-PD-06/sp-core-testing-5.26.0-PD-06.jar!/logback.xml]
12:03:16,796 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [STDOUT]
12:03:16,796 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:03:16,813 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:03:16,888 |-INFO in ch.qos.logback.classic.model.processor.LoggerModelHandler - Setting level of logger [com.github.noconnor.junitperf] to DEBUG
12:03:16,890 |-INFO in ch.qos.logback.classic.model.processor.RootLoggerModelHandler - Setting level of ROOT logger to OFF
12:03:16,890 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [STDOUT] to Logger[ROOT]
12:03:16,891 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@934b6cb - End of configuration.
12:03:16,892 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@55cf0d14 - Registering current configuration as safe fallback point

12:03:42.484 [main] INFO  c.g.n.j.r.providers.HtmlReportGenerator  - Rendering report to: C:\Projects11\sp-met-global\trunk\components\pam\sp-met-global-pam-test\build\reports\junitperf_report.html

java.lang.AssertionError: Error threshold not achieved

    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThat(PerformanceEvaluationStatement.java:122)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThresholdsMet(PerformanceEvaluationStatement.java:104)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.runParallelEvaluation(PerformanceEvaluationStatement.java:79)
    at com.github.noconnor.junitperf.JUnitPerfRule$1.evaluate(JUnitPerfRule.java:107)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Disconnected from the target VM, address: '127.0.0.1:65449', transport: 'socket'

Process finished with exit code -1

Kindly advice

noconnor commented 1 year ago

logback.xml) on debug level for the JUnitPerf to show on console

You need to set the logging to TRACE (not debug) for junitperf package

azizamohamedabdelsalam commented 1 year ago

sorry about my misunderstood i configured rhe package on tracking level in log

and based on the real test case i have as follow :

package de.psi.metals.sp.met.global.pam.test.performance;

import javax.inject.Inject;
import javax.ws.rs.core.Response;

import com.github.noconnor.junitperf.JUnitPerfRule;
import com.github.noconnor.junitperf.JUnitPerfTest;
import com.github.noconnor.junitperf.JUnitPerfTestRequirement;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import de.psi.metals.sp.core.com.api.SPEnvelope;
import de.psi.metals.sp.core.testing.component.BusinessComponentTestBase;
import de.psi.metals.sp.met.global.pam.business.model.XRelationName;
import de.psi.metals.sp.met.global.pam.business.service.PamDDService;
import de.psi.metals.sp.met.global.pam.com.StorageAppService;
import de.psi.metals.sp.met.global.pam.com.api.dto.rawdataset2pam.RawDataSet2PamDto;
import de.psi.metals.sp.met.global.pam.com.generator.data.rawdataset2pam.RawDataSet2PamDataGeneratorConfigurationBasic;
import de.psi.metals.sp.met.global.pam.com.generator.data.rawdataset2pam.RawDataSet2PamDataGeneratorDefault;
import de.psi.metals.sp.met.global.pam.test.util.DtoTestDataFactory;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RawDataSet2PamWriteTestPerformance extends BusinessComponentTestBase
{
    @Rule
    public JUnitPerfRule perfTestRule = new JUnitPerfRule();

    @Inject
    public StorageAppService service;
    @Inject
    public PamDDService pamDDService;

    private static XRelationName xRelation = XRelationName.TIME;
    private static String dataType = "analog";
    private static String defaultDataObjectName = "TestDefaultObjectName";

    final RawDataSet2PamDataGeneratorConfigurationBasic config =
        new RawDataSet2PamDataGeneratorConfigurationBasic();

    final RawDataSet2PamDataGeneratorDefault generator = new RawDataSet2PamDataGeneratorDefault();

    private static RawDataSet2PamDto generatedRequest = new RawDataSet2PamDto();

    @Override
    @Before
    public void setup() {
        super.setup();

        pamDDService.createMDProcCharRelation( 1, xRelation, defaultDataObjectName );
        pamDDService.createMDProcCharDataType( 1, dataType );
    }

    @Test
    @JUnitPerfTest(threads = 1, totalExecutions = 2000,durationMs = 3_000, warmUpMs = 2_000,rampUpPeriodMs = 2_000)
    @JUnitPerfTestRequirement(percentiles = "90:.3,95:.4,98:.4,99:.5", allowedErrorPercentage = 0.01F)
    public void testWrite() throws InterruptedException
    {
        generatedRequest = generator.generateData( config, 1, 1);
        Assert.assertNotNull(generatedRequest);
        Assert.assertEquals(1,
                generatedRequest.getValueList()
                        .size());

        SPEnvelope< RawDataSet2PamDto > scenarioOneEnvelope = new SPEnvelope<>();

         SPEnvelope< RawDataSet2PamDto > envelope =
             new SPEnvelope<>( DtoTestDataFactory.createHeader( String.valueOf( 1 ) ), generatedRequest );

        Response response = service.create( envelope );
    }
}

and the Trace output (snippet) what is the exceptions thrown

C:\Tools\Java\jdk-11.0.17+8\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54745,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\aabdelsalam\AppData\Local\JetBrains\IdeaIC2021.3\captureAgent\debugger-agent.jar=file:/C:/Users/aabdelsalam/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 @C:\Users\aabdelsalam\AppData\Local\Temp\idea_arg_file770347860 com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 de.psi.metals.sp.met.global.pam.test.performance.RawDataSet2PamWriteTestPerformance "@N Times2"
Connected to the target VM, address: '127.0.0.1:54745', transport: 'socket'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-business/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-infrastructure/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/core/sp-met-global-core-infrastructure/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-config/5.26.0-PD-06/sp-core-config-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-testing/5.26.0-PD-06/sp-core-testing-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-audittrail-com-api/5.26.0-PD-06/sp-audittrail-com-api-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/org/apache/deltaspike/modules/deltaspike-jpa-module-impl/1.9.0/deltaspike-jpa-module-impl-1.9.0.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 2:20:22 NACHM. org.apache.deltaspike.core.util.ProjectStageProducer initProjectStage
INFORMATION: Computed the following DeltaSpike ProjectStage: Production
Juli 04, 2023 2:20:34 NACHM. org.apache.deltaspike.core.util.ProjectStageProducer setProjectStage
INFORMATION: change project-stage from Production to UnitTest

13:24:48.870 [perf-eval-thread-0] TRACE c.g.n.j.statements.EvaluationTask        - Execution error
org.junit.internal.runners.model.MultipleFailureException: There were 2 errors:
  org.jboss.weld.contexts.ContextNotActiveException(WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped)
  java.lang.NullPointerException(null)
    at org.junit.runners.model.MultipleFailureException.assertEmpty(MultipleFailureException.java:67)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:39)
    at com.github.noconnor.junitperf.statements.DefaultStatement.evaluate(DefaultStatement.java:21)
    at com.github.noconnor.junitperf.statements.EvaluationTask.evaluateStatement(EvaluationTask.java:103)
    at com.github.noconnor.junitperf.statements.EvaluationTask.run(EvaluationTask.java:60)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.lambda$createTask$0(PerformanceEvaluationStatement.java:94)
    at java.base/java.lang.Thread.run(Thread.java:829)

and the test is failed with this output :

Juli 04, 2023 1:24:50 NACHM. org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testFailure
INFORMATION: [failed] de.psi.metals.sp.met.global.pam.test.performance.RawDataSet2PamWriteTestPerformance#testWrite message: Error threshold not achieved

java.lang.AssertionError: Error threshold not achieved

    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThat(PerformanceEvaluationStatement.java:122)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.assertThresholdsMet(PerformanceEvaluationStatement.java:104)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.runParallelEvaluation(PerformanceEvaluationStatement.java:79)
    at com.github.noconnor.junitperf.JUnitPerfRule$1.evaluate(JUnitPerfRule.java:107)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:177)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.runChild(CdiTestRunner.java:76)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$BeforeClassStatement.evaluate(CdiTestRunner.java:372)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$AfterClassStatement.evaluate(CdiTestRunner.java:393)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner.run(CdiTestRunner.java:144)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Juli 04, 2023 1:24:50 NACHM. org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testFinished
INFORMATION: [finished] de.psi.metals.sp.met.global.pam.test.performance.RawDataSet2PamWriteTestPerformance#testWrite
13:24:52.087 [Thread-2] INFO  org.jboss.weld.Bootstrap - WELD-ENV-002001: Weld SE container c289cad0-a3e1-450f-968f-341998fac1f0 shut down
Weld SE container c289cad0-a3e1-450f-968f-341998fac1f0 shut down by shutdown hook
Disconnected from the target VM, address: '127.0.0.1:52861', transport: 'socket'
Process finished with exit code -1
noconnor commented 1 year ago

This seems to be the issue you are having:

org.junit.internal.runners.model.MultipleFailureException: There were 2 errors:
  org.jboss.weld.contexts.ContextNotActiveException(WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped)
  java.lang.NullPointerException(null)
    at org.junit.runners.model.MultipleFailureException.assertEmpty(MultipleFailureException.java:67)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:39)

And it appears to be happening in an @After block that must be in your BusinessComponentTestBase class? This is not a junitperf error.

Does the test pass when you comment out the @Rule?

azizamohamedabdelsalam commented 1 year ago

yes without @Rule the test is passed and this is the log trace in this case

C:\Tools\Java\jdk-11.0.17+8\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.3\lib\idea_rt.jar=65040:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.3\bin" -Dfile.encoding=UTF-8 @C:\Users\aabdelsalam\AppData\Local\Temp\idea_arg_file1108708898 com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 de.psi.metals.sp.met.global.pam.test.performance.RawDataSet2PamWriteTestPerformance
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-business/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-infrastructure/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'file:/C:/Projects11/sp-met-global/trunk/components/core/sp-met-global-core-infrastructure/target/classes/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-config/5.26.0-PD-06/sp-core-config-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-testing/5.26.0-PD-06/sp-core-testing-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-audittrail-com-api/5.26.0-PD-06/sp-audittrail-com-api-5.26.0-PD-06.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:20 NACHM. org.apache.deltaspike.core.impl.config.EnvironmentPropertyConfigSourceProvider <init>
INFORMATION: Custom config found by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL: 'jar:file:/C:/Users/aabdelsalam/.m2/repository/org/apache/deltaspike/modules/deltaspike-jpa-module-impl/1.9.0/deltaspike-jpa-module-impl-1.9.0.jar!/META-INF/apache-deltaspike.properties'
Juli 04, 2023 4:14:21 NACHM. org.apache.deltaspike.core.util.ProjectStageProducer initProjectStage
INFORMATION: Computed the following DeltaSpike ProjectStage: Production
Juli 04, 2023 4:14:21 NACHM. org.apache.deltaspike.core.util.ProjectStageProducer setProjectStage
INFORMATION: change project-stage from Production to UnitTest
Juli 04, 2023 4:14:21 NACHM. org.apache.deltaspike.core.api.config.PropertyLoader loadAllProperties
INFORMATION: could not find any property files with name META-INF/apache-deltaspike_test-container
16:14:21.876 [main] INFO  org.jboss.weld.Version - WELD-000900: 3.0.5 (Final)
16:14:21,996 |-INFO in ch.qos.logback.classic.LoggerContext[default] - This is logback-classic version 1.4.7
16:14:22,018 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
16:14:22,019 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/test-classes/logback.xml]
16:14:22,021 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@24097e9b - Resource [logback.xml] occurs multiple times on the classpath.
16:14:22,021 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@24097e9b - Resource [logback.xml] occurs at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/test-classes/logback.xml]
16:14:22,021 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@24097e9b - Resource [logback.xml] occurs at [file:/C:/Projects11/sp-met-global/trunk/components/pam/sp-met-global-pam-test/target/classes/logback.xml]
16:14:22,021 |-WARN in ch.qos.logback.classic.util.DefaultJoranConfigurator@24097e9b - Resource [logback.xml] occurs at [jar:file:/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-testing/5.26.0-PD-06/sp-core-testing-5.26.0-PD-06.jar!/logback.xml]
16:14:22,133 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [STDOUT]
16:14:22,133 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:14:22,141 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
16:14:22,187 |-INFO in ch.qos.logback.classic.model.processor.LoggerModelHandler - Setting level of logger [com.github.noconnor.junitperf] to TRACE
16:14:22,187 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [STDOUT] to Logger[com.github.noconnor.junitperf]
16:14:22,188 |-INFO in ch.qos.logback.classic.model.processor.LoggerModelHandler - Setting level of logger [de.psi.metals.sp.core.testing.component.BusinessComponentTestBase] to TRACE
16:14:22,188 |-INFO in ch.qos.logback.classic.model.processor.RootLoggerModelHandler - Setting level of ROOT logger to OFF
16:14:22,188 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [STDOUT] to Logger[ROOT]
16:14:22,188 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@5eb97ced - End of configuration.
16:14:22,189 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@68ba310d - Registering current configuration as safe fallback point

16:14:22.234 [main] INFO  org.jboss.weld.Bootstrap - WELD-ENV-000020: Using jandex for bean discovery
16:14:22.743 [main] WARN  org.jboss.weld.Bootstrap - WELD-ENV-002008: Bean class de.psi.pjf.per.qparser.ModelInitializerUtils found in multiple bean archives - this may result in incorrect behavior: 
  - WeldBeanDeploymentArchive [id=/C:/Users/aabdelsalam/.m2/repository/de/psi/metals/sp/sp-core-testing/5.26.0-PD-06/sp-core-testing-5.26.0-PD-06.jar],
  - WeldBeanDeploymentArchive [id=/C:/Users/aabdelsalam/.m2/repository/de/psi/pjf/per/per.qm.ejb/2.8.7/per.qm.ejb-2.8.7.jar]
16:14:23.135 [main] INFO  org.jboss.weld.Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
16:14:23.285 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] de.psi.metals.sp.core.health.metrics.HealthMetricsEnricher.processAnnotatedType(@Observes ProcessAnnotatedType<T>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.292 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.exclude.extension.ExcludeExtension.vetoBeans(@Observes ProcessAnnotatedType, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.296 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] de.psi.metals.sp.core.com.envelope.EnvelopeExtensionForBusEventReceiverMethods.processAnnotatedType(@Observes ProcessAnnotatedType<T>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.299 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.partialbean.impl.PartialBeanBindingExtension.findInvocationHandlerBindings(@Observes ProcessAnnotatedType<X>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.299 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] de.psi.metals.sp.core.auth.RemoveProblematicBeansExtension.processAnnotatedType(@Observes ProcessAnnotatedType<T>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.304 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.message.MessageBundleExtension.detectInterfaces(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.306 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] public de.psi.metals.sp.core.dataaccess.server.EmManageableRepoBindingExtension.findRepoBindings(@Observes ProcessAnnotatedType<X>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.307 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.core.impl.interceptor.interdyn.InterDynExtension.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.311 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.core.impl.config.ConfigurationExtension.findDynamicConfigurationBeans(@Observes ProcessAnnotatedType<?>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.311 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.interceptor.GlobalInterceptorExtension.promoteInterceptors(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.315 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.scheduler.impl.SchedulerExtension.findScheduledJobs(@Observes ProcessAnnotatedType<X>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.320 [main] INFO  org.jboss.weld.Event - WELD-000411: Observer method [BackedAnnotatedMethod] org.apache.deltaspike.data.impl.RepositoryExtension.processAnnotatedType(@Observes ProcessAnnotatedType<X>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
16:14:23.630 [ForkJoinPool.commonPool-worker-31] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.pjf.auth.jeesupport.jaxrs.userinfo.AuthorizationHeaderFactory because of underlying class loading error: Type org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.664 [ForkJoinPool.commonPool-worker-9] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.pjf.auth.jeesupport.jaxrs.OIDCPermissionChecker because of underlying class loading error: Type org.eclipse.microprofile.jwt.JsonWebToken not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.700 [ForkJoinPool.commonPool-worker-3] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter because of underlying class loading error: Type org.apache.myfaces.mc.test.core.runner.MyFacesContainer not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.774 [ForkJoinPool.commonPool-worker-7] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.pjf.auth.jeesupport.jaxrs.AuthorizationProvider because of underlying class loading error: Type org.eclipse.microprofile.jwt.JsonWebToken not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.824 [ForkJoinPool.commonPool-worker-27] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.pjf.bus.jee.registrator.extension.OpenApiProcessorForSPApplication because of underlying class loading error: Type de.psi.pjf.bus.jee.registrator.OpenApiProcessor not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.918 [ForkJoinPool.commonPool-worker-15] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.metals.sp.core.com.RetryBusRegistrator because of underlying class loading error: Type de.psi.pjf.bus.jee.registrator.BusRegistrator not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.929 [ForkJoinPool.commonPool-worker-11] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.metals.sp.core.com.deliveryprocessor.SpEventDeliveryProcessor because of underlying class loading error: Type de.psi.pjf.bus.jee.event.EventDeliveryProcessor not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:23.941 [ForkJoinPool.commonPool-worker-15] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from org.apache.deltaspike.testcontrol.impl.jsf.MockedJsfTestContainerAdapter because of underlying class loading error: Type org.apache.myfaces.test.mock.MockedJsfTestContainer not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:24.003 [ForkJoinPool.commonPool-worker-25] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.metals.sp.core.com.metrics.PSIBusCommandsMetricsEnricher because of underlying class loading error: Type io.smallrye.metrics.app.Reservoir not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:24.057 [ForkJoinPool.commonPool-worker-29] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.metals.sp.core.com.producer.SPBusArtemisProducers because of underlying class loading error: Type de.psi.pjf.bus.jee.event.BusArtemisProducers not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:24.058 [ForkJoinPool.commonPool-worker-31] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from de.psi.metals.sp.met.global.core.infrastructure.resync.MetGlobalCoreReSyncDomainEntitiesProvider because of underlying class loading error: Type de.psi.metals.sp.auditsync.resync.ReSyncDomainEntitiesProviderIf not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:24.091 [ForkJoinPool.commonPool-worker-5] INFO  org.jboss.weld.Bootstrap - WELD-000119: Not generating any bean definitions from org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer because of underlying class loading error: Type org.apache.myfaces.test.mock.MockRenderKit not found.  If this is unexpected, enable DEBUG logging to see the full error.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.core.impl.lock.LockedInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.core.impl.future.FutureableInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.core.impl.monitoring.InvocationMonitorInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class org.apache.deltaspike.proxy.util.EnableInterceptorsInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
16:14:24.889 [main] WARN  org.jboss.weld.Validator - WELD-001478: Interceptor class de.psi.pjf.auth.authdatasecurity.SecureMethodInterceptor is enabled for the application and for the bean archive flat. It will only be invoked in the @Priority part of the chain.
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.genericaction.GenericActionService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.datasync.DataSyncEventReceiver
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.pjf.per.QueryExecutorService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.met.global.core.infrastructure.MasterDataInitialization
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.testing.audittrail.DummyAuditTrailReSyncAppService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.met.global.pam.com.StorageAppService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.jpa.api.transaction.TransactionHelper
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.health.ReadinessInitSteps
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.testing.component.TransactionWrapper
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.infrastructure.IdGeneratorImpl
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.eventinboxoutbox.MessageRelayService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.pjf.per.ModelMetadataService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.datasync.DataSyncAppService
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.health.ReadinessExposedServices
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.proxy.util.EnableInterceptorsInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.bus.PSIBusCommandRetryInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.core.impl.monitoring.InvocationMonitorInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.health.metrics.HealthGaugeInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.envelope.BusEventReceiverInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.metals.sp.core.com.metrics.PSIBusCommandInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.core.impl.lock.LockedInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.pjf.per.ExceptionLogEnhancerInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean de.psi.pjf.auth.authdatasecurity.SecureMethodInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.apache.deltaspike.core.impl.future.FutureableInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.jboss.weld.environment.se.contexts.activators.ActivateThreadScopeInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter isEjbOrAnnotatedTypeWithInterceptorAnnotation
WARNUNG: Skip mocking intercepted bean org.jboss.weld.contexts.activator.ActivateRequestContextInterceptor
Juli 04, 2023 4:14:25 NACHM. org.apache.deltaspike.scheduler.impl.AbstractQuartzScheduler start
INFORMATION: no custom quartz-config file found. falling back to the default config provided by quartz.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator (file:/C:/Users/aabdelsalam/.m2/repository/org/apache/deltaspike/modules/deltaspike-proxy-module-impl-asm/1.9.0/deltaspike-proxy-module-impl-asm-1.9.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
16:14:26.058 [main] WARN  org.jboss.weld.Validator - WELD-001471: Interceptor method initializeInjectors defined on class de.psi.pjf.per.qparser.DpmlUtilitiesProducer is not defined according to the specification. It should not throw javax.naming.NamingException, which is a checked exception.
    at de.psi.pjf.per.qparser.DpmlUtilitiesProducer.initializeInjectors(DpmlUtilitiesProducer.java:0)
  StackTrace
16:14:26.430 [main] INFO  org.jboss.weld.Bootstrap - WELD-ENV-002003: Weld SE container fa7110d3-441b-46ec-a01f-608b208a875f initialized
Juli 04, 2023 4:14:27 NACHM. org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testStarted
INFORMATION: [run] de.psi.metals.sp.met.global.pam.test.performance.RawDataSet2PamWriteTestPerformance#testWrite

 ______                        _                                           
(____  \                      (_)                                          
 ____)  ) _   _   ____  ____   _  ____    ____  _ _ _  _____  _   _  _____ 
|  __  ( | | | | / ___)|  _ \ | ||  _ \  / _  || | | |(____ || | | || ___ |
| |__)  )| |_| || |    | | | || || | | |( (_| || | | |/ ___ | \ V / | ____|
|______/ |____/ |_|    |_| |_||_||_| |_| \___ | \___/ \_____|  \_/  |_____)
                                        (_____|                            

    Burningwave Core 12.59.1

16:14:31.837 [main] INFO  org.hibernate.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [
    name: SP.Test.PU
    ...]
16:14:31.937 [main] INFO  org.hibernate.Version - HHH000412: Hibernate Core {5.3.21.Final}
16:14:31.941 [main] INFO  org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
16:14:32.026 [main] INFO  org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.5.Final}
16:14:32.537 [main] WARN  org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
16:14:32.542 [main] INFO  org.hibernate.orm.connections.pooling - HHH10001005: using driver [org.h2.Driver] at URL [jdbc:h2:mem:test]
16:14:32.542 [main] INFO  org.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {}
16:14:32.543 [main] INFO  org.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false
16:14:32.547 [main] INFO  org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 20 (min=1)
16:14:32.828 [main] INFO  org.hibernate.dialect.Dialect - HHH000400: Using dialect: de.psi.metals.sp.core.dataaccess.dialect.H2CustomDialect
16:14:33.163 [main] WARN  org.hibernate.cfg.AnnotationBinder - HHH000457: Joined inheritance hierarchy [de.psi.metals.sp.met.global.core.business.plantunit.PlantUnit] defined explicit @DiscriminatorColumn.  Legacy Hibernate behavior was to ignore the @DiscriminatorColumn.  However, as part of issue HHH-6911 we now apply the explicit @DiscriminatorColumn.  If you would prefer the legacy behavior, enable the `hibernate.discriminator.ignore_explicit_for_joined` setting (hibernate.discriminator.ignore_explicit_for_joined=true)
16:14:33.625 [main] INFO  org.hibernate.orm.beans - HHH10005002: No explicit CDI BeanManager reference was passed to Hibernate, but CDI is available on the Hibernate ClassLoader.
16:14:34.329 [main] INFO  org.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@42994d28] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
16:14:34.480 [main] INFO  org.hibernate.hql.internal.QueryTranslatorFactoryInitiator - HHH000397: Using ASTQueryTranslatorFactory
16:14:35.868 [main] INFO  d.p.m.s.c.t.c.BusinessComponentTestBase  - Cleaning DB.
16:14:35.949 [Thread-2] INFO  org.hibernate.orm.connections.pooling - HHH10001008: Cleaning up connection pool [jdbc:h2:mem:test]
16:14:36.242 [Thread-2] INFO  org.jboss.weld.Bootstrap - WELD-ENV-002001: Weld SE container fa7110d3-441b-46ec-a01f-608b208a875f shut down
Weld SE container fa7110d3-441b-46ec-a01f-608b208a875f shut down by shutdown hook

Process finished with exit code 0
azizamohamedabdelsalam commented 1 year ago

and regarding @After is already exist in BusinessComponentTestBase as below:

@After
    public void tearDown() {
        if (this.tx.isActive()) {
            this.tx.rollback();
        }

        this.entityManager.clear();
        this.cleanUpDb();
    }
and it is resposible to clean the db
noconnor commented 1 year ago

So when the @Rule is in place, the before, test and after will be executed in a loop 2000 times (ie totalExecutions number of times)

Is there any code in your before or after that would fail if it was executed multiple times?

You may have to run the test in debug mode and see whats happening in your before/after methods, because from the trace log it looks like your after method is throwing an exception.

noconnor commented 1 year ago

It also might be worth mentioning that the test will be executed on a new thread.

This stack overflow entry suggests the error you are seeing might be threading related https://stackoverflow.com/a/46538520

azizamohamedabdelsalam commented 1 year ago

So when the @Rule is in place, the before, test and after will be executed in a loop 2000 times (ie totalExecutions number of times)

Is there any code in your before or after that would fail if it was executed multiple times?

You may have to run the test in debug mode and see whats happening in your before/after methods, because from the trace log it looks like your after method is throwing an exception.

what in @Before and @After is supposed to be executed only one time not to be repeated as @test . then that may be the reason of error how can i configure the rule so that @Before and @After execute only once whatever total of execution

noconnor commented 1 year ago

You could use @BeforeClass and @AfterClass

https://junit.org/junit4/javadoc/4.12/org/junit/BeforeClass.html https://junit.org/junit4/javadoc/4.12/org/junit/AfterClass.html

azizamohamedabdelsalam commented 1 year ago

i have tried this way:

 @Slf4j
@RunWith(CdiTestRunner.class)
public class RawDataSet2PamWriteTestPerformance
{
    @Rule
    public JUnitPerfRule perfTestRule = new JUnitPerfRule(true);

    @Inject
    public StorageAppService service;
    @Inject
    public PamDDService pamDDService;

    @Inject
    private PamMvDataSetRepositoryIf dataSetRepository;
    @Inject
    private PamMvHeaderRepositoryIf headerRepository;

    @Inject
    @ServicePlatform
    protected EntityManager entityManager;
    @Inject
    protected DBCleanerForComponentTest dbCleaner;
    protected EntityTransaction tx;

    private static XRelationName xRelation = XRelationName.TIME;
    private static String dataType = "analog";
    private static String defaultDataObjectName = "TestDefaultObjectName";

    private boolean isSetupExecuted=false;
    private static final int TOTAL_ITERATIONS = 2;
    private int iterationCounter = 0;

    final RawDataSet2PamDataGeneratorConfigurationBasic config =
        new RawDataSet2PamDataGeneratorConfigurationBasic();

    final RawDataSet2PamDataGeneratorDefault generator = new RawDataSet2PamDataGeneratorDefault();

    private static RawDataSet2PamDto generatedRequest = new RawDataSet2PamDto();

    final  List<SPEnvelope<RawDataSet2PamDto>> scenarioOneEnvelopesList = new ArrayList<>();

    private void performSetupOnce() {
        if (!isSetupExecuted) {
            this.tx = this.entityManager.getTransaction();
            this.tx.begin();

            pamDDService.createMDProcCharRelation(1, xRelation, defaultDataObjectName);
            pamDDService.createMDProcCharDataType(1, dataType);

            generatedRequest = generator.generateData(config, 1, 1);

            isSetupExecuted = true;
        }
    }

    private void performTeardownOnce(){

        if (iterationCounter == TOTAL_ITERATIONS) {
            if (this.tx.isActive()) {
                this.tx.rollback();
            }

            this.entityManager.clear();
            this.cleanUpDb();
        }
    }

    protected void cleanUpDb() {
        EntityTransaction entityTransaction = this.entityManager.getTransaction();

        try {
            entityTransaction.begin();
            log.info("Cleaning DB.");
            this.dbCleaner.clearDatabase();
            entityTransaction.commit();
        } catch (Exception var3) {
            if (entityTransaction.isActive()) {
                entityTransaction.rollback();
            }

            log.error("Cleaning of DB failed", var3);
            Assert.fail("Cleaning of DB");
        }

    }

    @Test
    @JUnitPerfTest(threads = 1, totalExecutions = TOTAL_ITERATIONS,durationMs = 3_000, warmUpMs = 2_000,rampUpPeriodMs = 2_000)
   @JUnitPerfTestRequirement(percentiles = "90:.3,95:.4,98:.7,99:.8", allowedErrorPercentage = 0.01F)
    public void testWrite() throws InterruptedException
    {
        performSetupOnce();
      iterationCounter++;
       SPEnvelope< RawDataSet2PamDto > scenarioOneEnvelope = new SPEnvelope<>();

         SPEnvelope< RawDataSet2PamDto > envelope =
             new SPEnvelope<>( DtoTestDataFactory.createHeader( String.valueOf( iterationCounter++ ) ), generatedRequest );

        Response response = service.create( envelope );
        performTeardownOnce();

    }

}

as you can see 1- i exclude before and after methods from the starement to be evaluated 2- the regarding the logic that was inside @Before and @After i set inside the test method directly and make sure it will executed once and not each iteration 3- trace log output show that :

Strategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:723)
    at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64)
    at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$ContainerAwareMethodInvoker.evaluate(CdiTestRunner.java:326)
    at com.github.noconnor.junitperf.statements.MeasurableStatement.evaluate(MeasurableStatement.java:39)
    at com.github.noconnor.junitperf.statements.EvaluationTask.evaluateStatement(EvaluationTask.java:80)
    at com.github.noconnor.junitperf.statements.EvaluationTask.run(EvaluationTask.java:60)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.lambda$createTask$0(PerformanceEvaluationStatement.java:94)
    at java.base/java.lang.Thread.run(Thread.java:829)
15:48:44.521 [perf-eval-thread-0] TRACE c.g.n.j.statements.EvaluationTask        - Warmup error
org.jboss.weld.contexts.ContextNotActiveException: **WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped**
    at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:647)
    at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:89)
    at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:164)
    at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:87)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
    at org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager$949593926$Proxy$_$$_WeldClientProxy.getMock(Unknown Source)
    at org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:59)
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
    at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70)
    at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:723)
    at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64)
    at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86)
    at org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner$ContainerAwareMethodInvoker.evaluate(CdiTestRunner.java:326)
    at com.github.noconnor.junitperf.statements.MeasurableStatement.evaluate(MeasurableStatement.java:39)
    at com.github.noconnor.junitperf.statements.EvaluationTask.evaluateStatement(EvaluationTask.java:80)
    at com.github.noconnor.junitperf.statements.EvaluationTask.run(EvaluationTask.java:60)
    at com.github.noconnor.junitperf.statements.PerformanceEvaluationStatement.lambda$createTask$0(PerformanceEvaluationStatement.java:94)
    at java.base/java.lang.Thread.run(Thread.java:829)

as you can see the problem with the CDI (Contexts and Dependency Injection) context in the project's test environment[it is apache deltaspike framework] it need to make sure that RequestScoped context is activated and initialized correctly during test execution, so that i can prevent the ContextNotActiveException from being thrown.' WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped' however it was initiated successfully

there may be a missing of compatibility between JUnitPerf and CDI where org.apache.deltaspike.testcontrol.api.junit.CDITestRunner is responsible to create test task within a container of managed bean

Note: the test case in this form is passed without JUnitPerf Rule.

Kindly advise

noconnor commented 1 year ago

Again , this post seems to suggest the issue you are having is threading related

Junitperf tests will be executed in on a thread separate to the thread that initialises your test (and initialises your Injected dependencies)

That stack overflow links to a JIRA ticket discussing this error, and that JIRA contains a PR that updates WELD docs discussing propagating contexts across threads: https://docs.jboss.org/weld/reference/latest/en-US/html_single/#_propagating_built_in_contexts

You will need to consult the weld documentation to fix this issue.

azizamohamedabdelsalam commented 1 year ago

Ah, just i didn't go through it Thanks