-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
ComputeFleetCRUDTests.cs
102 lines (83 loc) · 4.62 KB
/
ComputeFleetCRUDTests.cs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Linq;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using NUnit.Framework;
namespace Azure.ResourceManager.ComputeFleet.Tests
{
internal class ComputeFleetCRUDTests : ComputeFleetTestBase
{
public ComputeFleetCRUDTests(bool isAsync)
: base(isAsync)
{
}
// To enable record - set AZURE_TEST_MODE=Record to record the test.
[TestCase]
[RecordedTest]
public async Task TestCreateComputeFleet()
{
var computeFleetCollection = await GetComputeFleetCollectionAsync();
var vnet = await CreateVirtualNetwork();
var computeFleetName = Recording.GenerateAssetName("testFleetViaSDK-");
var computeFleetData = GetBasicComputeFleetData(DefaultLocation, computeFleetName, GetSubnetId(vnet));
// Create the compute fleet
var createFleetResult = await computeFleetCollection.CreateOrUpdateAsync(WaitUntil.Completed, computeFleetName, computeFleetData);
Assert.AreEqual(computeFleetName, createFleetResult.Value.Data.Name);
Assert.AreEqual(DefaultLocation, createFleetResult.Value.Data.Location);
// Get the compute fleet
var getComputeFleet = await computeFleetCollection.GetAsync(computeFleetName);
Assert.AreEqual(computeFleetName, getComputeFleet.Value.Data.Name);
// Check if Fleet exists.
var isExists = await computeFleetCollection.ExistsAsync(computeFleetName);
Assert.IsTrue(isExists);
// Delete the compute fleet
await createFleetResult.Value.DeleteAsync(WaitUntil.Completed);
// Check if Fleet does not exists.
isExists = await computeFleetCollection.ExistsAsync(computeFleetName);
Assert.IsFalse(isExists);
}
[TestCase]
[RecordedTest]
public async Task TestCreateMultipleComputeFleetsAndCheck()
{
Console.WriteLine("Stating Test TestCreateMultipleComputeFleetsAndCheck");
var computeFleetCollection = await GetComputeFleetCollectionAsync();
var vnet = await CreateVirtualNetwork();
var computeFleetName = Recording.GenerateAssetName("testFleetViaSDK-");
var computeFleetData = GetBasicComputeFleetData(DefaultLocation, computeFleetName, GetSubnetId(vnet));
// Create the compute fleet
var createFleetResult = await computeFleetCollection.CreateOrUpdateAsync(WaitUntil.Completed, computeFleetName, computeFleetData);
Assert.AreEqual(computeFleetName, createFleetResult.Value.Data.Name);
Assert.AreEqual(DefaultLocation, createFleetResult.Value.Data.Location);
// Get the compute fleet
var getComputeFleet = await computeFleetCollection.GetAsync(computeFleetName);
Assert.AreEqual(computeFleetName, getComputeFleet.Value.Data.Name);
// Check if Fleet exists.
var isExists = await computeFleetCollection.ExistsAsync(computeFleetName);
Assert.IsTrue(isExists);
// Create 2nd Fleet
var computeFleetName2nd = Recording.GenerateAssetName("testFleetViaSDK-", "multi");
var computeFleetData2nd = GetBasicComputeFleetData(DefaultLocation, computeFleetName2nd, GetSubnetId(vnet));
var createFleetResult2nd = await computeFleetCollection.CreateOrUpdateAsync(WaitUntil.Completed, computeFleetName2nd, computeFleetData2nd);
Assert.AreEqual(computeFleetName2nd, createFleetResult2nd.Value.Data.Name);
Assert.AreEqual(DefaultLocation, createFleetResult2nd.Value.Data.Location);
// Check if 2nd Fleet exists.
isExists = await computeFleetCollection.ExistsAsync(computeFleetName2nd);
Assert.IsTrue(isExists);
var fleet2nd = await computeFleetCollection.GetIfExistsAsync(computeFleetName2nd);
Assert.NotNull(fleet2nd);
// Delete the 1st compute fleet
await createFleetResult.Value.DeleteAsync(WaitUntil.Completed);
// Check if 1st Fleet does not exists.
isExists = await computeFleetCollection.ExistsAsync(computeFleetName);
Assert.IsFalse(isExists);
// Delete the 2nd compute fleet
await createFleetResult2nd.Value.DeleteAsync(WaitUntil.Completed);
// Check if 2nd Fleet does not exists.
isExists = await computeFleetCollection.ExistsAsync(computeFleetName2nd);
Assert.IsFalse(isExists);
}
}
}