Skip to content

Commit

Permalink
test Starting/Initializing debug line tweaks, @PostConstruct logs too
Browse files Browse the repository at this point in the history
@BeforeClass output prints "Starting ...", @PostConstruct methods show
"Initializing ..." to have at least some header before it potentially
fails (still can fail during MP startup before the header).
Unused DerbyController in AbstractIntegrationTest was removed.
  • Loading branch information
virgo47 committed Feb 5, 2021
1 parent f363c89 commit 3a7c632
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 57 deletions.
Expand Up @@ -57,7 +57,7 @@ public TestMonitor testMonitor() {

@BeforeClass
public void displayTestClassTitle() {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
displayTestTitle("Starting TEST CLASS: " + getClass().getName());
}

@AfterClass
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -56,6 +56,7 @@ public void setup() throws SchemaException, SAXException, IOException {

@PostConstruct
public void initialize() throws SchemaException, ObjectAlreadyExistsException {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
OperationResult initResult = new OperationResult(CLASS_DOT + "setup");
repositoryCache.postInit(initResult);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -8,54 +8,46 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;

import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayCollection;
import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext;

import static org.testng.AssertJUnit.fail;

import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.PostConstruct;

import com.evolveum.midpoint.prism.PrismContext;

import com.evolveum.midpoint.prism.delta.ItemDelta;

import com.evolveum.midpoint.repo.cache.global.GlobalCacheObjectValue;
import com.evolveum.midpoint.repo.cache.global.GlobalObjectCache;

import com.evolveum.midpoint.repo.cache.global.GlobalQueryCache;
import com.evolveum.midpoint.repo.cache.global.GlobalVersionCache;

import com.evolveum.midpoint.repo.cache.local.QueryKey;

import com.evolveum.midpoint.schema.statistics.CachePerformanceInformationUtil;

import com.evolveum.midpoint.util.caching.CachePerformanceCollector;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.api.perf.OperationPerformanceInformation;
import com.evolveum.midpoint.repo.api.perf.PerformanceInformation;
import com.evolveum.midpoint.repo.cache.global.GlobalCacheObjectValue;
import com.evolveum.midpoint.repo.cache.global.GlobalObjectCache;
import com.evolveum.midpoint.repo.cache.global.GlobalQueryCache;
import com.evolveum.midpoint.repo.cache.global.GlobalVersionCache;
import com.evolveum.midpoint.repo.cache.local.QueryKey;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.CachePerformanceInformationUtil;
import com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil;
import com.evolveum.midpoint.test.util.AbstractSpringTest;
import com.evolveum.midpoint.test.util.InfraTestMixin;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.caching.CachePerformanceCollector;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -87,6 +79,7 @@ public void setup() {

@PostConstruct
public void initialize() throws SchemaException {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
PrismTestUtil.setPrismContext(prismContext);

OperationResult initResult = new OperationResult(CLASS_DOT + "setup");
Expand Down Expand Up @@ -635,8 +628,8 @@ private <T extends ObjectType> void generateLargeObjects(Class<T> objectClass, i
.description(StringUtils.repeat('#', size));
repositoryCache.addObject(object, null, result);

if ((i+1) % 100 == 0) {
showMemory("After generating " + (i+1) + " objects");
if ((i + 1) % 100 == 0) {
showMemory("After generating " + (i + 1) + " objects");
}
}
}
Expand Down
Expand Up @@ -53,11 +53,11 @@
import com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary;
import com.evolveum.midpoint.repo.sql.data.common.embedded.REmbeddedReference;
import com.evolveum.midpoint.repo.sql.helpers.BaseHelper;
import com.evolveum.midpoint.repo.sqlbase.JdbcSession;
import com.evolveum.midpoint.repo.sql.testing.SqlRepoTestUtil;
import com.evolveum.midpoint.repo.sql.testing.TestQueryListener;
import com.evolveum.midpoint.repo.sql.util.HibernateToSqlTranslator;
import com.evolveum.midpoint.repo.sql.util.RUtil;
import com.evolveum.midpoint.repo.sqlbase.JdbcSession;
import com.evolveum.midpoint.repo.sqlbase.SqlRepoContext;
import com.evolveum.midpoint.repo.sqlbase.mapping.QueryModelMapping;
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase;
Expand Down Expand Up @@ -147,6 +147,8 @@ public void initializeTestClass() throws Exception {
logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName());
return;
}

displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
initSystemExecuted = true;
initSystem();
}
Expand Down
Expand Up @@ -113,7 +113,6 @@
import com.evolveum.midpoint.test.util.*;
import com.evolveum.midpoint.tools.testng.CurrentTestResultHolder;
import com.evolveum.midpoint.tools.testng.MidpointTestContext;
import com.evolveum.midpoint.tools.testng.PerformanceTestCommonMixin;
import com.evolveum.midpoint.tools.testng.TestMonitor;
import com.evolveum.midpoint.util.*;
import com.evolveum.midpoint.util.exception.*;
Expand Down Expand Up @@ -182,10 +181,9 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest
@Qualifier("repoSimpleObjectResolver")
protected SimpleObjectResolver repoSimpleObjectResolver;

// Controllers for embedded OpenDJ and Derby. The abstract test will configure it, but
// it will not start only tests that need OpenDJ or derby should start it
// Controllers for embedded OpenDJ. The abstract test will configure it, but
// it will not start only tests that need OpenDJ should start it.
protected static OpenDJController openDJController = new OpenDJController();
protected static DerbyController derbyController = new DerbyController();

/**
* Fast and simple way how to enable tracing of test methods.
Expand All @@ -208,6 +206,7 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest
*/
@PostConstruct
public void initSystem() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
if (initSystemExecuted) {
logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName());
return;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -41,6 +41,7 @@ public class TestPartitioning extends AbstractTaskManagerTest {

@PostConstruct
public void initialize() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
super.initialize();
workStateManager.setFreeBucketWaitIntervalOverride(1000L);
DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML);
Expand Down
Expand Up @@ -20,11 +20,6 @@
import java.util.List;
import javax.annotation.PostConstruct;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.util.PrismTestUtil;

import com.evolveum.midpoint.schema.constants.Channel;

import org.quartz.JobExecutionContext;
import org.quartz.JobKey;
import org.quartz.SchedulerException;
Expand All @@ -35,12 +30,18 @@
import org.testng.annotations.Test;
import org.xml.sax.SAXException;

import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.Channel;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
Expand Down Expand Up @@ -98,6 +99,7 @@ public void setup() throws SchemaException, SAXException, IOException {

@PostConstruct
public void initialize() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
super.initialize();
addObjectFromFile(TASK_OWNER_FILENAME);
addObjectFromFile(TASK_OWNER2_FILENAME);
Expand All @@ -115,7 +117,6 @@ public void test000Integrity() {
/**
* Here we only test setting various task properties.
*/

@Test
public void test003GetProgress() throws Exception {
OperationResult result = createOperationResult();
Expand Down Expand Up @@ -593,11 +594,6 @@ public void test012Suspend() throws Exception {

// The progress should be more than 0
AssertJUnit.assertTrue("Task has not reported any progress", task.getProgress() > 0);

// Thread.sleep(200); // give the scheduler a chance to release the task

// task.refresh(result);
// AssertJUnit.assertEquals("Task is not released", TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());
}

@Test
Expand Down Expand Up @@ -642,18 +638,12 @@ public void test013ReleaseAndSuspendLooselyBound() throws Exception {
AssertJUnit.assertTrue("Task is not stopped", stopped);

AssertJUnit.assertEquals(TaskExecutionStatus.SUSPENDED, task.getExecutionStatus());
// AssertJUnit.assertEquals(TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());

AssertJUnit.assertNotNull(task.getLastRunStartTimestamp());
assertFalse(task.getLastRunStartTimestamp() == 0);
AssertJUnit.assertNotNull(task.getLastRunFinishTimestamp());
assertFalse(task.getLastRunFinishTimestamp() == 0);
AssertJUnit.assertTrue(task.getProgress() > 0);

// Thread.sleep(200); // give the scheduler a chance to release the task
// task.refresh(result);
// AssertJUnit.assertEquals("Task is not released", TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());

}

@Test
Expand Down Expand Up @@ -686,7 +676,6 @@ public void test014SuspendLongRunning() throws Exception {
assertFalse("Task is stopped (it should be running for now)", stopped);

AssertJUnit.assertEquals("Task is not suspended", TaskExecutionStatus.SUSPENDED, task.getExecutionStatus());
// AssertJUnit.assertEquals("Task should be still claimed, as it is not definitely stopped", TaskExclusivityStatus.CLAIMED, task.getExclusivityStatus());

AssertJUnit.assertNotNull(task.getLastRunStartTimestamp());
assertFalse(task.getLastRunStartTimestamp() == 0);
Expand All @@ -708,10 +697,6 @@ public void test014SuspendLongRunning() throws Exception {
AssertJUnit.assertNotNull("Last run finish time is null", task.getLastRunStartTimestamp());
assertFalse("Last run finish time is zero", task.getLastRunStartTimestamp() == 0);
AssertJUnit.assertTrue("Progress is not reported", task.getProgress() > 0);

// Thread.sleep(200); // give the scheduler a chance to release the task
// task.refresh(result);
// AssertJUnit.assertEquals("Task is not released", TaskExclusivityStatus.RELEASED, task.getExclusivityStatus());
}

@Test
Expand Down Expand Up @@ -1070,6 +1055,7 @@ private void checkTaskStateRepeatedly(String taskOid, OperationResult result, in
System.out.println("Done. Status = " + task.getExecutionStatus());
break;
}
//noinspection BusyWait
Thread.sleep(checkInterval);
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -90,6 +90,7 @@ protected String coordinatorTaskOid() {

@PostConstruct
public void initialize() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
super.initialize();
workStateManager.setFreeBucketWaitIntervalOverride(1000L);
DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -97,6 +97,7 @@ protected String coordinatorTaskOid() {

@PostConstruct
public void initialize() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
super.initialize();
workStateManager.setFreeBucketWaitIntervalOverride(1000L);
DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML);
Expand Down Expand Up @@ -207,7 +208,7 @@ public void test110AllocateTwoBucketsStandalone() throws Exception {
displayValue("1st obtained bucket", bucket1);
displayValue("2nd obtained bucket", bucket2);
standalone = taskManager.getTaskPlain(standalone.getOid(), result);
displayDumpable("task after 2xget", standalone);
displayDumpable("task after 2x get", standalone);

assertNumericBucket(bucket1, WorkBucketStateType.READY, 1, 0, 100);
assertNumericBucket(bucket2, WorkBucketStateType.READY, 1, 0, 100); // should be the same
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -88,6 +88,7 @@ private String coordinatorTaskOid() {

@PostConstruct
public void initialize() throws Exception {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
super.initialize();
workStateManager.setFreeBucketWaitIntervalOverride(1000L);
DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2020 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -43,7 +43,7 @@ public TestMonitor testMonitor() {

@BeforeClass
public void displayTestClassTitle() {
displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
displayTestTitle("Starting TEST CLASS: " + getClass().getName());
}

@AfterClass
Expand Down

0 comments on commit 3a7c632

Please sign in to comment.