Skip to content

Commit

Permalink
TestAsyncUpdateTaskMechanics: code cleanup, comment on flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Jun 14, 2022
1 parent f81ff19 commit 4854826
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
* Copyright (c) 2019 Evolveum and contributors
* Copyright (C) 2019-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.intest.async;

import static org.testng.AssertJUnit.assertEquals;
Expand All @@ -17,9 +16,6 @@
import java.util.Map;
import java.util.concurrent.TimeoutException;

import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;

import org.apache.commons.io.IOUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -36,7 +32,6 @@
import com.evolveum.midpoint.test.util.MidPointTestConstants;
import com.evolveum.midpoint.tools.testng.UnusedTestElement;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

Expand All @@ -50,9 +45,12 @@ public class TestAsyncUpdateTaskMechanics extends AbstractConfiguredModelIntegra

private static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "async/task");

private static final TestResource RESOURCE_HR = new TestResource(TEST_DIR, "resource-hr-amqp091.xml", "63693a4a-07ee-4903-a206-3f777f4495a5");
private static final TestResource TASK_ASYNC_UPDATE_HR_NO_WORKERS = new TestResource(TEST_DIR, "task-async-update-hr-no-workers.xml", "074fe1fd-3099-42f7-b6ad-1e1e5eec51d5");
private static final TestResource TASK_ASYNC_UPDATE_HR_ONE_WORKER = new TestResource(TEST_DIR, "task-async-update-hr-one-worker.xml", "e6cc59c5-8404-4a0f-9ad0-2cd5c81d9f6b");
private static final TestResource<?> RESOURCE_HR =
new TestResource<>(TEST_DIR, "resource-hr-amqp091.xml", "63693a4a-07ee-4903-a206-3f777f4495a5");
private static final TestResource<?> TASK_ASYNC_UPDATE_HR_NO_WORKERS =
new TestResource<>(TEST_DIR, "task-async-update-hr-no-workers.xml", "074fe1fd-3099-42f7-b6ad-1e1e5eec51d5");
private static final TestResource<?> TASK_ASYNC_UPDATE_HR_ONE_WORKER =
new TestResource<>(TEST_DIR, "task-async-update-hr-one-worker.xml", "e6cc59c5-8404-4a0f-9ad0-2cd5c81d9f6b");

private static final File SYSTEM_CONFIGURATION_FILE = new File(TEST_DIR, "system-configuration.xml");

Expand Down Expand Up @@ -111,6 +109,8 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co
assertEquals("Wrong task progress", 10, taskAfter.asObjectable().getProgress().intValue());
}

// Occasionally fails with: Timeout (30000) while waiting for Task(id:e6cc59c5-8404-4a0f-9ad0-2cd5c81d9f6b,
// name:HR async update (one worker), oid:e6cc59c5-8404-4a0f-9ad0-2cd5c81d9f6b) to finish. Last result R(run IN_PROGRESS null)
@Test
public void test110SmallTaskOneWorker() throws IOException, TimeoutException, CommonException {
OperationResult result = getTestOperationResult();
Expand All @@ -136,7 +136,8 @@ public void test110SmallTaskOneWorker() throws IOException, TimeoutException, Co
assertEquals("Wrong task progress", 10, taskAfter.asObjectable().getProgress().intValue());
}

private void prepareMessages(File templateFile, String prefix, int howMany, boolean markLast) throws IOException, TimeoutException {
private void prepareMessages(File templateFile, String prefix, int howMany, boolean markLast)
throws IOException, TimeoutException {
String template = String.join("\n", IOUtils.readLines(new FileReader(templateFile)));
for (int i = 0; i < howMany; i++) {
String number = String.format("%s%06d", prefix, i);
Expand Down

0 comments on commit 4854826

Please sign in to comment.