Skip to content

Commit

Permalink
Fixed the Job that CANCELLED execution queue entries so that it does …
Browse files Browse the repository at this point in the history
…not not consider the timeout from the time it was inserted to the queue but the time when the execution was triggered. #2472
  • Loading branch information
vertigo17 committed Aug 4, 2023
1 parent 81e8668 commit bc326b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public interface ITestCaseExecutionQueueDAO {
/**
* Read TestCaseExecutionInQueue By Tag
*
* @param tag Tag used to filter execution.
* @param stateList List of State to filter.
* @param tag Tag used to filter execution.
* @param stateList List of State to filter.
* @param withDependencies
* @return AnswerList that contains a list of TestCaseExecutionInQueue
* object enriched with TestCase and Application objects
Expand Down Expand Up @@ -150,13 +150,15 @@ public interface ITestCaseExecutionQueueDAO {
TestCaseExecutionQueue findByKeyWithDependencies(long id) throws CerberusException;

/**
* @param object the {@link org.cerberus.core.crud.entity.AppService} to Create
* @param object the {@link org.cerberus.core.crud.entity.AppService} to
* Create
* @return {@link AnswerItem}
*/
AnswerItem<TestCaseExecutionQueue> create(TestCaseExecutionQueue object);

/**
* @param object the {@link org.cerberus.core.crud.entity.AppService} to Update
* @param object the {@link org.cerberus.core.crud.entity.AppService} to
* Update
* @return {@link AnswerItem}
*/
Answer update(TestCaseExecutionQueue object);
Expand Down Expand Up @@ -264,6 +266,11 @@ public interface ITestCaseExecutionQueueDAO {
Answer updateToCancelledForce(long id, String comment);

/**
* This method moves queue State to CANCELLED any queue entry that has been
* in a running state for a too long period without any State change. It
* prevents execution that stops in an unexpected way to keep a slot
* resource in the queue for nothing.
*
* @param timeOutInS
* @param comment
* @return
Expand All @@ -278,7 +285,8 @@ public interface ITestCaseExecutionQueueDAO {
Answer updateToErrorForce(long id, String comment);

/**
* @param object the {@link org.cerberus.core.crud.entity.AppService} to Delete
* @param object the {@link org.cerberus.core.crud.entity.AppService} to
* Delete
* @return {@link AnswerItem}
*/
Answer delete(TestCaseExecutionQueue object);
Expand All @@ -293,10 +301,10 @@ public interface ITestCaseExecutionQueueDAO {
* Uses data of ResultSet to create object {@link TestCaseExecutionQueue}
*
* @param resultSet ResultSet relative to select from table
* TestCaseExecutionInQueue
* TestCaseExecutionInQueue
* @return object {@link TestCaseExecutionQueue}
* @throws SQLException when trying to get value from
* {@link java.sql.ResultSet#getString(String)}
* {@link java.sql.ResultSet#getString(String)}
* @see TestCaseExecutionQueue
*/
TestCaseExecutionQueue loadFromResultSet(ResultSet resultSet) throws SQLException, FactoryCreationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ public AnswerList<String> readDistinctValuesByCriteria(String columnName, String
LOG.debug("SQL : " + query.toString());
}
try (Connection connection = databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement();) {
PreparedStatement preStat = connection.prepareStatement(query.toString());
Statement stm = connection.createStatement();) {

int i = 1;
if (!StringUtil.isEmpty(searchTerm)) {
Expand All @@ -805,7 +805,7 @@ public AnswerList<String> readDistinctValuesByCriteria(String columnName, String
}

try (ResultSet resultSet = preStat.executeQuery();
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
ResultSet rowSet = stm.executeQuery("SELECT FOUND_ROWS()");) {
//gets the data
while (resultSet.next()) {
distinctValues.add(resultSet.getString("distinctValues") == null ? "" : resultSet.getString("distinctValues"));
Expand Down Expand Up @@ -1227,7 +1227,7 @@ public TestCaseExecutionQueue findByKeyWithDependencies(long id) throws Cerberus
+ "WHERE `" + COLUMN_ID + "` = ?";

try (Connection connection = this.databaseSpring.connect();
PreparedStatement selectStatement = connection.prepareStatement(query);) {
PreparedStatement selectStatement = connection.prepareStatement(query);) {
selectStatement.setLong(1, id);
try (ResultSet result = selectStatement.executeQuery();) {
if (!result.next()) {
Expand Down Expand Up @@ -1269,7 +1269,7 @@ public AnswerItem<TestCaseExecutionQueue> create(TestCaseExecutionQueue object)
}

try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);) {
PreparedStatement preStat = connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);) {

int i = 1;
preStat.setString(i++, object.getSystem());
Expand Down Expand Up @@ -1876,7 +1876,7 @@ public void updateToError(long id, String comment) throws CerberusException {
}

try (Connection connection = databaseSpring.connect();
PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {
PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {

updateStateAndCommentStatement.setString(1, comment);
updateStateAndCommentStatement.setLong(2, id);
Expand Down Expand Up @@ -1907,7 +1907,7 @@ public void updateToErrorFromQuWithDep(long id, String comment) throws CerberusE
}

try (Connection connection = databaseSpring.connect();
PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {
PreparedStatement updateStateAndCommentStatement = connection.prepareStatement(query)) {

updateStateAndCommentStatement.setString(1, comment);
updateStateAndCommentStatement.setLong(2, id);
Expand Down Expand Up @@ -2077,7 +2077,7 @@ public AnswerItem<Integer> updateToCancelledOldRecord(Integer timeOutInS, String
String query
= "UPDATE testcaseexecutionqueue "
+ "SET `" + COLUMN_STATE + "` = 'CANCELLED', `" + COLUMN_REQUEST_DATE + "` = now(), `" + COLUMN_DATEMODIF + "` = now(), `" + COLUMN_COMMENT + "` = ? "
+ "WHERE TO_SECONDS(now()) - TO_SECONDS(DateCreated) > ? "
+ "WHERE TO_SECONDS(now()) - TO_SECONDS(`" + COLUMN_DATEMODIF + "`) > ? "
+ "AND `" + COLUMN_STATE + "` IN ('WAITING','STARTING','EXECUTING')";

// Debug message on SQL.
Expand Down Expand Up @@ -2360,11 +2360,11 @@ private TestCaseExecutionQueueToTreat loadQueueToTreatFromResultSet(ResultSet re
* Uses data of ResultSet to create object {@link TestCaseExecutionQueue}
*
* @param resultSet ResultSet relative to select from table
* TestCaseExecutionInQueue
* TestCaseExecutionInQueue
* @return object {@link TestCaseExecutionQueue} with objects
* {@link ResultSet} and {@link Application}
* @throws SQLException when trying to get value from
* {@link java.sql.ResultSet#getString(String)}
* {@link java.sql.ResultSet#getString(String)}
* @see TestCaseExecutionQueue
*/
private TestCaseExecutionQueue loadWithDependenciesFromResultSet(ResultSet resultSet) throws SQLException, FactoryCreationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fixed scrollTo action. #2458
* Fixed wrong status on manual test execution. #2455
* Fixed impossibility to delete all property with the same name. #2454
* Fixed the Job that CANCELLED execution queue entries so that it does not not consider the timeout from the time it was inserted to the queue but the time when the execution was triggered. #2472

*Improvements / New features*
[square]
Expand Down

0 comments on commit bc326b2

Please sign in to comment.