vendredi 1 juillet 2016

I had some big problems for test activiti deployment with testng

i use testng to test the concurrency of activiti 5.19. first i write a unit test to deploy my bpm file. the java code as blow:

@ContextConfiguration(value = { "classpath:springTypicalUsageTest-context.xml" })
public class TaskTestPerformance extends AbstractTestNGSpringContextTests{
private static final Logger log =  LoggerFactory.getLogger(TaskTestPerformance.class);
@Autowired
private ItsProcessInstanceImp itsProcessInstanceService;
@Autowired
private ItsDeploymentImp itsDeploymentService;
@Autowired
private ItsProcessDefinitionImp itsProcessDefinitionService;
@Autowired
private ItsTaskImp itsTaskService;

private static String bpmfile = "com/jsits/bpm/activiti/test/task/taskTest.bpmn";
private static String deploymentname = "taskTasks";

@Test(invocationCount=20,threadPoolSize=10,invocationTimeOut=60000)
public void testTaskId(){
    Deployment deployment = itsDeploymentService.deploy(deploymentname, bpmfile);
    log.info(deployment.getId());
}

}

Notes: shis method will exe 20 times and with 10 threads,and will timeout after 60 seconds,just like the upper code shows:

 (invocationCount=20,threadPoolSize=10,invocationTimeOut=60000)

I run the unit test with testNG runner,and the result is: ===============================================

Default test

Tests run: 20, Failures: 13, Skips: 0

===============================================

the error details are:

Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "ACT_UNIQ_PROCDEF_INDEX_6 ON PUBLIC.ACT_RE_PROCDEF(KEY_, VERSION_, TENANT_ID_) VALUES ( /* key:7 */ 'tasktestid:5:69', 1, 'http://ift.tt/1lD0pq1', 'tasktestname', 'tasktestid', 5, '53', 'com/jsits/bpm/activiti/test/task/taskTest.bpmn', 'com/jsits/bpm/activiti/test/task/taskTest.tasktestid.png', NULL, FALSE, TRUE, 1, '')"; SQL statement:
insert into ACT_RE_PROCDEF(ID_, REV_, CATEGORY_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, RESOURCE_NAME_, DGRM_RESOURCE_NAME_, DESCRIPTION_, HAS_START_FORM_KEY_, HAS_GRAPHICAL_NOTATION_ , SUSPENSION_STATE_, TENANT_ID_)
    values (?,
            1,
            ?,
            ?,
            ?, 
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?) [23505-176]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
    at org.h2.message.DbException.get(DbException.java:178)
    at org.h2.message.DbException.get(DbException.java:154)
    at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
    at org.h2.index.TreeIndex.add(TreeIndex.java:69)
    at org.h2.table.RegularTable.addRow(RegularTable.java:120)
    at org.h2.command.dml.Insert.insertRows(Insert.java:157)
    at org.h2.command.dml.Insert.update(Insert.java:115)
    at org.h2.command.CommandContainer.update(CommandContainer.java:79)
    at org.h2.command.Command.executeUpdate(Command.java:254)
    at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:199)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
    ... 36 more

all those errors!!

I change the database form mysql to h2, and change the invocationCount from 100 to 20, threadPoolSize from 10 to 100, the error is not changed.

but if i modify the threadPoolSize=1 ,error is gone.

Is this means activiti deploy bpm ,the concurrency is bad?

thanks all of you!

Aucun commentaire:

Enregistrer un commentaire