public Task Test_OTAA_Unconfirmed_Send_And_Receive_C2D_Mac_Commands_MultiGw() { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device23_OTAA_MultiGw)); LogTestStart(device); return(Test_OTAA_Unconfirmed_Send_And_Receive_C2D_Mac_Commands(device)); }
public Task Test_ABP_Confirmed_And_Unconfirmed_Message_With_ADR_MultiGw() { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device5_ABP_MultiGw)); LogTestStart(device); return(Test_ABP_Confirmed_And_Unconfirmed_Message_With_ADR(device)); }
public Task Test_OTAA_Confirmed_And_Unconfirmed_Message_With_Custom_RX1_DR_Offset_MultiGw() { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device4_OTAA_MultiGw)); LogTestStart(device); return(Test_OTAA_Confirmed_And_Unconfirmed_Message_With_Custom_RX1_DR_Offset(device)); }
public Task Test_OTAA_Join_Send_And_Rejoin_With_Custom_RX2_DR_MultiGw() { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device20_OTAA_MultiGw)); LogTestStart(device); return(Test_OTAA_Join_Send_And_Rejoin_With_Custom_RX2_DR(device)); }
public Task Test_OTAA_Unconfirmed_Receives_Confirmed_C2D_Message_Single() { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device14_OTAA)); LogTestStart(device); return(Test_OTAA_Unconfirmed_Receives_Confirmed_C2D_Message(device)); }
public async Task Test_Concentrator_Deduplication_OTAA() { Assert.True(this.initializationSucceeded); var device = TestFixtureCi.GetDeviceByPropertyName("Device31_OTAA"); LogTestStart(device); await ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWOTAA); await ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, device.AppEui); await ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey); await ArduinoDevice.SetupLora(TestFixtureCi.Configuration); var joinSucceeded = await ArduinoDevice.setOTAAJoinAsyncWithRetry(LoRaArduinoSerial._otaa_join_cmd_t.JOIN, 20000, 5); Assert.True(joinSucceeded, "Join failed"); var droppedLog = await TestFixtureCi.SearchNetworkServerModuleAsync( (log) => log.IndexOf(this.expectedLog, StringComparison.Ordinal) != -1, new SearchLogOptions(this.expectedLog)); Assert.NotNull(droppedLog.MatchedEvent); // wait 1 second after joined await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_JOIN); const int MESSAGE_COUNT = 5; for (var i = 0; i < MESSAGE_COUNT; ++i) { Log($"{device.DeviceID}: Sending OTAA confirmed message {i + 1}/{MESSAGE_COUNT}"); var msg = PayloadGenerator.Next().ToString(CultureInfo.InvariantCulture); await ArduinoDevice.transferPacketWithConfirmedAsync(msg, 10); await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET); // After transferPacketWithConfirmed: Expectation from serial // +CMSG: ACK Received await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", ArduinoDevice.SerialLogs); // 0000000000000031: message '{"value": 101}' sent to hub var expectedPayload = $"{{\"value\":{msg}}}"; await TestFixtureCi.AssertIoTHubDeviceMessageExistsAsync(device.DeviceID, expectedPayload, new SearchLogOptions(expectedPayload)); droppedLog = await TestFixtureCi.SearchNetworkServerModuleAsync( (log) => log.IndexOf(this.expectedLog, StringComparison.Ordinal) != -1, new SearchLogOptions(this.expectedLog)); Assert.NotNull(droppedLog.MatchedEvent); TestFixtureCi.ClearLogs(); } }
public async Task Test_Concentrator_Can_Receive_Updates_Then_Connect_To_Lns_And_Receive_Messages() { //arrange var temporaryDirectoryName = string.Empty; var stationEui = StationEui.Parse(TestFixture.Configuration.CupsBasicStationEui); var clientThumbprint = TestFixture.Configuration.ClientThumbprint; var crcParseResult = uint.TryParse(TestFixture.Configuration.ClientBundleCrc, out var crc); var sigCrcParseResult = uint.TryParse(TestFixture.Configuration.CupsSigKeyChecksum, out var sigCrc); try { var device = TestFixtureCi.GetDeviceByPropertyName(nameof(TestFixtureCi.Device33_OTAA)); LogTestStart(device, stationEui); if (!string.IsNullOrEmpty(clientThumbprint)) { //if a test re-run, clientThumbprint will be empty, therefore there's nothing to do, previously generated certificates will be reused //update allowed client thumbprints in IoT Hub Twin to only have the one being added await TestFixture.UpdateExistingConcentratorThumbprint(stationEui, condition : (originalArray) => !originalArray.Any(x => x.Equals(clientThumbprint, StringComparison.OrdinalIgnoreCase)), action : (originalList) => { originalList.RemoveAll(x => true); // remove all keys originalList.Add(clientThumbprint); // add only new thumbprint }); } if (crcParseResult) { //if a test re-run, crc field will be empty, therefore there's nothing to do, previously generated certificates will be reused //update crc value with the one being generated in ci await TestFixture.UpdateExistingConcentratorCrcValues(stationEui, crc); } var fwDigest = TestFixture.Configuration.CupsFwDigest; var fwPackage = TestFixture.Configuration.CupsBasicStationPackage; var fwUrl = TestFixture.Configuration.CupsFwUrl; if (sigCrcParseResult && !string.IsNullOrEmpty(fwDigest) && !string.IsNullOrEmpty(fwPackage) && fwUrl is not null) { //if a test re-run, the fields will be empty, therefore there's no update to achieve await TestFixture.UpdateExistingFirmwareUpgradeValues(stationEui, sigCrc, fwDigest, fwPackage, fwUrl); } //setup the concentrator with CUPS_URI only (certificates are retrieved from default location) TestUtils.StartBasicsStation(TestFixture.Configuration, new Dictionary <string, string>() { { "TLS_SNI", "false" }, { "CUPS_URI", TestFixture.Configuration.SharedCupsEndpoint }, { "FIXED_STATION_EUI", stationEui.ToString() }, { "RADIODEV", TestFixture.Configuration.RadioDev } }, out temporaryDirectoryName); // Waiting 30s for being sure that BasicStation actually started up await Task.Delay(30_000); // If package log does not match, firmware upgrade process failed var expectedLog = stationEui + $": Received 'version' message for station '{TestFixture.Configuration.CupsBasicStationVersion}' with package '{fwPackage}'"; var log = await TestFixtureCi.SearchNetworkServerModuleAsync( (log) => log.IndexOf(expectedLog, StringComparison.Ordinal) != -1, new SearchLogOptions(expectedLog) { MaxAttempts = 1 }); Assert.True(log.Found); //the concentrator should be ready at this point to receive messages //if receiving 'updf' is succeeding, cups worked successfully await ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWOTAA); await ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, device.AppEui); await ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, device.AppKey); await ArduinoDevice.SetupLora(TestFixtureCi.Configuration); var joinSucceeded = await ArduinoDevice.setOTAAJoinAsyncWithRetry(LoRaArduinoSerial._otaa_join_cmd_t.JOIN, 20000, 5); Assert.True(joinSucceeded, "Join failed"); var expectedLog2 = stationEui + ": Received 'jreq' message"; var jreqLog = await TestFixtureCi.SearchNetworkServerModuleAsync( (log) => log.IndexOf(expectedLog2, StringComparison.Ordinal) != -1, new SearchLogOptions(expectedLog2) { MaxAttempts = 2 }); Assert.NotNull(jreqLog.MatchedEvent); // wait 1 second after joined await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_JOIN); Log($"{device.DeviceID}: Sending OTAA unconfirmed message"); var msg = PayloadGenerator.Next().ToString(CultureInfo.InvariantCulture); await ArduinoDevice.transferPacketAsync(msg, 10); await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET); var expectedLog3 = $"{{\"value\":{msg}}}"; await TestFixtureCi.AssertIoTHubDeviceMessageExistsAsync(device.DeviceID, expectedLog3, new SearchLogOptions(expectedLog3) { MaxAttempts = 2 }); var expectedLog4 = stationEui + ": Received 'updf' message"; var updfLog = await TestFixtureCi.SearchNetworkServerModuleAsync( (log) => log.IndexOf(expectedLog4, StringComparison.Ordinal) != -1, new SearchLogOptions(expectedLog4) { MaxAttempts = 2 }); Assert.True(updfLog.Found); var twin = await TestFixture.GetTwinAsync(stationEui.ToString()); var twinReader = new TwinCollectionReader(twin.Properties.Reported, null); Assert.True(twinReader.TryRead <string>(TwinProperty.Package, out var reportedPackage) && string.Equals(fwPackage, reportedPackage, StringComparison.OrdinalIgnoreCase)); } finally { TestUtils.KillBasicsStation(TestFixture.Configuration, temporaryDirectoryName, out var logFilePath); if (!string.IsNullOrEmpty(logFilePath) && File.Exists(logFilePath)) { Log("[INFO] ** Basic Station Logs Start **"); Log(await File.ReadAllTextAsync(logFilePath)); Log("[INFO] ** Basic Station Logs End **"); File.Delete(logFilePath); } } TestFixtureCi.ClearLogs(); }
private async Task Test_Deduplication_Strategies(string devicePropertyName, string strategy) { var device = TestFixtureCi.GetDeviceByPropertyName(devicePropertyName); LogTestStart(device); await ArduinoDevice.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWABP); await ArduinoDevice.setIdAsync(device.DevAddr, device.DeviceID, null); await ArduinoDevice.setKeyAsync(device.NwkSKey, device.AppSKey, null); await ArduinoDevice.SetupLora(TestFixtureCi.Configuration); for (var i = 0; i < 10; i++) { var msg = PayloadGenerator.Next().ToString(CultureInfo.InvariantCulture); await ArduinoDevice.transferPacketWithConfirmedAsync(msg, 10); await Task.Delay(Constants.DELAY_FOR_SERIAL_AFTER_SENDING_PACKET); // After transferPacket: Expectation from serial // +CMSG: ACK Received await AssertUtils.ContainsWithRetriesAsync("+CMSG: ACK Received", ArduinoDevice.SerialLogs); var allGwGotIt = await TestFixtureCi.ValidateMultiGatewaySources((log) => log.IndexOf($"deduplication Strategy: {strategy}", StringComparison.OrdinalIgnoreCase) != -1); if (allGwGotIt) { var notDuplicate = "\"IsDuplicate\":false"; var isDuplicate = "\"IsDuplicate\":true"; var notDuplicateResult = await TestFixtureCi.SearchNetworkServerModuleAsync((s) => s.IndexOf(notDuplicate, StringComparison.Ordinal) != -1, new SearchLogOptions(notDuplicate)); var duplicateResult = await TestFixtureCi.SearchNetworkServerModuleAsync((s) => s.IndexOf(isDuplicate, StringComparison.Ordinal) != -1, new SearchLogOptions(isDuplicate)); Assert.NotNull(notDuplicateResult.MatchedEvent); Assert.NotNull(duplicateResult.MatchedEvent); Assert.NotEqual(duplicateResult.MatchedEvent.SourceId, notDuplicateResult.MatchedEvent.SourceId); switch (strategy) { case "Mark": var expectedProperty = "dupmsg"; await TestFixture.AssertIoTHubDeviceMessageExistsAsync(device.DeviceID, expectedProperty, "true", new SearchLogOptions(expectedProperty) { SourceIdFilter = duplicateResult.MatchedEvent.SourceId, TreatAsError = true }); await TestFixture.AssertIoTHubDeviceMessageExistsAsync(device.DeviceID, expectedProperty, "true", new SearchLogOptions(expectedProperty) { SourceIdFilter = notDuplicateResult.MatchedEvent.SourceId, TreatAsError = true }); break; case "Drop": var logMsg = $"{device.DeviceID}: duplication strategy indicated to not process message"; var droppedLog = await TestFixtureCi.SearchNetworkServerModuleAsync((log) => log.StartsWith(logMsg, StringComparison.Ordinal), new SearchLogOptions(logMsg) { SourceIdFilter = duplicateResult.MatchedEvent.SourceId }); Assert.NotNull(droppedLog.MatchedEvent); var expectedPayload = $"{{\"value\":{msg}}}"; await TestFixtureCi.AssertIoTHubDeviceMessageExistsAsync(device.DeviceID, expectedPayload, new SearchLogOptions(expectedPayload) { TreatAsError = true }); break; default: throw new SwitchExpressionException(); } } TestFixtureCi.ClearLogs(); } }