Skip to content

Commit

Permalink
[Internal] Client Telemetry: Adds Client Telemetry pipeline sending d…
Browse files Browse the repository at this point in the history
…ata to service (#3900)

* first draft

* comment other pipelines

* pint variables

* commnet other pipelines

* added env variable

* minor changes

* update env variable

* print env variable

* add space in end

* fix test

* fix tests

* fix test

* fix tests

* remove response interceptor

* logs

* debuug mode

* 3failing test to print llgs

* minor refactoring

* 2nd windows-2019

* fix ct tests

* 2remove debugging

* fix tests

* revert

* ncomment pipelines

* fix test

* minor changes

* release and emulator pipeline

* update pipelines

* ignore abstract class test

* fixing pipeline

* refactor code

* change it to class name to run tests

* added emulator setup

* 1 temp commit

* env variable

* renames env variable

* fix tests

* add condition

* fix tests

* reorder env variable

* revert pipeline

* did some clean up

* change to revert

* Revert "change to revert"

This reverts commit 03db3c104505dc7b8f3cea267835c92ca530f8f4.

* fix typos

* throw if exception intercepter is null

* remove modelling changes

* removed virtaul

* Update Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/HttpHandlerHelper.cs

Co-authored-by: Matias Quaranta <[email protected]>

* added condition for pipelines

* Revert "added condition for pipelines"

This reverts commit f9a208cd28e01badee97a2eb770a486cea67c1f0.

* changed cond

* fix codn

* more enhancement

* testing for release pipeline

* refactore code and using test category

* added comments on test

* refactor pipeline code

* fix variables

* fix pipeline

---------

Co-authored-by: Matias Quaranta <[email protected]>
  • Loading branch information
sourabh1007 and ealsur authored Aug 22, 2023
1 parent ce38cc1 commit 2257ca2
Show file tree
Hide file tree
Showing 6 changed files with 1,360 additions and 1,028 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------

namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Fluent;
using Microsoft.Azure.Cosmos.Telemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/// <summary>
/// In Release pipeline, no need to mock Client Telemetry Service Call and Test will talk to the real database account.
/// If you are making changes in this file please make sure you are adding similar test in <see cref="ClientTelemetryTests"/> also.
/// </summary>
[TestClass]
[TestCategory("ClientTelemetryRelease")]
public class ClientTelemetryReleaseTests : ClientTelemetryTestsBase
{
public override CosmosClientBuilder GetBuilder()
{
string connectionString = ConfigurationManager.GetEnvironmentVariable<string>("COSMOSDB_ACCOUNT_CONNECTION_STRING", null);
return new CosmosClientBuilder(connectionString: connectionString);
}

/// <summary>
/// Returing null means do not return any hard codd response for any HTTP call.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public override Task<HttpResponseMessage> HttpHandlerRequestCallbackChecks(HttpRequestMessage request)
{
return null;
}

[ClassInitialize]
public static new void ClassInitialize(TestContext context)
{
ClientTelemetryTestsBase.ClassInitialize(context);

// It will go away in next PR
Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEnabled, "true");
Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetrySchedulingInSeconds, "1");
Environment.SetEnvironmentVariable(ClientTelemetryOptions.EnvPropsClientTelemetryEndpoint, "https://tools.cosmos.azure.com/api/clienttelemetry/trace");
}

[ClassCleanup]
public static new void FinalCleanup()
{
ClientTelemetryTestsBase.FinalCleanup();
}

[TestInitialize]
public override void TestInitialize()
{
base.TestInitialize();
}

[TestCleanup]
public override async Task Cleanup()
{
await base.Cleanup();
}

[TestMethod]
[DataRow(ConnectionMode.Direct, true)]
[DataRow(ConnectionMode.Gateway, true)]
[DataRow(ConnectionMode.Direct, false)]
[DataRow(ConnectionMode.Gateway, false)]
public override async Task PointSuccessOperationsTest(ConnectionMode mode, bool isAzureInstance)
{
await base.PointSuccessOperationsTest(mode, isAzureInstance);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task PointReadFailureOperationsTest(ConnectionMode mode)
{
await base.PointReadFailureOperationsTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task StreamReadFailureOperationsTest(ConnectionMode mode)
{
await base.StreamReadFailureOperationsTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task StreamOperationsTest(ConnectionMode mode)
{
await base.StreamOperationsTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task BatchOperationsTest(ConnectionMode mode)
{
await base.BatchOperationsTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task SingleOperationMultipleTimesTest(ConnectionMode mode)
{
await base.SingleOperationMultipleTimesTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task QueryOperationSinglePartitionTest(ConnectionMode mode)
{
await base.QueryOperationSinglePartitionTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task QueryMultiPageSinglePartitionOperationTest(ConnectionMode mode)
{
await base.QueryMultiPageSinglePartitionOperationTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task QueryOperationCrossPartitionTest(ConnectionMode mode)
{
await base.QueryOperationCrossPartitionTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task QueryOperationMutiplePageCrossPartitionTest(ConnectionMode mode)
{
await base.QueryOperationMutiplePageCrossPartitionTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
[DataRow(ConnectionMode.Gateway)]
public override async Task QueryOperationInvalidContinuationTokenTest(ConnectionMode mode)
{
await base.QueryOperationInvalidContinuationTokenTest(mode);
}

[TestMethod]
[DataRow(ConnectionMode.Direct)]
public override async Task CreateItemWithSubStatusCodeTest(ConnectionMode mode)
{
await base.CreateItemWithSubStatusCodeTest(mode);
}
}
}
Loading

0 comments on commit 2257ca2

Please sign in to comment.