Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Merge branch 'dev' into master (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Feb 13, 2019
2 parents b059631 + 25a7b64 commit 2a87a94
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 6 deletions.
7 changes: 7 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ Invoke-BuildStep 'Creating artifacts' {
}

$nuspecPackages = `
"src\Ng\Catalog2Dnx.nuspec", `
"src\Ng\Catalog2Lucene.nuspec", `
"src\Ng\Catalog2Monitoring.nuspec", `
"src\Ng\Catalog2Registration.nuspec", `
"src\Ng\Feed2Catalog.nuspec", `
"src\Ng\Monitoring2Monitoring.nuspec", `
"src\Ng\MonitoringProcessor.nuspec", `
"src\Ng\Ng.nuspec", `
"src\Ng\Ng.Operations.nuspec"

Expand Down
1 change: 1 addition & 0 deletions src/Ng/Arguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class Arguments
public const string Path = "path";
public const string Source = "source";
public const string Verbose = "verbose";
public const string InstanceName = "instanceName";

public const int DefaultInterval = 3; // seconds
public const string Interval = "interval";
Expand Down
17 changes: 17 additions & 0 deletions src/Ng/Catalog2Dnx.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Catalog2Dnx</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Catalog2Dnx job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/Catalog2Lucene.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Catalog2Lucene</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Catalog2Lucene job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/Catalog2Monitoring.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Catalog2Monitoring</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Catalog2Monitoring job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/Catalog2Registration.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Catalog2Registration</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Catalog2Registration job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/Feed2Catalog.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Feed2Catalog</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Feed2Catalog job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/Monitoring2Monitoring.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Monitoring2Monitoring</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The Monitoring2Monitoring job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
17 changes: 17 additions & 0 deletions src/Ng/MonitoringProcessor.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>MonitoringProcessor</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>The MonitoringProcessor job.</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="Ng"/>
<file src="Scripts\*.cmd" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
7 changes: 7 additions & 0 deletions src/Ng/Ng.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="Catalog2Dnx.nuspec" />
<None Include="Catalog2Lucene.nuspec" />
<None Include="Catalog2Monitoring.nuspec" />
<None Include="Catalog2Registration.nuspec" />
<None Include="Feed2Catalog.nuspec" />
<None Include="Monitoring2Monitoring.nuspec" />
<None Include="MonitoringProcessor.nuspec" />
<None Include="Ng.Operations.nuspec">
<SubType>Designer</SubType>
</None>
Expand Down
3 changes: 2 additions & 1 deletion src/Ng/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public static async Task MainAsync(string[] args)
}

var jobName = args[0];
TelemetryConfiguration.Active.TelemetryInitializers.Add(new JobNameTelemetryInitializer(jobName));
var instanceName = arguments.GetOrDefault(Arguments.InstanceName, jobName);
TelemetryConfiguration.Active.TelemetryInitializers.Add(new JobNameTelemetryInitializer(jobName, instanceName));

// Configure ApplicationInsights
ApplicationInsights.Initialize(arguments.GetOrDefault<string>(Arguments.InstrumentationKey));
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2DnxV3.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.ngcatalog2dnx.Title}"
title #{Jobs.ngcatalog2dnx.Title}

start /w Ng.exe catalog2dnx ^
-instanceName catalog2dnx-global ^
-source #{Jobs.ngcatalog2dnx.Catalog.Source} ^
-contentBaseAddress #{Jobs.ngcatalog2dnx.ContentBaseAddress} ^
-storageBaseAddress #{Jobs.ngcatalog2dnx.StorageBaseAddress} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2DnxV3China.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.ngcatalog2dnxChina.Title}"
title #{Jobs.ngcatalog2dnxChina.Title}

start /w Ng.exe catalog2dnx ^
-instanceName catalog2dnx-china ^
-source #{Jobs.ngcatalog2dnx.Catalog.Source} ^
-contentBaseAddress #{Jobs.China.ngcatalog2dnx.ContentBaseAddress} ^
-storageBaseAddress #{Jobs.China.ngcatalog2dnx.StorageBaseAddress} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2LuceneV3-Asia.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.Asia.catalog2lucenev3.Title}"
title #{Jobs.Asia.catalog2lucenev3.Title}

start /w Ng.exe catalog2lucene ^
-instanceName catalog2lucene-ea ^
-source #{Jobs.common.v3.Source} ^
-luceneDirectoryType azure ^
-luceneStorageAccountName #{Jobs.Asia.v3.Storage.Name} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2LuceneV3-Reg2-USSC.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.catalog2lucenev3reg2ussc.Title}"
title #{Jobs.catalog2lucenev3reg2ussc.Title}

start /w ng.exe catalog2lucene ^
-instanceName catalog2lucene-ussc ^
-source #{Jobs.common.v3.Source} ^
-luceneDirectoryType azure ^
-luceneStorageAccountName #{Jobs.common.v3.Storage.USSC.Name} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2LuceneV3-Reg2.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.catalog2lucenev3reg2.Title}"
title #{Jobs.catalog2lucenev3reg2.Title}

start /w ng.exe catalog2lucene ^
-instanceName catalog2lucene-usnc ^
-source #{Jobs.common.v3.Source} ^
-luceneDirectoryType azure ^
-luceneStorageAccountName #{Jobs.common.v3.Storage.Primary.Name} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2LuceneV3-SouthEastAsia.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.catalog2lucenev3reg2southeastasia.Title}"
title #{Jobs.catalog2lucenev3reg2southeastasia.Title}

start /w Ng.exe catalog2lucene ^
-instanceName catalog2lucene-sea ^
-source #{Jobs.common.v3.Source} ^
-luceneDirectoryType azure ^
-luceneStorageAccountName #{Jobs.SouthEastAsia.v3.Storage.Name} ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2RegistrationV3-Reg3-China.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.China.catalog2registrationv3reg3.Title}"
title #{Jobs.China.catalog2registrationv3reg3.Title}

start /w ng.exe catalog2registration ^
-instanceName catalog2registration-china ^
-source #{Jobs.common.China.v3.Source} ^
-contentBaseAddress #{Jobs.China.catalog2registrationv3reg3.ContentBaseAddress} ^
-storageType azure ^
Expand Down
1 change: 1 addition & 0 deletions src/Ng/Scripts/Catalog2RegistrationV3-Reg3.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ echo "Starting job - #{Jobs.catalog2registrationv3reg3.Title}"
title #{Jobs.catalog2registrationv3reg3.Title}

start /w ng.exe catalog2registration ^
-instanceName catalog2registration-global ^
-source #{Jobs.catalog2registrationv3reg3.Source} ^
-contentBaseAddress #{Jobs.catalog2registrationv3reg3.ContentBaseAddress} ^
-storageType azure ^
Expand Down
6 changes: 5 additions & 1 deletion src/Ng/Telemetry/JobNameTelemetryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ namespace Ng
public class JobNameTelemetryInitializer : ITelemetryInitializer
{
private const string JobNameKey = "JobName";
private const string InstanceNameKey = "InstanceName";

private readonly string _jobName;
private readonly string _instanceName;

public JobNameTelemetryInitializer(string jobName)
public JobNameTelemetryInitializer(string jobName, string instanceName)
{
_jobName = jobName ?? throw new ArgumentNullException(nameof(jobName));
_instanceName = instanceName ?? throw new ArgumentNullException(nameof(instanceName));
}

public void Initialize(ITelemetry telemetry)
{
telemetry.Context.Properties[JobNameKey] = _jobName;
telemetry.Context.Properties[InstanceNameKey] = _instanceName;
}
}
}
18 changes: 14 additions & 4 deletions tests/NgTests/JobNameTelemetryInitializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,36 @@ public class JobNameTelemetryInitializerTests
public void Constructor_WhenJobNameIsNull_Throws()
{
var exception = Assert.Throws<ArgumentNullException>(
() => new JobNameTelemetryInitializer(jobName: null));
() => new JobNameTelemetryInitializer(jobName: null, instanceName: "instanceName"));

Assert.Equal("jobName", exception.ParamName);
}

[Fact]
public void Initialize_WhenTelemetryIsNotNull_SetsJobName()
public void Constructor_WhenInstanceNameIsNull_Throws()
{
var exception = Assert.Throws<ArgumentNullException>(
() => new JobNameTelemetryInitializer(jobName: "jobName", instanceName: null));

Assert.Equal("instanceName", exception.ParamName);
}

[Fact]
public void Initialize_WhenTelemetryIsNotNull_SetsJobNameAndInstanceName()
{
var telemetryContext = new TelemetryContext();
var telemetry = new Mock<ITelemetry>();

telemetry.SetupGet(x => x.Context)
.Returns(telemetryContext);

var initializer = new JobNameTelemetryInitializer(jobName: "a");
var initializer = new JobNameTelemetryInitializer(jobName: "a", instanceName: "b");

initializer.Initialize(telemetry.Object);

Assert.Equal(1, telemetryContext.Properties.Count);
Assert.Equal(2, telemetryContext.Properties.Count);
Assert.Equal("a", telemetryContext.Properties["JobName"]);
Assert.Equal("b", telemetryContext.Properties["InstanceName"]);
}
}
}

0 comments on commit 2a87a94

Please sign in to comment.