Skip to content

Commit

Permalink
Fix flaky tests (faucetsdn#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
khyatimahendru authored Jan 7, 2025
1 parent edddcbe commit 05adf88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.udmi.util.CleanDateFormat;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import udmi.schema.EndpointConfiguration;
Expand All @@ -30,7 +31,7 @@ public abstract class ProcessorTestBase extends MessageTestBase {
public static final String TEST_USER = "[email protected]";
public static final Date TEST_TIMESTAMP = CleanDateFormat.cleanDate();
public static final long ASYNC_PROCESSING_DELAY_MS = 2000;
protected final List<Object> captured = new ArrayList<>();
protected final List<Object> captured = Collections.synchronizedList(new ArrayList<>());
protected IotAccessBase provider;
private ProcessorBase processor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.google.bos.udmi.service.messaging.MessageDispatcher;
import com.google.udmi.util.JsonUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
Expand All @@ -33,7 +34,7 @@ public class MessageDispatcherImplTest {

public static final long GET_TIMEOUT_SEC = 1;

List<Object> devNullCapture = new ArrayList<>();
List<Object> devNullCapture = Collections.synchronizedList(new ArrayList<>());

private EndpointConfiguration getConfiguration(boolean reversed) {
EndpointConfiguration config = new EndpointConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.udmi.util.JsonUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -42,7 +43,7 @@ public class TraceMessagePipeTest {
private static final String VALUE_ONE = "value1";
private static final String VALUE_TWO = "value2";
private static final Date FIRST_PUBLISHED = new Date(1681554607000L);
private final List<Bundle> consumed = new ArrayList<>();
private final List<Bundle> consumed = Collections.synchronizedList(new ArrayList<>());

@SuppressWarnings("unchecked")
private Map<String, String> extractMessage(Bundle bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.udmi.util.IotProvider;
import com.google.udmi.util.SiteModel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -35,7 +36,7 @@ public class IotMockProvider implements IotProvider {
private final SiteModel siteModel;
private final String client;
private final Map<String, CloudModel> cloudDevices = new HashMap<>();
private List<MockAction> mockActions = new ArrayList<>();
private List<MockAction> mockActions = Collections.synchronizedList(new ArrayList<>());

/**
* Create a mock provider used for unit testing.
Expand Down

0 comments on commit 05adf88

Please sign in to comment.