Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 8b19fc7

Browse files
authored
chore: upgrade towards net6.0 (#104)
* chore: update to netstandard2.1 * pr-add: upgrade towards net6.0 * pr-fix: update with new observability logging * pr-fix: update with increated time-out * pr-fix: simplified cloudevent consuming * pr-fix: introduce test collections for stable test runs * pr-fix: add all eventgrid integration tests under the same test collection
1 parent ca617ce commit 8b19fc7

File tree

18 files changed

+100
-55
lines changed

18 files changed

+100
-55
lines changed

build/variables/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
variables:
2-
DotNet.Sdk.Version: '3.1.201'
2+
DotNet.Sdk.Version: '6.0.100'
33
Project: 'Arcus.BackgroundJobs'
44
Vm.Image: 'ubuntu-latest'

src/Arcus.BackgroundJobs.AzureActiveDirectory/Arcus.BackgroundJobs.AzureActiveDirectory.csproj

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
55
<Authors>Arcus</Authors>
66
<Company>Arcus</Company>
77
<RepositoryType>Git</RepositoryType>
@@ -18,10 +18,21 @@
1818
<NoWarn>NU5125;NU5048</NoWarn>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
22+
<PackageReference Include="Arcus.EventGrid.Publishing" Version="[3.2.0, 4.0.0)" />
23+
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.4.0, 3.0.0)" />
24+
<PackageReference Include="Arcus.Security.Core" Version="[1.7.0, 2.0.0)" />
25+
<PackageReference Include="Guard.Net" Version="2.0.0" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
2229
<PackageReference Include="Arcus.EventGrid.Publishing" Version="[3.1.0, 4.0.0)" />
2330
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.0.0, 3.0.0)" />
2431
<PackageReference Include="Arcus.Security.Core" Version="[1.6.0, 2.0.0)" />
32+
<PackageReference Include="Guard.Net" Version="1.2.0" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
2536
<PackageReference Include="Azure.Identity" Version="1.4.1" />
2637
<PackageReference Include="CronScheduler.AspNetCore" Version="3.0.1" />
2738
<PackageReference Include="Microsoft.Graph" Version="4.6.0" />

src/Arcus.BackgroundJobs.AzureAppConfiguration/Arcus.BackgroundJobs.AzureAppConfiguration.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
55
<Authors>Arcus</Authors>
66
<Company>Arcus</Company>
77
<RepositoryType>Git</RepositoryType>
@@ -18,9 +18,17 @@
1818
<NoWarn>NU5125;NU5048</NoWarn>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
22+
<PackageReference Include="Arcus.EventGrid" Version="[3.2.0,4.0.0)" />
23+
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.2.0,2.0.0)" />
24+
</ItemGroup>
25+
26+
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
2227
<PackageReference Include="Arcus.EventGrid" Version="[3.0.0,4.0.0)" />
2328
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.1.0,2.0.0)" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
2432
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="4.5.0" />
2533
</ItemGroup>
2634

src/Arcus.BackgroundJobs.CloudEvents/Arcus.BackgroundJobs.CloudEvents.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
55
<Authors>Arcus</Authors>
66
<Company>Arcus</Company>
77
<RepositoryType>Git</RepositoryType>
@@ -18,7 +18,13 @@
1818
<NoWarn>NU5125;NU5048</NoWarn>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
22+
<PackageReference Include="Arcus.EventGrid" Version="[3.2.0,4.0.0)" />
23+
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.2.0,2.0.0)" />
24+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
25+
</ItemGroup>
26+
27+
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
2228
<PackageReference Include="Arcus.EventGrid" Version="[3.0.0,4.0.0)" />
2329
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.0.1,2.0.0)" />
2430
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />

src/Arcus.BackgroundJobs.Databricks/Arcus.BackgroundJobs.Databricks.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
55
<Authors>Arcus</Authors>
66
<Company>Arcus</Company>
77
<RepositoryType>Git</RepositoryType>
@@ -18,10 +18,19 @@
1818
<NoWarn>NU5125;NU5048</NoWarn>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
22+
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.4.0,3.0.0)" />
23+
<PackageReference Include="Arcus.Security.Core" Version="[1.7.0,2.0.0)" />
24+
<PackageReference Include="CronScheduler.AspNetCore" Version="3.0.1" />
25+
</ItemGroup>
26+
27+
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
2228
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.0.0,3.0.0)" />
2329
<PackageReference Include="Arcus.Security.Core" Version="[1.3.0,2.0.0)" />
2430
<PackageReference Include="CronScheduler.AspNetCore" Version="3.0.0" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
2534
<PackageReference Include="Microsoft.Azure.Databricks.Client" Version="1.1.1613.2" />
2635
</ItemGroup>
2736

