-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint_config_connection_error test (#455)
This adds the first test that involves blob configs, specifically around endpoint (re)configuration.
- Loading branch information
1 parent
94437e3
commit c5940b4
Showing
5 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
validator/src/main/java/com/google/daq/mqtt/sequencer/sequences/BlobsetSequences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.google.daq.mqtt.sequencer.sequences; | ||
|
||
import static udmi.schema.Category.BLOBSET_BLOB_APPLY; | ||
|
||
import com.google.daq.mqtt.sequencer.SequenceRunner; | ||
import java.util.Base64; | ||
import java.util.HashMap; | ||
import org.junit.Test; | ||
import udmi.schema.BlobBlobsetConfig; | ||
import udmi.schema.BlobBlobsetConfig.BlobPhase; | ||
import udmi.schema.BlobsetConfig; | ||
import udmi.schema.BlobsetConfig.SystemBlobsets; | ||
import udmi.schema.Entry; | ||
import udmi.schema.Level; | ||
|
||
/** | ||
* Validation tests for instances that involve blobset config messages. | ||
*/ | ||
|
||
public class BlobsetSequences extends SequenceRunner { | ||
|
||
private static final String ENDPOINT_CONFIG_CONNECTION_ERROR_PAYLOAD = | ||
"{ " | ||
+ " \"protocol\": \"mqtt\",\n" | ||
+ " \"client_id\": \"test_project/device\",\n" | ||
+ " \"hostname\": \"localhost\"\n" | ||
+ "}"; | ||
|
||
@Test | ||
@Description("Push endpoint config message to device that results in a connection error.") | ||
public void endpoint_config_connection_error() { | ||
BlobBlobsetConfig config = new BlobBlobsetConfig(); | ||
config.phase = BlobPhase.FINAL; | ||
config.base64 = String.valueOf( | ||
Base64.getEncoder().encode(ENDPOINT_CONFIG_CONNECTION_ERROR_PAYLOAD.getBytes())); | ||
config.content_type = "application/json"; | ||
deviceConfig.blobset = new BlobsetConfig(); | ||
deviceConfig.blobset.blobs = new HashMap<String, BlobBlobsetConfig>(); | ||
deviceConfig.blobset.blobs.put(SystemBlobsets.IOT_ENDPOINT_CONFIG.value(), config); | ||
|
||
untilTrue("device tried endpoint config which resulted in connection error", () -> { | ||
Entry stateStatus = deviceState.blobset.blobs.get(SystemBlobsets.IOT_ENDPOINT_CONFIG).status; | ||
return stateStatus.category.equals(BLOBSET_BLOB_APPLY) | ||
&& stateStatus.level == Level.ERROR.value(); | ||
}); | ||
} | ||
|
||
} |