Skip to content

Commit

Permalink
EdgeAgent logs upload - fix file extension for gzip files (#1387) (#1391
Browse files Browse the repository at this point in the history
)

* Fix extension for gzip files

* Update AzureBlobLogsUploaderTest.cs
  • Loading branch information
varunpuranik authored Jun 28, 2019
1 parent 675bbaf commit 49d8655
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,12 @@ internal static string GetExtension(LogsContentEncoding logsContentEncoding, Log
{
if (logsContentEncoding == LogsContentEncoding.Gzip)
{
return "gz";
return logsContentType == LogsContentType.Json ? "json.gz" : "log.gz";
}

if (logsContentType == LogsContentType.Json)
else
{
return "json";
return logsContentType == LogsContentType.Json ? "json" : "log";
}

return "log";
}

internal string GetBlobName(string id, LogsContentEncoding logsContentEncoding, LogsContentType logsContentType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ namespace Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.Blob
using Microsoft.Azure.Devices.Edge.Agent.IoTHub.Blob;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Edge.Util.Test.Common;
using Microsoft.WindowsAzure.Storage.Blob;
using Moq;
using Xunit;
using Match = System.Text.RegularExpressions.Match;

[Unit]
public class AzureBlobLogsUploaderTest
{
const string BlobNameRegexPattern = @"(?<iothub>.*)/(?<deviceid>.*)/(?<id>.*)-(?<timestamp>\d{4}-\d{2}-\d{2}--\d{2}-\d{2}-\d{2}).(?<extension>\w{2})";
const string BlobNameRegexPattern = @"(?<iothub>.*)/(?<deviceid>.*)/(?<id>.*)-(?<timestamp>\d{4}-\d{2}-\d{2}--\d{2}-\d{2}-\d{2}).(?<extension>.{3,7})";

[Theory]
[InlineData(LogsContentEncoding.Gzip, LogsContentType.Json, "gz")]
[InlineData(LogsContentEncoding.Gzip, LogsContentType.Text, "gz")]
[InlineData(LogsContentEncoding.Gzip, LogsContentType.Json, "json.gz")]
[InlineData(LogsContentEncoding.Gzip, LogsContentType.Text, "log.gz")]
[InlineData(LogsContentEncoding.None, LogsContentType.Json, "json")]
[InlineData(LogsContentEncoding.None, LogsContentType.Text, "log")]
public void GetExtensionTest(LogsContentEncoding contentEncoding, LogsContentType contentType, string expectedExtension)
Expand All @@ -39,7 +38,7 @@ public void GetBlobNameTest()
string iotHub = "foo.azure-devices.net";
string deviceId = "abcd";
string id = "pqr";
string extension = "gz";
string extension = "json.gz";

var regex = new Regex(BlobNameRegexPattern);

Expand Down

0 comments on commit 49d8655

Please sign in to comment.