-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathGitHubTelemetryForwardingE2ETests.cs
More file actions
66 lines (56 loc) · 2.39 KB
/
Copy pathGitHubTelemetryForwardingE2ETests.cs
File metadata and controls
66 lines (56 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using System.Collections.Concurrent;
using GitHub.Copilot.Rpc;
using GitHub.Copilot.Test.Harness;
using Xunit;
using Xunit.Abstractions;
namespace GitHub.Copilot.Test.E2E;
#pragma warning disable GHCP001 // GitHub telemetry forwarding is experimental.
// TODO(BYOK): Anthropic Messages produced no GitHub telemetry notification. Determine whether
// provider-backed sessions should forward the same telemetry before keeping this CAPI-only.
[Trait(E2ETestTraits.Backend, E2ETestTraits.CapiOnly)]
public class GitHubTelemetryForwardingE2ETests(E2ETestFixture fixture, ITestOutputHelper output)
: E2ETestBase(fixture, "github_telemetry", output)
{
[Fact]
public async Task Should_Forward_GitHub_Telemetry_For_A_Live_Session()
{
var notifications = new ConcurrentQueue<GitHubTelemetryNotification>();
await using var client = Ctx.CreateClient(options: new CopilotClientOptions
{
OnGitHubTelemetry = notification =>
{
notifications.Enqueue(notification);
return Task.CompletedTask;
},
});
CopilotSession? session = null;
try
{
session = await Ctx.CreateSessionAsync(client, new SessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
});
await TestHelper.WaitForConditionAsync(
() => !notifications.IsEmpty,
timeout: TimeSpan.FromSeconds(30),
timeoutMessage: "Timed out waiting for GitHub telemetry notification.");
Assert.True(notifications.TryPeek(out var notification));
Assert.False(string.IsNullOrEmpty(notification.SessionId));
Assert.NotNull(notification.Event);
Assert.NotEmpty(notification.Event.Kind);
Assert.IsType<bool>(notification.Restricted);
}
finally
{
if (session is not null)
{
await session.DisposeAsync();
}
await client.StopAsync();
}
}
}
#pragma warning restore GHCP001