Skip to content

Commit 872034f

Browse files
authored
Move to latest ServerCommon for new Service Bus SDK (#1152)
* Move to new Service Bus library * Resolve some restore warnings Progress on NuGet/Engineering#5011
1 parent 6adc9c2 commit 872034f

21 files changed

+61
-64
lines changed

Directory.Build.props

-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
<Project>
2-
3-
<!-- NuGet dependencies shared across projects -->
4-
<PropertyGroup>
5-
<ServerCommonPackageVersion>2.111.0</ServerCommonPackageVersion>
6-
<NuGetClientPackageVersion>6.4.2</NuGetClientPackageVersion>
7-
<NuGetGalleryPackageVersion>4.4.5-dev-8381969</NuGetGalleryPackageVersion>
8-
</PropertyGroup>
9-
102
<ItemGroup>
113
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
124
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

Directory.Packages.props

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<EnablePackageVersionOverride>false</EnablePackageVersionOverride>
5+
<ServerCommonPackageVersion>2.112.0</ServerCommonPackageVersion>
6+
<NuGetClientPackageVersion>6.6.1</NuGetClientPackageVersion>
7+
<NuGetGalleryPackageVersion>4.4.5-dev-8435783</NuGetGalleryPackageVersion>
58
</PropertyGroup>
69
<ItemGroup>
710
<PackageVersion Include="Autofac" Version="4.9.1" />
@@ -34,7 +37,7 @@
3437
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
3538
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
3639
<PackageVersion Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
37-
<PackageVersion Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.1.0" />
40+
<PackageVersion Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.2.3" />
3841
<PackageVersion Include="Moq" Version="4.13.1" />
3942
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
4043
<PackageVersion Include="NuGet.Build.Tasks.Pack" Version="4.8.0" />
@@ -54,6 +57,7 @@
5457
<PackageVersion Include="NuGet.Services.Status.Table" Version="$(ServerCommonPackageVersion)" />
5558
<PackageVersion Include="NuGet.Services.Storage" Version="$(ServerCommonPackageVersion)" />
5659
<PackageVersion Include="NuGet.Services.Testing.Entities" Version="$(ServerCommonPackageVersion)" />
60+
<PackageVersion Include="NuGet.Services.Validation" Version="$(ServerCommonPackageVersion)" />
5761
<PackageVersion Include="NuGet.StrongName.Octokit" Version="0.32.0" />
5862
<PackageVersion Include="NuGet.StrongName.json-ld.net" Version="1.0.6" />
5963
<PackageVersion Include="NuGet.Versioning" Version="$(NuGetClientPackageVersion)" />

NuGet.Jobs.sln

+3
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
185185
.editorconfig = .editorconfig
186186
build.ps1 = build.ps1
187187
Directory.Build.props = Directory.Build.props
188+
Directory.Packages.props = Directory.Packages.props
189+
global.json = global.json
190+
.nuget\NuGet.config = .nuget\NuGet.config
188191
SdkProjects.props = SdkProjects.props
189192
sign.thirdparty.props = sign.thirdparty.props
190193
test.ps1 = test.ps1

build.ps1

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ param (
99
[string]$SemanticVersion = '1.0.0-zlocal',
1010
[string]$Branch = 'zlocal',
1111
[string]$CommitSHA,
12-
[string]$BuildBranchCommit = '900bef1848c739abb49805f2706014d0be4dccbe'
12+
[string]$BuildBranchCommit = '900bef1848c739abb49805f2706014d0be4dccbe' #DevSkim: ignore DS173237. Not a secret/token. It is a commit hash.
1313
)
1414

1515
# For TeamCity - If any issue occurs, this script fails the build. - By default, TeamCity returns an exit code of 0 for all powershell scripts, even if they fail
@@ -25,10 +25,7 @@ if (-not (Test-Path "$PSScriptRoot/build")) {
2525
New-Item -Path "$PSScriptRoot/build" -ItemType "directory"
2626
}
2727

28-
# Enable TLS 1.2 since GitHub requires it.
29-
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
30-
31-
wget -UseBasicParsing -Uri "https://raw.githubusercontent.com/NuGet/ServerCommon/$BuildBranchCommit/build/init.ps1" -OutFile "$PSScriptRoot/build/init.ps1"
28+
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/NuGet/ServerCommon/$BuildBranchCommit/build/init.ps1" -OutFile "$PSScriptRoot/build/init.ps1"
3229
. "$PSScriptRoot/build/init.ps1" -BuildBranchCommit "$BuildBranchCommit"
3330

3431
Function Clean-Tests {

global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.300",
4+
"rollForward": "latestFeature"
5+
}
6+
}

