This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the ability to schedule validation message processing in the f…
…uture (#69) * Added ScheduledEnqueueTimeUtc to the IBrokeredMessage and implementation. Added tests for the property * Added the postponed version of the StartValidationAsync to the IPackageValidationEnqueuer
- Loading branch information
Showing
9 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/NuGet.Services.Validation/IPackageValidationEnqueuer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuGet.Services.Validation | ||
{ | ||
public interface IPackageValidationEnqueuer | ||
{ | ||
/// <summary> | ||
/// Enqueues validation of the specified package to start ASAP. | ||
/// </summary> | ||
/// <param name="message">Package information</param> | ||
Task StartValidationAsync(PackageValidationMessageData message); | ||
|
||
/// <summary> | ||
/// Enqueues validation of the specified package to start no sooner than specified time | ||
/// </summary> | ||
/// <param name="message">Package information</param> | ||
/// <param name="postponeProcessingTill">The time till which validation processing should be postponed.</param> | ||
Task StartValidationAsync(PackageValidationMessageData message, DateTimeOffset postponeProcessingTill); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/NuGet.Services.ServiceBus.Tests/BrokeredMessageWrapperFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Xunit; | ||
|
||
namespace NuGet.Services.ServiceBus.Tests | ||
{ | ||
public class BrokeredMessageWrapperFacts | ||
{ | ||
[Fact] | ||
public void DoesNotMessUpScheduledEnqueueTimeUtc() | ||
{ | ||
var now = DateTimeOffset.Now; | ||
|
||
var message = new BrokeredMessageWrapper("data"); | ||
message.ScheduledEnqueueTimeUtc = now; | ||
Assert.Equal(now, message.ScheduledEnqueueTimeUtc); | ||
} | ||
|
||
[Fact] | ||
public void ForcesUtcOnScheduledEnqueueTimeUtc() | ||
{ | ||
var now = DateTimeOffset.Now; | ||
var nowUtc = now.UtcDateTime; | ||
|
||
var message = new BrokeredMessageWrapper("data"); | ||
message.ScheduledEnqueueTimeUtc = now; | ||
|
||
Assert.Equal(DateTimeKind.Utc, message.BrokeredMessage.ScheduledEnqueueTimeUtc.Kind); | ||
Assert.Equal(nowUtc, message.BrokeredMessage.ScheduledEnqueueTimeUtc); | ||
Assert.Equal(TimeSpan.Zero, message.ScheduledEnqueueTimeUtc.Offset); | ||
} | ||
|
||
[Fact] | ||
public void DefaultScheduledEnqueueTimeUtcIsNotInTheFuture() | ||
{ | ||
var message = new BrokeredMessageWrapper("data"); | ||
Assert.True(message.ScheduledEnqueueTimeUtc <= DateTimeOffset.Now); | ||
} | ||
|
||
[Fact] | ||
public void MinScheduledEnqueueTimeUtcWorks() | ||
{ | ||
var message = new BrokeredMessageWrapper("data"); | ||
message.ScheduledEnqueueTimeUtc = DateTimeOffset.MinValue; | ||
|
||
Assert.True(message.ScheduledEnqueueTimeUtc < DateTimeOffset.Now); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
tests/NuGet.Services.ServiceBus.Tests/NuGet.Services.ServiceBus.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{FF5CA51A-CD6A-463F-AE9A-5737FF0FCFA7}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>NuGet.Services.ServiceBus.Tests</RootNamespace> | ||
<AssemblyName>NuGet.Services.ServiceBus.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="BrokeredMessageWrapperFacts.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="project.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NuGet.Services.ServiceBus\NuGet.Services.ServiceBus.csproj"> | ||
<Project>{9337000b-ea3b-40be-9a33-38bc28dfd0cb}</Project> | ||
<Name>NuGet.Services.ServiceBus</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
14 changes: 14 additions & 0 deletions
14
tests/NuGet.Services.ServiceBus.Tests/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("NuGet.Services.ServiceBus.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("NuGet.Services.ServiceBus.Tests")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: ComVisible(false)] | ||
[assembly: Guid("ff5ca51a-cd6a-463f-ae9a-5737ff0fcfa7")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"dependencies": { | ||
"WindowsAzure.ServiceBus": "4.1.3", | ||
"Moq": "4.5.23", | ||
"xunit": "2.1.0", | ||
"xunit.runner.visualstudio": "2.1.0" | ||
}, | ||
"frameworks": { | ||
"net452": {} | ||
}, | ||
"runtimes": { | ||
"win": {} | ||
} | ||
} |