Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logs #55

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Geodatenbezug.Test/GeodiensteApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task StartExportAsync()
new () { Code = HttpStatusCode.OK, Content = "{\"info\":\"Data export successfully started. Call the URL of status_url to get the current status of the export.\"}" },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json", Times.Once());
loggerMock.Setup(LogLevel.Information, "Es läuft gerade ein anderer Export. Versuche es in 1 Minute erneut.", Times.Once());

var result = await CreateGeodiensteApiMock().StartExportAsync(topic);
Expand All @@ -124,7 +124,7 @@ public async Task StartExportAsyncTimeout()
new () { Code = HttpStatusCode.NotFound, Content = "{\"error\":\"Cannot start data export because there is another data export pending\"}" },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json", Times.Once());
loggerMock.Setup(LogLevel.Information, "Es läuft gerade ein anderer Export. Versuche es in 1 Minute erneut.", Times.Exactly(9));
loggerMock.Setup(LogLevel.Error, "Es läuft bereits ein anderer Export. Zeitlimite überschritten.", Times.Once());

Expand All @@ -140,7 +140,7 @@ public async Task StartExportAsyncFails()
new () { Code = HttpStatusCode.Unauthorized },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Starte den Datenexport für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/export.json", Times.Once());

var result = await CreateGeodiensteApiMock().StartExportAsync(topic);
Assert.AreEqual(HttpStatusCode.Unauthorized, result.StatusCode);
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task CheckExportStatusAsync()
new () { Code = HttpStatusCode.OK, Content = "{\"status\":\"success\", \"info\":\"Data ready to be downloaded. Provide your credentials to download the data.\", \"download_url\":\"test.com/data.zip\", \"exported_at\":\"2022-03-24T09:31:05.508\"}" },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json", Times.Once());
loggerMock.Setup(LogLevel.Information, "Export ist in der Warteschlange. Versuche es in 1 Minute erneut.", Times.Once());
loggerMock.Setup(LogLevel.Information, "Export ist in Bearbeitung. Versuche es in 1 Minute erneut.", Times.Once());

Expand All @@ -198,7 +198,7 @@ public async Task CheckExportStatusAsyncTimeout()
new () { Code = HttpStatusCode.OK, Content = "{\"status\":\"working\",\"info\":\"Try again later.\",\"download_url\":null,\"exported_at\":null}" },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json", Times.Once());
loggerMock.Setup(LogLevel.Information, "Export ist in der Warteschlange. Versuche es in 1 Minute erneut.", Times.Exactly(7));
loggerMock.Setup(LogLevel.Information, "Export ist in Bearbeitung. Versuche es in 1 Minute erneut.", Times.Exactly(2));
loggerMock.Setup(LogLevel.Error, "Zeitlimite überschritten. Status ist in Bearbeitung", Times.Once());
Expand All @@ -216,7 +216,7 @@ public async Task CheckExportStatusAsyncFails()
new () { Code = HttpStatusCode.Unauthorized },
]);
httpClientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny<string>())).Returns(httpTestMessageHandler.ToHttpClient()).Verifiable();
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json...", Times.Once());
loggerMock.Setup(LogLevel.Information, "Prüfe den Status des Datenexports für Perimeter LN- und Sömmerungsflächen (ZG) mit https://geodienste.ch/downloads/lwb_perimeter_ln_sf/1234567890/status.json", Times.Once());

var result = await CreateGeodiensteApiMock().CheckExportStatusAsync(topic);
Assert.AreEqual(HttpStatusCode.Unauthorized, result.StatusCode);
Expand All @@ -242,7 +242,7 @@ public async Task DownloadExportAsync()
var destinationPath = ".\\testresult";
var destinationFile = Path.Combine(destinationPath, "lwb_perimeter_terrassenreben_v2_0_lv95.gpkg");

loggerMock.Setup(LogLevel.Information, $"Lade die Daten herunter {downloadUrl}...", Times.Once());
loggerMock.Setup(LogLevel.Information, $"Lade die Daten herunter {downloadUrl}", Times.Once());

var result = await new GeodiensteApi(loggerMock.Object, httpClientFactoryMock.Object).DownloadExportAsync(downloadUrl, destinationPath);
Assert.AreEqual(destinationFile, result);
Expand All @@ -267,7 +267,7 @@ public async Task DownloadExportAsyncNoPackage()

