Skip to content

Commit

Permalink
[synapse] Reenable AccessControlClientLiveTests as LiveOnly. Mark oth…
Browse files Browse the repository at this point in the history
…ers as RecordedTest (#18499)

- Give up on making AccessControlClientLiveTests record-able and mark as LiveOnly
- [RecordedTest] seems to be a flatly better [Test] for all RecordedTestBase derived tests, so use it
  • Loading branch information
chamons authored Feb 9, 2021
1 parent e3a7aab commit eb0ba42
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 2,059 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Azure.Analytics.Synapse.AccessControl.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/18080 - roleAssignmentId can not be reused in recording due to reuse 409.")]
[LiveOnly] // Assignment IDs can not be reused for at least 30 days.
public class AccessControlClientLiveTests : RecordedTestBase<SynapseTestEnvironment>
{
internal class DisposableClientRole : IAsyncDisposable
Expand All @@ -34,27 +34,16 @@ private DisposableClientRole (RoleAssignmentsClient assignmentsClient, RoleDefin
Assignment = assignment;
}

public static async ValueTask<DisposableClientRole> Create (RoleAssignmentsClient assignmentsClient, RoleDefinitionsClient definitionsClient, TestRecording recording) =>
new DisposableClientRole (assignmentsClient, definitionsClient, await CreateResource (assignmentsClient, definitionsClient, recording));
public static async ValueTask<DisposableClientRole> Create (RoleAssignmentsClient assignmentsClient, RoleDefinitionsClient definitionsClient) =>
new DisposableClientRole (assignmentsClient, definitionsClient, await CreateResource (assignmentsClient, definitionsClient));

public static async ValueTask<RoleAssignmentDetails> CreateResource (RoleAssignmentsClient assignmentsClient, RoleDefinitionsClient definitionsClient, TestRecording recording)
public static async ValueTask<RoleAssignmentDetails> CreateResource (RoleAssignmentsClient assignmentsClient, RoleDefinitionsClient definitionsClient)
{
string scope = "workspaces/workspacechhamosynapse";

Guid? roleID = (await definitionsClient.ListRoleDefinitionsAsync()).Value.First (x => x.Name == "Synapse Administrator").Id;
Guid principalId = recording.Random.NewGuid();

string roleAssignmentId;
// Assignment IDs can not be reused for at least 30 days, so only respect recording's copy in playback
if (recording.Mode == RecordedTestMode.Playback)
{
roleAssignmentId = recording.Random.NewGuid().ToString();
}
else
{
roleAssignmentId = Guid.NewGuid().ToString();
}

Guid principalId = Guid.NewGuid();
string roleAssignmentId = Guid.NewGuid().ToString();
return await assignmentsClient.CreateRoleAssignmentAsync(roleAssignmentId, roleID.Value, principalId, scope);
}

Expand Down Expand Up @@ -92,7 +81,7 @@ public async Task CreateRoleAssignment()
RoleAssignmentsClient assignmentsClient = CreateAssignmentClient();
RoleDefinitionsClient definitionsClient = CreateDefinitionsClient();

await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient, this.Recording);
await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient);

Assert.NotNull(role.Assignment.Id);
Assert.NotNull(role.Assignment.RoleDefinitionId);
Expand All @@ -105,7 +94,7 @@ public async Task GetRoleAssignment()
RoleAssignmentsClient assignmentsClient = CreateAssignmentClient();
RoleDefinitionsClient definitionsClient = CreateDefinitionsClient();

await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient, this.Recording);
await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient);

RoleAssignmentDetails roleAssignment = await assignmentsClient.GetRoleAssignmentByIdAsync(role.Assignment.Id);

Expand All @@ -119,7 +108,7 @@ public async Task ListRoleAssignments()
RoleAssignmentsClient assignmentsClient = CreateAssignmentClient();
RoleDefinitionsClient definitionsClient = CreateDefinitionsClient();

await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient, this.Recording);
await using DisposableClientRole role = await DisposableClientRole.Create (assignmentsClient, definitionsClient);

Response<IReadOnlyList<SynapseRoleDefinition>> roleAssignments = await definitionsClient.ListRoleDefinitionsAsync();
foreach (SynapseRoleDefinition expected in roleAssignments.Value)
Expand All @@ -137,7 +126,7 @@ public async Task DeleteRoleAssignments()
RoleAssignmentsClient assignmentsClient = CreateAssignmentClient();
RoleDefinitionsClient definitionsClient = CreateDefinitionsClient();

RoleAssignmentDetails assignment = await DisposableClientRole.CreateResource (assignmentsClient, definitionsClient, this.Recording);
RoleAssignmentDetails assignment = await DisposableClientRole.CreateResource (assignmentsClient, definitionsClient);

Response response = await assignmentsClient.DeleteRoleAssignmentByIdAsync (assignment.Id);
response.AssertSuccess();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private BigDataPoolsClient CreateClient()
}