src/NuGet.Services.Validation.Orchestrator/OrchestrationRunner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task RunOrchestrationAsync()
3838
{
3939
_logger.LogInformation("Starting up the orchestration");
4040

41-
_subscriptionProcessor.Start(_configuration.MaxConcurrentCalls);
41+
await _subscriptionProcessor.StartAsync(_configuration.MaxConcurrentCalls);
4242
await Task.Delay(_configuration.ProcessRecycleInterval);
4343

4444
_logger.LogInformation("Recycling the process...");

src/NuGet.Services.Validation.Orchestrator/PackageValidationMessageDataSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public PackageValidationMessageDataSerializationAdapter(IServiceBusMessageSerial
1414
_serializer = serializer;
1515
}
1616

17-
public PackageValidationMessageData Deserialize(IBrokeredMessage message)
17+
public PackageValidationMessageData Deserialize(IReceivedBrokeredMessage message)
1818
=> _serializer.DeserializePackageValidationMessageData(message);
1919

2020
public IBrokeredMessage Serialize(PackageValidationMessageData message)

src/Validation.Common.Job/SubscriptionProcessorJob.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public override async Task Run()
4545
$"SubcriptionProcessorJob<T>.{nameof(SetupDefaultSubscriptionProcessorConfiguration)}() or set it up your way.");
4646
}
4747

48-
processor.Start(configuration.Value.MaxConcurrentCalls);
48+
await processor.StartAsync(configuration.Value.MaxConcurrentCalls);
4949

5050
// Wait a certain period of time, and then shutdown this process so that it is restarted.
5151
await Task.Delay(configuration.Value.ProcessDuration);

src/Validation.ContentScan.Core/ContentScanMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ContentScanMessageSerializer : IBrokeredMessageSerializer<ContentSc
1717
private IBrokeredMessageSerializer<CheckContentScanStatusData1> _checkScanStatusSerializer =
1818
new BrokeredMessageSerializer<CheckContentScanStatusData1>();
1919

20-
public ContentScanData Deserialize(IBrokeredMessage message)
20+
public ContentScanData Deserialize(IReceivedBrokeredMessage message)
2121
{
2222
var schemaName = message.GetSchemaName();
2323
switch (schemaName)

src/Validation.PackageSigning.Core/Messages/CertificateValidationMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public IBrokeredMessage Serialize(CertificateValidationMessage message)
2424
});
2525
}
2626

27-
public CertificateValidationMessage Deserialize(IBrokeredMessage brokeredMessage)
27+
public CertificateValidationMessage Deserialize(IReceivedBrokeredMessage brokeredMessage)
2828
{
2929
var message = _serializer.Deserialize(brokeredMessage);
3030

src/Validation.PackageSigning.Core/Messages/SignatureValidationMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public IBrokeredMessage Serialize(SignatureValidationMessage message)
2626
});
2727
}
2828