var downloadUrl = "http://test.com/test.zip";
var destinationPath = ".\\testresult";
loggerMock.Setup(LogLevel.Information, $"Lade die Daten herunter {downloadUrl}...", Times.Once());
loggerMock.Setup(LogLevel.Information, $"Lade die Daten herunter {downloadUrl}", Times.Once());

await Assert.ThrowsExceptionAsync<FileNotFoundException>(async () => await new GeodiensteApi(loggerMock.Object, httpClientFactoryMock.Object).DownloadExportAsync(downloadUrl, destinationPath), "Keine GeoPackage-Datei im Archiv gefunden.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Cleanup()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");

processor.InputDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg";
await processor.RunGdalProcessingAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Cleanup()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");

processor.InputDataPath = "testdata\\lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg";
await processor.RunGdalProcessingAsync();
Expand Down
10 changes: 5 additions & 5 deletions Geodatenbezug.Test/Processors/NutzungsflaechenProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public async Task PrepareDataAsync()
.Setup(api => api.DownloadExportAsync(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync("downloadedFilePath");

loggerMock.Setup(LogLevel.Information, $"Bereite Daten für die Prozessierung von {topic.TopicTitle} ({topic.Canton}) vor...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {bewirtschaftungseinheitTopic.TopicTitle} ({bewirtschaftungseinheitTopic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Bereite Daten für die Prozessierung von {topic.TopicTitle} ({topic.Canton}) vor");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Information, $"Exportiere {bewirtschaftungseinheitTopic.TopicTitle} ({bewirtschaftungseinheitTopic.Canton})");

await processor.PrepareDataAsync();
geodiensteApiMock.Verify(api => api.StartExportAsync(topic), Times.Once);
Expand All @@ -73,8 +73,8 @@ public async Task PrepareDataAsync()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Lade Nutzungsart-Katalog von https://models.geo.admin.ch/BLW/LWB_Nutzungsflaechen_Kataloge_V2_0.xml...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Information, $"Lade Nutzungsart-Katalog von https://models.geo.admin.ch/BLW/LWB_Nutzungsflaechen_Kataloge_V2_0.xml");

processor.InputDataPath = "testdata\\lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg";
processor.BewirtschaftungseinheitDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Cleanup()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");

processor.InputDataPath = "testdata\\lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg";
await processor.RunGdalProcessingAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Cleanup()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");

processor.InputDataPath = "testdata\\lwb_perimeter_terrassenreben_v2_0_lv95_NE_202404191123.gpkg";
await processor.RunGdalProcessingAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Cleanup()
[TestMethod]
public async Task RunGdalProcessingAsync()
{
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung von Thema {topic.TopicTitle} ({topic.Canton})");

processor.InputDataPath = "testdata\\lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg";
await processor.RunGdalProcessingAsync();
Expand Down
12 changes: 6 additions & 6 deletions Geodatenbezug.Test/Processors/TopicProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task ExportTopic()
geodiensteApiMock
.Setup(api => api.CheckExportStatusAsync(It.IsAny<Topic>()))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"status\":\"success\", \"info\":\"Data ready to be downloaded. Provide your credentials to download the data.\", \"download_url\":\"test.com/data.zip\", \"exported_at\":\"2022-03-24T09:31:05.508\"}"), });
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");

var result = await Processor.ExportTopicAsync(topic);

Expand All @@ -80,7 +80,7 @@ public async Task ExportTopicOnlyOneExportIn24h()
geodiensteApiMock
.Setup(api => api.CheckExportStatusAsync(It.IsAny<Topic>()))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"status\":\"success\", \"info\":\"Data ready to be downloaded. Provide your credentials to download the data.\", \"download_url\":\"test.com/data.zip\", \"exported_at\":\"2022-03-24T09:31:05.508\"}"), });
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");

var result = await Processor.ExportTopicAsync(topic);

Expand All @@ -103,7 +103,7 @@ public async Task ExportTopicStartExportFails()
geodiensteApiMock
.Setup(api => api.StartExportAsync(It.IsAny<Topic>()))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("{\"error\":\"Data export information not found. Invalid token?\"}"), });
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Error, $"Fehler beim Starten des Exports für Thema {topic.TopicTitle} ({topic.Canton}): {HttpStatusCode.NotFound} - Data export information not found. Invalid token?");