[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/18080 - This test case cannot be automated due to the inability to configure infrastructure to test against.")]
[Test]
[RecordedTest]
public async Task ListPools()
{
BigDataPoolsClient client = CreateClient();
Expand All @@ -44,7 +44,7 @@ public async Task ListPools()
}

[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/18080 - This test case cannot be automated due to the inability to configure infrastructure to test against.")]
[Test]
[RecordedTest]
public async Task GetPool()
{
const string PoolName = "sparkchhamosyna";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private DataFlowClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task GetDataFlows()
{
DataFlowClient client = CreateClient();
Expand All @@ -43,7 +43,7 @@ public async Task GetDataFlows()
Assert.GreaterOrEqual((await dataFlows.ToListAsync()).Count, 1);
}

[Test]
[RecordedTest]
public async Task GetDataFlow()
{
DataFlowClient client = CreateClient();
Expand All @@ -53,7 +53,7 @@ public async Task GetDataFlow()
Assert.AreEqual (flow.Name, dataFlow.Name);
}

[Test]
[RecordedTest]
public async Task RenameDataFlow()
{
DataFlowClient client = CreateClient();
Expand All @@ -72,7 +72,7 @@ public async Task RenameDataFlow()
await operation.WaitForCompletionAsync();
}

[Test]
[RecordedTest]
public async Task DeleteDataFlow()
{
DataFlowClient client = CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private DataFlowDebugSessionClient CreateDebugClient()
}

[Ignore ("https://github.com/Azure/azure-sdk-for-net/issues/18079 prevents test from working")]
[Test]
[RecordedTest]
public async Task AddDataFlow()
{
DataFlowClient flowClient = CreateFlowClient();
Expand All @@ -90,7 +90,7 @@ public async Task AddDataFlow()
Assert.NotNull (response.JobVersion);
}

[Test]
[RecordedTest]
public async Task QuerySessions()
{
DataFlowClient flowClient = CreateFlowClient();
Expand All @@ -104,7 +104,7 @@ public async Task QuerySessions()
}

[Ignore ("https://github.com/Azure/azure-sdk-for-net/issues/18079 prevents test from working")]
[Test]
[RecordedTest]
public async Task ExecuteCommand()
{
DataFlowClient flowClient = CreateFlowClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private DatasetClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task TestGetDataset()
{
DatasetClient client = CreateClient();
Expand All @@ -46,7 +46,7 @@ public async Task TestGetDataset()
}
}

[Test]
[RecordedTest]
public async Task TestCreateDataset()
{
DatasetClient client = CreateClient();
Expand All @@ -57,7 +57,7 @@ public async Task TestCreateDataset()
Assert.AreEqual(datasetName, dataset.Name);
}

[Test]
[RecordedTest]
public async Task TestDeleteDataset()
{
DatasetClient client = CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private IntegrationRuntimesClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task TestGet()
{
IntegrationRuntimesClient client = CreateClient();
Expand All @@ -48,7 +48,7 @@ public async Task TestGet()
}
}

[Test]
[RecordedTest]
public async Task TestList()
{
IntegrationRuntimesClient client = CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private LinkedServiceClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task TestGetLinkedService()
{
LinkedServiceClient client = CreateClient();
Expand All @@ -83,7 +83,7 @@ public async Task TestGetLinkedService()
}
}

[Test]
[RecordedTest]
public async Task TestDeleteLinkedService()
{
LinkedServiceClient client = CreateClient();
Expand All @@ -94,7 +94,7 @@ public async Task TestDeleteLinkedService()
await operation.WaitAndAssertSuccessfulCompletion();
}

[Test]
[RecordedTest]
public async Task TestRenameLinkedService()
{
LinkedServiceClient client = CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private NotebookClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task TestGetNotebook()
{
NotebookClient client = CreateClient ();
Expand All @@ -89,7 +89,7 @@ public async Task TestGetNotebook()
}
}

[Test]
[RecordedTest]
public async Task TestDeleteNotebook()
{
NotebookClient client = CreateClient();
Expand All @@ -100,7 +100,7 @@ public async Task TestDeleteNotebook()
await operation.WaitAndAssertSuccessfulCompletion();
}

[Test]
[RecordedTest]
public async Task TestRenameLinkedService()
{
NotebookClient client = CreateClient();
Expand All @@ -120,7 +120,7 @@ public async Task TestRenameLinkedService()
}

[Ignore ("https://github.com/Azure/azure-sdk-for-net/issues/18080 - Notebook summary appears to require Synapse.Spark execution first")]
[Test]
[RecordedTest]
public async Task TestGetSummary()
{
NotebookClient client = CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private PipelineClient CreateClient()
));
}

[Test]
[RecordedTest]
public async Task TestGetPipeline()
{
PipelineClient client = CreateClient ();
Expand All @@ -51,7 +51,7 @@ public async Task TestGetPipeline()
}
}

[Test]
[RecordedTest]
public async Task TestDeleteNotebook()
{
PipelineClient client = CreateClient();
Expand All @@ -62,7 +62,7 @@ public async Task TestDeleteNotebook()
await operation.WaitAndAssertSuccessfulCompletion();
}

[Test]
[RecordedTest]
public async Task TestRenameLinkedService()
{
PipelineClient client = CreateClient();
Expand All @@ -81,7 +81,7 @@ public async Task TestRenameLinkedService()
await operation.WaitForCompletionAsync();
}

[Test]
[RecordedTest]
public async Task TestPipelineRun()
{
PipelineClient client = CreateClient();
Expand Down
Loading

0 comments on commit eb0ba42

Please sign in to comment.