in src/LibraryTest/Library/HostTests.cs [18:59]
public async Task HostTests_RunsLibrary()
{
// ARRANGE
var telemetryClient = Common.SetupStubTelemetryClient(out var sentItems);
int port = Common.GetPort();
var config = $@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Configuration>
<Host>0.0.0.0</Host>
<Port>{port}</Port>
<InstrumentationKey>ikey1</InstrumentationKey>
<LiveMetricsStreamAuthenticationApiKey></LiveMetricsStreamAuthenticationApiKey>
<Watchlist>
<Namespaces>default</Namespaces>
</Watchlist>
<AdaptiveSampling Enabled=""true"">
<MaxEventsPerSecond>%ISTIO_MIXER_PLUGIN_AI_ADAPTIVE_SAMPLING_EVENTS_LIMIT%</MaxEventsPerSecond>
<!--Telemetry items other than events are counted together-->
<MaxOtherItemsPerSecond>%ISTIO_MIXER_PLUGIN_AI_ADAPTIVE_SAMPLING_LIMIT%</MaxOtherItemsPerSecond>
</AdaptiveSampling>
</Configuration>
";
// ACT
Host host = new Host(telemetryClient);
host.Run(config, TimeSpan.FromSeconds(5));
Thread.Sleep(TimeSpan.FromMilliseconds(250));
var request = new HandleTraceSpanRequest();
request.Instances.Add(Common.GetStandardInstanceMsg());
var writer = new GrpcWriter(port);
await writer.Write(request).ConfigureAwait(false);
Common.AssertIsTrueEventually(() => sentItems.Count == 2);
// ASSERT
Assert.AreEqual("source-1", (sentItems.Skip(0).First() as DependencyTelemetry).Context.Cloud.RoleInstance);
Assert.AreEqual("destination-1", (sentItems.Skip(1).First() as RequestTelemetry).Context.Cloud.RoleInstance);
}