29-
public SignatureValidationMessage Deserialize(IBrokeredMessage message)
29+
public SignatureValidationMessage Deserialize(IReceivedBrokeredMessage message)
3030
{
3131
var deserializedMessage = _serializer.Deserialize(message);
3232

src/Validation.ScanAndSign.Core/ScanAndSignMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ScanAndSignMessageSerializer : IBrokeredMessageSerializer<ScanAndSi
1616
private IBrokeredMessageSerializer<ScanAndSignMessageData2> _serializer2 =
1717
new BrokeredMessageSerializer<ScanAndSignMessageData2>();
1818

19-
public ScanAndSignMessage Deserialize(IBrokeredMessage message)
19+
public ScanAndSignMessage Deserialize(IReceivedBrokeredMessage message)
2020
{
2121
try
2222
{

src/Validation.Symbols.Core/SymbolsIngesterMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class SymbolsIngesterMessageSerializer : IBrokeredMessageSerializer<Symbo
1313
private IBrokeredMessageSerializer<SymbolsIngesterMessageDataV1> _serializer =
1414
new BrokeredMessageSerializer<SymbolsIngesterMessageDataV1>();
1515

16-
public SymbolsIngesterMessage Deserialize(IBrokeredMessage message)
16+
public SymbolsIngesterMessage Deserialize(IReceivedBrokeredMessage message)
1717
{
1818
var deserializedMessage = _serializer.Deserialize(message);
1919

src/Validation.Symbols.Core/SymbolsValidatorMessageSerializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class SymbolsValidatorMessageSerializer : IBrokeredMessageSerializer<Symb
1313
private IBrokeredMessageSerializer<SymbolsValidatorMessageDataV1> _serializer =
1414
new BrokeredMessageSerializer<SymbolsValidatorMessageDataV1>();
1515

16-
public SymbolsValidatorMessage Deserialize(IBrokeredMessage message)
16+
public SymbolsValidatorMessage Deserialize(IReceivedBrokeredMessage message)
1717
{
1818
var deserializedMessage = _serializer.Deserialize(message);
1919

tests/NuGet.Services.Validation.Orchestrator.Tests/BaseValidationMessageHandlerFacts.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Elmah.ContentSyndication;
88
using Microsoft.Extensions.Logging;
99
using Microsoft.Extensions.Options;
10-
using Microsoft.ServiceBus.Messaging;
1110
using Moq;
1211
using NuGet.Jobs.Validation;
1312
using NuGet.Jobs.Validation.Leases;

tests/NuGet.Services.Validation.Orchestrator.Tests/OrchestrationRunnerFacts.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ public async Task StartsMessageProcessing()
2121
var runner = CreateRunner();
2222
await runner.RunOrchestrationAsync();
2323

24-
SubscriptionProcessorMock.Verify(o => o.Start(DefaultMaxConcurrentCalls), Times.Once());
24+
SubscriptionProcessorMock.Verify(o => o.StartAsync(DefaultMaxConcurrentCalls), Times.Once());
2525
}
2626

2727
[Fact]
2828
public async Task ShutsDownMessageProcessing()
2929
{
3030
var startCalled = false;
3131
SubscriptionProcessorMock
32-
.Setup(o => o.Start(DefaultMaxConcurrentCalls))
32+
.Setup(o => o.StartAsync(DefaultMaxConcurrentCalls))
33+
.Returns(Task.CompletedTask)
3334
.Callback(() => startCalled = true);
3435

3536
SubscriptionProcessorMock

tests/NuGet.Services.Validation.Orchestrator.Tests/SymbolValidationMessageHandlerFacts.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using System.Threading.Tasks;
78
using Microsoft.Extensions.Logging;
89
using Microsoft.Extensions.Options;
@@ -275,7 +276,7 @@ public async Task DropsMessageIfPackageIsSoftDeletedForCheckValidator()
275276
Times.Once);
276277
}
277278

278-
private class MessageWithCustomDeliveryCount : IBrokeredMessage
279+
private class MessageWithCustomDeliveryCount : IReceivedBrokeredMessage
279280
{
280281
private readonly IBrokeredMessage _inner;
281282

@@ -285,23 +286,18 @@ public MessageWithCustomDeliveryCount(IBrokeredMessage inner, int deliveryCount)
285286
DeliveryCount = deliveryCount;
286287
}
287288

288-
public int DeliveryCount { get; private set; }
289-
290-
public string GetBody() => _inner.GetBody();
291-
public Stream GetBody<Stream>() => _inner.GetBody<Stream>();
292-
public IDictionary<string, object> Properties => _inner.Properties;
293-
294-
public DateTimeOffset ScheduledEnqueueTimeUtc { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
289+
public int DeliveryCount { get; }
295290
public DateTimeOffset ExpiresAtUtc => throw new NotImplementedException();
291+
public TimeSpan TimeToLive => throw new NotImplementedException();
292+
public IReadOnlyDictionary<string, object> Properties => _inner.Properties.ToDictionary(x => x.Key, x => x.Value);
296293
public DateTimeOffset EnqueuedTimeUtc => throw new NotImplementedException();
297-
public TimeSpan TimeToLive { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
298-
299-
public string MessageId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
294+
public DateTimeOffset ScheduledEnqueueTimeUtc => throw new NotImplementedException();
295+
public string MessageId => throw new NotImplementedException();
300296

301297
public Task AbandonAsync() => throw new NotImplementedException();
302-
public IBrokeredMessage Clone() => throw new NotImplementedException();
303298
public Task CompleteAsync() => throw new NotImplementedException();
304-
public void Dispose() => throw new NotImplementedException();
299+
public string GetBody() => _inner.GetBody();
300+
public TStream GetBody<TStream>() => _inner.GetBody<TStream>();
305301
}
306302
}
307303

tests/NuGet.Services.Validation.Orchestrator.Tests/ValidationMessageHandlerFacts.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using System.Threading.Tasks;
78
using Microsoft.Extensions.Logging;
89
using Microsoft.Extensions.Options;
@@ -278,7 +279,7 @@ public async Task DropsMessageIfPackageIsSoftDeletedForCheckValidator()
278279
Times.Once);
279280
}
280281

281-
private class MessageWithCustomDeliveryCount : IBrokeredMessage
282+
private class MessageWithCustomDeliveryCount : IReceivedBrokeredMessage
282283
{
283284
private readonly IBrokeredMessage _inner;
284285

@@ -288,23 +289,18 @@ public MessageWithCustomDeliveryCount(IBrokeredMessage inner, int deliveryCount)
288289
DeliveryCount = deliveryCount;
289290
}
290291

291-
public int DeliveryCount { get; private set; }
292-
293-
public string GetBody() => _inner.GetBody();
294-
public Stream GetBody<Stream>() => _inner.GetBody<Stream>();
295-
public IDictionary<string, object> Properties => _inner.Properties;
296-
297-
public DateTimeOffset ScheduledEnqueueTimeUtc { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
292+
public int DeliveryCount { get; }
298293
public DateTimeOffset ExpiresAtUtc => throw new NotImplementedException();
294+
public TimeSpan TimeToLive => throw new NotImplementedException();
295+
public IReadOnlyDictionary<string, object> Properties => _inner.Properties.ToDictionary(x => x.Key, x => x.Value);
299296
public DateTimeOffset EnqueuedTimeUtc => throw new NotImplementedException();
300-
public TimeSpan TimeToLive { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
301-
302-
public string MessageId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
297+
public DateTimeOffset ScheduledEnqueueTimeUtc => throw new NotImplementedException();
298+
public string MessageId => throw new NotImplementedException();
303299

304300
public Task AbandonAsync() => throw new NotImplementedException();
305-
public IBrokeredMessage Clone() => throw new NotImplementedException();
306301
public Task CompleteAsync() => throw new NotImplementedException();
307-
public void Dispose() => throw new NotImplementedException();
302+
public string GetBody() => _inner.GetBody();
303+
public TStream GetBody<TStream>() => _inner.GetBody<TStream>();
308304
}
309305
}
310306

tests/Validation.ContentScan.tests/ContentScanEnqueuerFacts.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public class ContentScanEnqueuerFactsBase
200200

201201
protected ContentScanData _capturedMessage;
202202
protected IBrokeredMessage _capturedBrokeredMessage;
203-
protected BrokeredMessageWrapper _serializedMessage;
203+
protected ServiceBusMessageWrapper _serializedMessage;
204204

205205
protected readonly IValidationRequest _validationRequest;
206206
protected readonly List<string> _owners;
@@ -225,7 +225,7 @@ public ContentScanEnqueuerFactsBase()
225225

226226
_validationRequest = new ValidationRequest(Guid.NewGuid(), new Uri("https://example.com/testpackage.nupkg"));
227227

228-
_serializedMessage = new BrokeredMessageWrapper("somedata");
228+
_serializedMessage = new ServiceBusMessageWrapper("somedata");
229229

230230
_serializerMock
231231
.Setup(s => s.Serialize(It.IsAny<ContentScanData>()))

tests/Validation.PackageSigning.ScanAndSign.Tests/ScanAndSignEnqueuerFacts.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public class ScanAndSignEnqueuerFactsBase
238238

239239
protected ScanAndSignMessage _capturedMessage;
240240
protected IBrokeredMessage _capturedBrokeredMessage;
241-
protected BrokeredMessageWrapper _serializedMessage;
241+
protected ServiceBusMessageWrapper _serializedMessage;
242242

243243
protected readonly INuGetValidationRequest _validationRequest;
244244
protected readonly List<string> _owners;
@@ -264,7 +264,7 @@ public ScanAndSignEnqueuerFactsBase()
264264
_validationRequest = new NuGetValidationRequest(Guid.NewGuid(), 42, "somepackage", "someversion", "https://example.com/testpackage.nupkg");
265265
_owners = new List<string> {"Billy", "Bob"};
266266

267-
_serializedMessage = new BrokeredMessageWrapper("somedata");
267+
_serializedMessage = new ServiceBusMessageWrapper("somedata");
268268

269269
_serializerMock
270270
.Setup(s => s.Serialize(It.IsAny<ScanAndSignMessage>()))

tests/Validation.PackageSigning.ScanAndSign.Tests/ScanAndSignMessageSerializerFacts.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
6+
using Moq;
97
using Newtonsoft.Json;
108
using NuGet.Jobs.Validation.ScanAndSign;
119
using NuGet.Services.ServiceBus;
@@ -71,7 +69,7 @@ public void SerializesVersion2()
7169

7270
private ScanAndSignMessageSerializer _target = new ScanAndSignMessageSerializer();
7371

74-
private IBrokeredMessage CreateMessage(
72+
private IReceivedBrokeredMessage CreateMessage(
7573
int version,
7674
OperationRequestType operationType,
7775
Guid validationId,
@@ -95,11 +93,16 @@ private IBrokeredMessage CreateMessage(
9593

9694
var payloadStr = JsonConvert.SerializeObject(payload);
9795

98-
var message = new BrokeredMessageWrapper(payloadStr);
99-
message.Properties["SchemaName"] = "SignatureValidationMessageData";
100-
message.Properties["SchemaVersion"] = version;
96+
var message = new Mock<IReceivedBrokeredMessage>();
97+
message.Setup(x => x.Properties).Returns(new Dictionary<string, object>
98+
{
99+
{ "SchemaName", "SignatureValidationMessageData" },
100+
{ "SchemaVersion", version },
101+
});
102+
103+
message.Setup(x => x.GetBody()).Returns(payloadStr);
101104

102-
return message;
105+
return message.Object;
103106
}
104107
}
105108
}

0 commit comments

Comments
 (0)