Skip to content

Commit

Permalink
reduce test durations (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
noursaidi authored Dec 21, 2023
1 parent 5e01b0b commit 040eaaf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.google.daq.mqtt.sequencer.sequences;

import static com.google.daq.mqtt.util.TimePeriodConstants.NINETY_SECONDS_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.ONE_MINUTE_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.THREE_MINUTES_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.TWO_MINUTES_MS;
import static com.google.udmi.util.GeneralUtils.encodeBase64;
import static com.google.udmi.util.GeneralUtils.sha256;
import static com.google.udmi.util.JsonUtil.stringify;
Expand Down Expand Up @@ -133,7 +136,7 @@ private String generateEndpointConfigDataUrl(String payload) {

@Feature(stage = PREVIEW, bucket = ENDPOINT)
@Summary("Push endpoint config message to device that results in a connection error.")
@Test
@Test(timeout = NINETY_SECONDS_MS) // TODO Is this enough? Does a client try X times?
public void endpoint_connection_error() {
setDeviceConfigEndpointBlob(BOGUS_ENDPOINT_HOSTNAME, registryId, false);
untilErrorReported();
Expand All @@ -142,7 +145,7 @@ public void endpoint_connection_error() {

@Feature(stage = PREVIEW, bucket = ENDPOINT)
@Summary("Check repeated endpoint with same information gets retried.")
@Test
@Test(timeout = NINETY_SECONDS_MS)
public void endpoint_connection_retry() {
setDeviceConfigEndpointBlob(BOGUS_ENDPOINT_HOSTNAME, registryId, false);
final Date savedGeneration = deviceConfig.blobset.blobs.get(IOT_BLOB_KEY).generation;
Expand All @@ -159,7 +162,7 @@ public void endpoint_connection_retry() {

@Feature(stage = PREVIEW, bucket = ENDPOINT)
@Summary("Check a successful reconnect to the same endpoint.")
@Test
@Test(timeout = NINETY_SECONDS_MS)
public void endpoint_connection_success_reconnect() {
setDeviceConfigEndpointBlob(getAlternateEndpointHostname(), registryId, false);
untilSuccessfulRedirect(BlobPhase.FINAL);
Expand All @@ -169,7 +172,7 @@ public void endpoint_connection_success_reconnect() {
@Feature(stage = ALPHA, bucket = ENDPOINT)
@Summary("Failed connection because of bad hash.")
@ValidateSchema(SubFolder.BLOBSET)
@Test
@Test(timeout = ONE_MINUTE_MS)
public void endpoint_connection_bad_hash() {
setDeviceConfigEndpointBlob(getAlternateEndpointHostname(), registryId, true);
untilTrue("blobset status is ERROR", () -> {
Expand All @@ -184,20 +187,20 @@ public void endpoint_connection_bad_hash() {
});
}

@Test
@Test(timeout = NINETY_SECONDS_MS)
@Feature(stage = PREVIEW, bucket = ENDPOINT)
@Summary("Check connection to an alternate project.")
public void endpoint_connection_success_alternate() {
check_endpoint_connection_success(false);
}

@Test
@Test(timeout = THREE_MINUTES_MS)
@Feature(stage = PREVIEW, bucket = ENDPOINT)
public void endpoint_redirect_and_restart() {
check_endpoint_connection_success(true);
}

@Test(timeout = THREE_MINUTES_MS)
@Test(timeout = TWO_MINUTES_MS)
@Feature(stage = PREVIEW, bucket = ENDPOINT)
public void endpoint_failure_and_restart() {
setDeviceConfigEndpointBlob(BOGUS_ENDPOINT_HOSTNAME, registryId, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.daq.mqtt.sequencer.SequenceBase.Capabilities.LOGGING;
import static com.google.daq.mqtt.util.TimePeriodConstants.NINETY_SECONDS_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.ONE_MINUTE_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.THREE_MINUTES_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.TWO_MINUTES_MS;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void system_last_update() {
untilTrue("state update complete", this::deviceStateComplete);
}

@Test
@Test(timeout = ONE_MINUTE_MS)
@Feature(stage = BETA, bucket = SYSTEM)
@ValidateSchema(SubFolder.SYSTEM)
public void valid_serial_no() {
Expand Down Expand Up @@ -123,7 +124,7 @@ public void device_config_acked() {
});
}

@Test(timeout = TWO_MINUTES_MS)
@Test(timeout = NINETY_SECONDS_MS)
@Feature(stage = BETA, bucket = SYSTEM, score = 4)
@Capability(value = LOGGING, stage = ALPHA)
@Summary("Check that the device correctly handles a broken (non-json) config message.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.google.daq.mqtt.sequencer.sequences;

import static com.google.daq.mqtt.util.TimePeriodConstants.NINETY_SECONDS_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.TWO_MINUTES_MS;
import static com.google.udmi.util.GeneralUtils.CSV_JOINER;
import static com.google.udmi.util.JsonUtil.isoConvert;
Expand Down Expand Up @@ -138,7 +139,7 @@ private boolean isTrue(Boolean condition) {
return Optional.ofNullable(condition).orElse(false);
}

@Test
@Test(timeout = NINETY_SECONDS_MS)
@Feature(bucket = ENUMERATION, stage = PREVIEW)
@Summary("Check enumeration of nothing at all")
public void empty_enumeration() {
Expand All @@ -147,7 +148,7 @@ public void empty_enumeration() {
checkSelfEnumeration(event, enumerate);
}

@Test(timeout = TWO_MINUTES_MS)
@Test(timeout = NINETY_SECONDS_MS)
@Feature(bucket = ENUMERATION_POINTSET, stage = ALPHA)
@Summary("Check enumeration of device points")
public void pointset_enumeration() {
Expand All @@ -160,7 +161,7 @@ public void pointset_enumeration() {
checkSelfEnumeration(event, enumerate);
}

@Test
@Test(timeout = NINETY_SECONDS_MS)
@Feature(bucket = ENUMERATION_FEATURES, stage = PREVIEW)
@Summary("Check enumeration of device features")
public void feature_enumeration() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.google.daq.mqtt.sequencer.sequences;

import static com.google.daq.mqtt.util.TimePeriodConstants.NINETY_SECONDS_MS;
import static com.google.daq.mqtt.util.TimePeriodConstants.ONE_MINUTE_MS;
import static com.google.udmi.util.GeneralUtils.CSV_JOINER;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -36,7 +37,7 @@ public void setUp() {

@Feature(stage = FeatureStage.BETA, bucket = Bucket.GATEWAY, nostate = true)
@Summary("Check that a gateway proxies pointset events for indicated devices")
@Test(timeout = ONE_MINUTE_MS)
@Test(timeout = NINETY_SECONDS_MS)
public void gateway_proxy_events() {
Set<String> remaining = new HashSet<>(deviceMetadata.gateway.proxy_ids);
Set<String> original = ImmutableSet.copyOf(remaining);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.google.daq.mqtt.sequencer.sequences;

import static com.google.daq.mqtt.util.TimePeriodConstants.ONE_MINUTE_MS;
import static java.lang.String.format;
import static udmi.schema.Bucket.ENDPOINT;
import static udmi.schema.Bucket.SYSTEM;
Expand All @@ -24,19 +25,19 @@ private void familyAddr(String family) {
() -> expected.equals(actual));
}

@Test
@Test(timeout = ONE_MINUTE_MS)
@Feature(stage = PREVIEW, bucket = SYSTEM)
public void family_ether_addr() {
familyAddr("ether");
}

@Test
@Test(timeout = ONE_MINUTE_MS)
@Feature(stage = PREVIEW, bucket = SYSTEM)
public void family_ipv4_addr() {
familyAddr("ipv4");
}

@Test
@Test(timeout = ONE_MINUTE_MS)
@Feature(stage = PREVIEW, bucket = SYSTEM)
public void family_ipv6_addr() {
familyAddr("ipv6");
Expand Down

0 comments on commit 040eaaf

Please sign in to comment.