await Assert.ThrowsExceptionAsync<InvalidOperationException>(async () => await Processor.ExportTopicAsync(topic), "Export failed");
Expand All @@ -130,7 +130,7 @@ public async Task ExportTopicCheckExportStatusFailed()
geodiensteApiMock
.Setup(api => api.CheckExportStatusAsync(It.IsAny<Topic>()))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"status\":\"failed\", \"info\":\"An unexpected error occurred. Please try again by starting a new data export.\"}"), });
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Error, $"Fehler bei der Statusabfrage des Datenexports für Thema {topic.TopicTitle} ({topic.Canton}): An unexpected error occurred. Please try again by starting a new data export.");

await Assert.ThrowsExceptionAsync<InvalidOperationException>(async () => await Processor.ExportTopicAsync(topic), "Export failed");
Expand Down Expand Up @@ -158,7 +158,7 @@ public async Task ExportTopicCheckExportStatusError()
geodiensteApiMock
.Setup(api => api.CheckExportStatusAsync(It.IsAny<Topic>()))
.ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("{\"error\":\"Data export information not found. Invalid token?\"}"), });
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Exportiere {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Error, $"Fehler bei der Statusabfrage des Datenexports für Thema {topic.TopicTitle} ({topic.Canton}): {HttpStatusCode.NotFound} - Data export information not found. Invalid token?");

await Assert.ThrowsExceptionAsync<InvalidOperationException>(async () => await Processor.ExportTopicAsync(topic), "Export failed");
Expand All @@ -183,7 +183,7 @@ public async Task PrepareDataFails()

processorMock.Setup(p => p.PrepareDataAsync())
.Throws(new InvalidOperationException("Something happened", new InvalidOperationException("Inner exception details")));
loggerMock.Setup(LogLevel.Information, $"Verarbeite Thema {topic.TopicTitle} ({topic.Canton})...");
loggerMock.Setup(LogLevel.Information, $"Verarbeite Thema {topic.TopicTitle} ({topic.Canton})");
loggerMock.Setup(LogLevel.Error, $"Fehler beim Verarbeiten des Themas {topic.TopicTitle} ({topic.Canton}): Something happened");

await Processor.ProcessAsync();
Expand Down
4 changes: 2 additions & 2 deletions Geodatenbezug/AzureStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AzureStorage(ILogger<AzureStorage> logger) : IAzureStorage
/// <inheritdoc />
public async Task<string> UploadFileAsync(string storageFilePath, string localFilePath)
{
logger.LogInformation($"Lade Datei {localFilePath} in den Azure Storage hoch...");
logger.LogInformation($"Lade Datei {localFilePath} in den Azure Storage hoch");
var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
if (string.IsNullOrEmpty(connectionString))
{
Expand All @@ -30,7 +30,7 @@ public async Task<string> UploadFileAsync(string storageFilePath, string localFi
using var localFileStream = File.OpenRead(localFilePath);
await blobClient.UploadAsync(localFileStream).ConfigureAwait(false);

logger.LogInformation($"Erstelle DownloadUrl für Datei {localFilePath}...");
logger.LogInformation($"Erstelle DownloadUrl für Datei {localFilePath}");
var sasBuilder = new BlobSasBuilder
{
BlobContainerName = StorageContainerName,
Expand Down
4 changes: 2 additions & 2 deletions Geodatenbezug/Geodatenbezug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Geodatenbezug(ILoggerFactory loggerFactory, Processor processing)
[Function(nameof(OrchestrateProcessing))]
public async Task OrchestrateProcessing([OrchestrationTrigger] TaskOrchestrationContext context)
{
logger.LogInformation("Start der Prozessierung...");
logger.LogInformation("Start der Prozessierung");
var topics = await context.CallActivityAsync<List<Topic>>(nameof(RetrieveTopics)).ConfigureAwait(true);
var results = new List<ProcessingResult>();
foreach (var topic in topics)
Expand All @@ -46,7 +46,7 @@ public async Task OrchestrateProcessing([OrchestrationTrigger] TaskOrchestration
[Function(nameof(RetrieveTopics))]
public async Task<List<Topic>?> RetrieveTopics([ActivityTrigger] string param)
{
logger.LogInformation("Laden der Themen...");
logger.LogInformation("Laden der Themen");
return await processing.GetTopicsToProcess().ConfigureAwait(false);
}

Expand Down
Loading