src/Arcus.BackgroundJobs.KeyVault/Arcus.BackgroundJobs.KeyVault.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
55
<Authors>Arcus</Authors>
66
<Company>Arcus</Company>
77
<RepositoryType>Git</RepositoryType>
@@ -18,7 +18,14 @@
1818
<NoWarn>NU5125;NU5048</NoWarn>
1919
</PropertyGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
22+
<PackageReference Include="Arcus.EventGrid" Version="[3.2.0,4.0.0)" />
23+
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.2.0,2.0.0)" />
24+
<PackageReference Include="Arcus.Security.Core" Version="[1.7.0,2.0.0)" />
25+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
2229
<PackageReference Include="Arcus.EventGrid" Version="[3.0.0,4.0.0)" />
2330
<PackageReference Include="Arcus.Messaging.Pumps.ServiceBus" Version="[1.0.1,2.0.0)" />
2431
<PackageReference Include="Arcus.Security.Core" Version="[1.4.0,2.0.0)" />

src/Arcus.BackgroundJobs.Tests.Integration/AppConfiguration/AutoRefreshAppConfigurationBackgroundJobTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Arcus.BackgroundJobs.Tests.Integration.AppConfiguration
1818
{
1919
[Trait("Category", "Integration")]
20+
[Collection(TestCollections.Integration)]
2021
public class AutoRefreshAppConfigurationBackgroundJobTests
2122
{
2223
private readonly ILogger _logger;

src/Arcus.BackgroundJobs.Tests.Integration/Arcus.BackgroundJobs.Tests.Integration.csproj

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Arcus.EventGrid.Publishing" Version="3.2.0-preview-3" />
10-
<PackageReference Include="Arcus.EventGrid.Testing" Version="3.2.0-preview-3" />
11-
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="2.0.0" />
12-
<PackageReference Include="Arcus.Testing.Logging" Version="0.2.0-preview-2" />
9+
<PackageReference Include="Arcus.EventGrid.Testing" Version="3.2.0" />
10+
<PackageReference Include="Arcus.Testing.Logging" Version="0.3.0" />
1311
<PackageReference Include="Arcus.Testing.Security.Providers.InMemory" Version="0.3.0" />
1412
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.1.0" />
1513
<PackageReference Include="Bogus" Version="29.0.2" />
16-
<PackageReference Include="Guard.Net" Version="1.2.0" />
1714
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.2" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.8" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
2118
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.4.0" />
2219
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
2320
<PackageReference Include="Moq" Version="4.13.1" />
24-
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
2521

2622
<PackageReference Include="xunit" Version="2.3.1" />
2723
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

src/Arcus.BackgroundJobs.Tests.Integration/AzureActiveDirectory/ClientSecretExpirationJobTests.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
42
using System.Threading.Tasks;
53
using Arcus.BackgroundJobs.AzureActiveDirectory;
64
using Arcus.BackgroundJobs.Tests.Integration.AzureActiveDirectory.Fixture;
75
using Arcus.BackgroundJobs.Tests.Integration.Fixture;
86
using Arcus.BackgroundJobs.Tests.Integration.Hosting;
9-
using Arcus.EventGrid;
10-
using Arcus.EventGrid.Contracts;
117
using Arcus.Testing.Logging;
128
using CloudNative.CloudEvents;
139
using Microsoft.Extensions.DependencyInjection;
@@ -18,6 +14,7 @@
1814
namespace Arcus.BackgroundJobs.Tests.Integration.AzureActiveDirectory
1915
{
2016
[Trait(name: "Category", value: "Integration")]
17+
[Collection(TestCollections.Integration)]
2118
public class ClientSecretExpirationJobTests
2219
{
2320
private readonly ILogger _logger;
@@ -61,24 +58,19 @@ public async Task CheckExpiredOrAboutToExpireClientSecretsInAzureActiveDirectory
6158
await using (var consumer = await TestServiceBusEventConsumer.StartNewAsync(_config, _logger))
6259
{
6360
// Assert
64-
EventBatch<Event> eventBatch = consumer.Consume();
65-
Assert.NotEmpty(eventBatch.Events);
66-
IEnumerable<CloudEvent> cloudEvents = eventBatch.Events.Select(ev => ev.AsCloudEvent());
67-
Assert.All(cloudEvents, ev =>
68-
{
69-
Assert.NotNull(ev.Id);
70-
Assert.True(Enum.TryParse(ev.Type, out ClientSecretExpirationEventType eventType),
71-
$"Event should have either '{ClientSecretExpirationEventType.ClientSecretAboutToExpire}' or '{ClientSecretExpirationEventType.ClientSecretExpired}' as event type");
61+
CloudEvent cloudEvent = consumer.Consume();
62+
Assert.NotNull(cloudEvent.Id);
63+
Assert.True(Enum.TryParse(cloudEvent.Type, out ClientSecretExpirationEventType eventType),
64+
$"Event should have either '{ClientSecretExpirationEventType.ClientSecretAboutToExpire}' or '{ClientSecretExpirationEventType.ClientSecretExpired}' as event type");
7265

73-
var data = ev.GetPayload<AzureApplication>();
74-
Assert.IsType<Guid>(data.KeyId);
66+
var data = cloudEvent.GetPayload<AzureApplication>();
67+
Assert.IsType<Guid>(data.KeyId);
7568

76-
bool isAboutToExpire = eventType == ClientSecretExpirationEventType.ClientSecretAboutToExpire;
77-
bool isExpired = eventType == ClientSecretExpirationEventType.ClientSecretExpired;
78-
79-
Assert.True(isAboutToExpire == (data.RemainingValidDays > 0 && data.RemainingValidDays < expirationThreshold), $"Remaining days should be between 1-{expirationThreshold - 1} when the secret is about to expire");
80-
Assert.True(isExpired == data.RemainingValidDays < 0, "Remaining days should be negative when the secret is expired");
81-
});
69+
bool isAboutToExpire = eventType == ClientSecretExpirationEventType.ClientSecretAboutToExpire;
70+
bool isExpired = eventType == ClientSecretExpirationEventType.ClientSecretExpired;
71+
72+
Assert.True(isAboutToExpire == (data.RemainingValidDays > 0 && data.RemainingValidDays < expirationThreshold), $"Remaining days should be between 1-{expirationThreshold - 1} when the secret is about to expire");
73+
Assert.True(isExpired == data.RemainingValidDays < 0, "Remaining days should be negative when the secret is expired");
8274
}
8375
}
8476
}

src/Arcus.BackgroundJobs.Tests.Integration/AzureActiveDirectory/Fixture/TestServiceBusEventConsumer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Arcus.EventGrid;
77
using Arcus.EventGrid.Contracts;
88
using Arcus.EventGrid.Testing.Infrastructure.Hosts.ServiceBus;
9+
using CloudNative.CloudEvents;
910
using GuardNet;
1011
using Microsoft.Extensions.Configuration;
1112
using Microsoft.Extensions.Logging;
@@ -49,17 +50,13 @@ public static async Task<TestServiceBusEventConsumer> StartNewAsync(TestConfig c
4950
/// <summary>
5051
/// Receives an event produced on the Azure Service Bus.
5152
/// </summary>
52-
public EventBatch<Event> Consume()
53+
public CloudEvent Consume()
5354
{
54-
List<Event> eventList = new List<Event>();
55-
Event receivedEvent = _serviceBusEventConsumerHost.GetReceivedEvent(
55+
CloudEvent receivedEvent = _serviceBusEventConsumerHost.GetReceivedEvent(
5656
data => data.Source == new Uri("https://github.com/arcus-azure/arcus.backgroundjobs"),
57-
TimeSpan.FromSeconds(300));
57+
TimeSpan.FromMinutes(8));
5858

59-
eventList.Add(receivedEvent);
60-
EventBatch<Event> eventBatch = new EventBatch<Event>(receivedEvent.Id, eventList);
61-
62-
return eventBatch;
59+
return receivedEvent;
6360
}
6461

6562
/// <summary>

0 commit comments

Comments
 (0)