Skip to content

Commit

Permalink
Add basic discovery to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed May 21, 2024
1 parent da6094c commit 0ecdc87
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 0 deletions.
38 changes: 38 additions & 0 deletions samples/greengrass/basic_discovery/ci_run_discovery_cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"language": "CPP",
"runnable_file": "basic-discovery",
"runnable_region": "us-east-1",
"runnable_main_class": "",
"arguments": [
{
"name": "--cert",
"secret": "ci/PubSub/cert",
"filename": "tmp_certificate.pem"
},
{
"name": "--key",
"secret": "ci/PubSub/key",
"filename": "tmp_key.pem"
},
{
"name": "--thing_name",
"data": "CI_PubSub_Thing"
},
{
"name": "--region",
"data": "us-east-1"
},
{
"name": "--message",
"data": "hello"
},
{
"name": "--print_discover_resp_only",
"data": "true"
},
{
"name": "--is_ci",
"data": "true"
}
]
}
2 changes: 2 additions & 0 deletions samples/greengrass/basic_discovery/copy_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cp ../../../build/samples/greengrass/basic_discovery/basic-discovery .
cp ../../../utils/run_in_ci.py .
22 changes: 22 additions & 0 deletions samples/greengrass/basic_discovery/gdk-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"component": {
"software.amazon.awssdk.sdk-gg-ipc": {
"author": "iot-device-sdk",
"version": "NEXT_PATCH",
"build": {
"build_system": "custom",
"custom_build_command": ["bash", "copy_files.sh"]
},
"publish": {
"bucket": "<PLACEHOLDER_BUCKET>",
"region": "<PLACEHOLDER_REGION>"
}
}
},
"gdk_version": "1.3.0",
"test-e2e": {
"gtf_options": {
"tags": "testgg"
}
}
}
63 changes: 63 additions & 0 deletions samples/greengrass/basic_discovery/gg-e2e-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.aws.greengrass</groupId>
<artifactId>uat-features</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>OTF</name>

<properties>
<otf.version>1.2.0-SNAPSHOT</otf.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>greengrass-common</id>
<name>greengrass common</name>
<!-- CloudFront url fronting the aws-greengrass-testing-standalone in S3-->
<url>https://d2jrmugq4soldf.cloudfront.net/snapshots</url>
</repository>
</repositories>

<dependencies>
<!-- Open Testing Framework dependency - Source Code: https://github.com/aws-greengrass/aws-greengrass-testing -->
<dependency>
<groupId>com.aws.greengrass</groupId>
<artifactId>aws-greengrass-testing-standalone</artifactId>
<version>${otf.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.aws.greengrass.testing.launcher.TestLauncher</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Feature: Testing features of Greengrassv2 IPC sample

@testgg
Scenario: As a developer, I can create a component and deploy it on my device
Given my device is registered as a Thing
And my device is running Greengrass
When I create a Greengrass deployment with components
| aws.greengrass.clientdevices.Auth | LATEST |
| aws.greengrass.clientdevices.mqtt.Moquette | LATEST |
| aws.greengrass.clientdevices.mqtt.Bridge | LATEST |
| aws.greengrass.clientdevices.IPDetector | LATEST |
| software.amazon.awssdk.sdk-gg-ipc | file:recipe.yaml |
When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.Auth configuration to:
"""
{
"MERGE": {
"deviceGroups": {
"formatVersion": "2021-03-05",
"definitions": {
"MyPermissiveDeviceGroup": {
"selectionRule": "thingName: *",
"policyName": "MyPermissivePolicy"
}
},
"policies": {
"MyPermissivePolicy": {
"AllowAll": {
"statementDescription": "Allow client devices to perform all actions.",
"operations": [
"*"
],
"resources": [
"*"
]
}
}
}
}
}
}
"""
When I update my Greengrass deployment configuration, setting the component aws.greengrass.clientdevices.mqtt.Bridge configuration to:
"""
{
"MERGE": {
"mqttTopicMapping": {
"ClientDeviceHelloWorld": {
"topic": "clients/+/hello/world",
"source": "LocalMqtt",
"target": "IotCore"
},
"ClientDeviceEvents": {
"topic": "clients/+/detections",
"targetTopicPrefix": "events/input/",
"source": "LocalMqtt",
"target": "Pubsub"
},
"ClientDeviceCloudStatusUpdate": {
"topic": "clients/+/status",
"targetTopicPrefix": "$aws/rules/StatusUpdateRule/",
"source": "LocalMqtt",
"target": "IotCore"
}
}
}
}
"""
And I deploy the Greengrass deployment configuration
Then the Greengrass deployment is COMPLETED on the device after 120 seconds
And the software.amazon.awssdk.sdk-gg-ipc log on the device contains the line "Received payload: hello" within 20 seconds
1 change: 1 addition & 0 deletions samples/greengrass/basic_discovery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ int main(int argc, char *argv[])

discoveryClient->Discover(
cmdData.input_thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) {
fprintf(stdout, "Discovery completed with error code %d; http code %d\n", error, httpResponseCode);
if (!error && response->GGGroups)
{
// Print the discovery response information and then exit. Does not use the discovery info.
Expand Down
32 changes: 32 additions & 0 deletions samples/greengrass/basic_discovery/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
RecipeFormatVersion: "2020-01-25"
ComponentName: software.amazon.awssdk.sdk-gg-ipc
ComponentVersion: "1.0.0"
ComponentDescription: "This is test for the Greengrass IPC sample"
ComponentPublisher: "iot-device-sdk"
ComponentConfiguration:
DefaultConfiguration:
accessControl:
aws.greengrass.ipc.mqttproxy:
software.amazon.awssdk.sdk-gg-ipc:mqttproxy:1:
policyDescription: "Allows access to publish and subscribe to a Greengrass IPC test topic"
operations:
- aws.greengrass#PublishToIoTCore
- aws.greengrass#SubscribeToIoTCore
resources:
- "*"
Message: "World"
Manifests:
- Platform:
os: all
Artifacts:
- URI: "file:basic-discovery"
Permission:
Read: ALL
Execute: ALL
- URI: "file:run_in_ci.py"
- URI: "file:ci_run_discovery_cfg.json"
Lifecycle:
Run: |
echo "GG core:" {iot:thingName}
python3 {artifacts:path}/run_in_ci.py --runnable_dir {artifacts:path} --file {artifacts:path}/ci_run_discovery_cfg.json

0 comments on commit 0ecdc87

Please sign in to comment.