|
1 | 1 | using Microsoft.Azure.Commands.NetAppFiles.VolumeGroup;
|
| 2 | +using Microsoft.Azure.Management.NetApp.Models; |
2 | 3 | using System;
|
| 4 | +using System.Collections; |
3 | 5 | using System.Collections.Generic;
|
| 6 | +using System.Runtime.ConstrainedExecution; |
4 | 7 | using System.Text;
|
5 | 8 | using Xunit;
|
6 | 9 | //using Microsoft.Azure.Commands.NetAppFiles.VolumeGroup;
|
@@ -89,44 +92,174 @@ public void LogThroughputCalculation5120ShouldReturn500()
|
89 | 92 | Assert.Equal(expectedThroughput, throughput);
|
90 | 93 | }
|
91 | 94 |
|
92 |
| - [Fact] |
93 |
| - public void DataVolumeNameScaleup() |
| 95 | + [Theory] |
| 96 | + [InlineData("SH1", "SH1", 2, "data", "SH1-data-mnt00002")] |
| 97 | + [InlineData("SH1", "", 1, "data", "SH1-data-mnt00001")] |
| 98 | + [InlineData("SH1", null, 1, "data", "SH1-data-mnt00001")] |
| 99 | + [InlineData("SH1", "SH1", 2, "shared", "SH1-shared")] |
| 100 | + [InlineData("SH1", "SH1", 2, "log", "SH1-log-mnt00002")] |
| 101 | + public void DataVolumeNameScaleup(string applicationId, string systemId, int numberOfHost, string volumeType, string expectedVolumeName) |
94 | 102 | {
|
95 |
| - string expectedVolumeName = "SH1-data-mnt00001"; |
96 |
| - var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
| 103 | + //string expectedVolumeName = "SH1-data-mnt00001"; |
| 104 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(applicationId, systemId, volumeType, numberOfHost, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
97 | 105 | Assert.Equal(expectedVolumeName, volumeName);
|
98 | 106 | }
|
99 | 107 |
|
100 | 108 | [Fact]
|
101 | 109 | public void DataVolumeNameScaleoutHost1()
|
102 | 110 | {
|
103 | 111 | string expectedVolumeName = "SH1-data-mnt00001";
|
104 |
| - var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
| 112 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapApplicationId, NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
105 | 113 | Assert.Equal(expectedVolumeName, volumeName);
|
106 | 114 | }
|
107 | 115 |
|
108 | 116 | [Fact]
|
109 | 117 | public void DataVolumeNameScaleoutHost2()
|
110 | 118 | {
|
111 | 119 | string expectedVolumeName = "SH1-data-mnt00002";
|
112 |
| - var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, 2, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
| 120 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapApplicationId, NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, 2, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
113 | 121 | Assert.Equal(expectedVolumeName, volumeName);
|
114 | 122 | }
|
115 | 123 |
|
116 | 124 | [Fact]
|
117 | 125 | public void LogVolumeNameScaleup()
|
118 | 126 | {
|
119 | 127 | string expectedVolumeName = "SH1-log-mnt00001";
|
120 |
| - var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Log, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
| 128 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapApplicationId, NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Log, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
121 | 129 | Assert.Equal(expectedVolumeName, volumeName);
|
122 | 130 | }
|
123 | 131 |
|
124 | 132 | [Fact]
|
125 | 133 | public void SharedVolumeNameScaleup()
|
126 | 134 | {
|
127 | 135 | string expectedVolumeName = "SH1-shared";
|
128 |
| - var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Shared, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
| 136 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateVolumeName(NewAzureRmNetAppFilesVolumeGroup.DefaultSapApplicationId, NewAzureRmNetAppFilesVolumeGroup.DefaultSapSystemId, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Shared, 1, NewAzureRmNetAppFilesVolumeGroup.SystemRoles.PRIMARY, null); |
129 | 137 | Assert.Equal(expectedVolumeName, volumeName);
|
130 | 138 | }
|
| 139 | + |
| 140 | + [Theory] |
| 141 | + [InlineData(1024, 2, "data", 512)] |
| 142 | + [InlineData(10, 2, "data", 100)] |
| 143 | + [InlineData(10, 2, "log", 150)] |
| 144 | + [InlineData(1024, 2, "log", 150)] |
| 145 | + public void OracleDataThroughputCalculation(int throughPut, int numberOfVolumes, string volumeType, int expectedThroughput) |
| 146 | + { |
| 147 | + |
| 148 | + var throughput = NewAzureRmNetAppFilesVolumeGroup.CalculateOracleThroughput(throughPut, numberOfVolumes, volumeType); |
| 149 | + Assert.Equal(expectedThroughput, throughput); |
| 150 | + } |
| 151 | + |
| 152 | + |
| 153 | + [Theory] |
| 154 | + [InlineData(1024, 2, 20, 614)] |
| 155 | + [InlineData(24, 2, 20, 100)] |
| 156 | + public void OracleUsageThresholdCalculationData(int oraDataBaseSize, int numberOfVolumes, int snapshotCapacity, int expected) |
| 157 | + { |
| 158 | + long gibibyte = 1024L * 1024L * 1024L; |
| 159 | + long expectedthreshold = expected * gibibyte; |
| 160 | + var threshold = NewAzureRmNetAppFilesVolumeGroup.CalulateOracleUsageThreshold(oraDataBaseSize, numberOfVolumes, snapshotCapacity, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Data); |
| 161 | + Assert.Equal(expectedthreshold / gibibyte, threshold/gibibyte); |
| 162 | + } |
| 163 | + |
| 164 | + [Theory] |
| 165 | + [InlineData(1024, 2, 20, 100)] |
| 166 | + [InlineData(24, 2, 20, 100)] |
| 167 | + public void OracleUsageThresholdCalculationBinary(int oraDataBaseSize, int numberOfVolumes, int snapshotCapacity, int expected) |
| 168 | + { |
| 169 | + long gibibyte = 1024L * 1024L * 1024L; |
| 170 | + long expectedthreshold = expected * gibibyte; |
| 171 | + var threshold = NewAzureRmNetAppFilesVolumeGroup.CalulateOracleUsageThreshold(oraDataBaseSize, numberOfVolumes, snapshotCapacity, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Binary); |
| 172 | + Assert.Equal(expectedthreshold / gibibyte, threshold / gibibyte); |
| 173 | + } |
| 174 | + |
| 175 | + [Theory] |
| 176 | + [InlineData(1024, 2, 20, 512)] |
| 177 | + [InlineData(24, 2, 20, 100)] |
| 178 | + public void OracleUsageThresholdCalculationBackup(int oraDataBaseSize, int numberOfVolumes, int snapshotCapacity, int expected) |
| 179 | + { |
| 180 | + long gibibyte = 1024L * 1024L * 1024L; |
| 181 | + long expectedthreshold = expected * gibibyte; |
| 182 | + var threshold = NewAzureRmNetAppFilesVolumeGroup.CalulateOracleUsageThreshold(oraDataBaseSize, numberOfVolumes, snapshotCapacity, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Backup); |
| 183 | + Assert.Equal(expectedthreshold / gibibyte, threshold / gibibyte); |
| 184 | + } |
| 185 | + |
| 186 | + [Theory] |
| 187 | + [InlineData(150, 2, 100)] |
| 188 | + [InlineData(350, 2, 175)] |
| 189 | + public void OracleUsageThroughputCalculationData(int oracleThroughput, int numberOfVolumes, int expected) |
| 190 | + { |
| 191 | + var volumeThroughput = NewAzureRmNetAppFilesVolumeGroup.CalculateOracleThroughput(oracleThroughput, numberOfVolumes, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Data); |
| 192 | + Assert.Equal(expected, volumeThroughput); |
| 193 | + } |
| 194 | + |
| 195 | + [Theory] |
| 196 | + [InlineData(150, 2, 150)] |
| 197 | + [InlineData(350, 2, 150)] |
| 198 | + public void OracleUsageThroughputCalculationBackup(int oracleThroughput, int numberOfVolumes, int expected) |
| 199 | + { |
| 200 | + var volumeThroughput = NewAzureRmNetAppFilesVolumeGroup.CalculateOracleThroughput(oracleThroughput, numberOfVolumes, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Backup); |
| 201 | + Assert.Equal(expected, volumeThroughput); |
| 202 | + } |
| 203 | + |
| 204 | + [Theory] |
| 205 | + [InlineData(150, 2, 64)] |
| 206 | + [InlineData(350, 2, 64)] |
| 207 | + public void OracleUsageThroughputCalculationBinary(int oracleThroughput, int numberOfVolumes, int expected) |
| 208 | + { |
| 209 | + var volumeThroughput = NewAzureRmNetAppFilesVolumeGroup.CalculateOracleThroughput(oracleThroughput, numberOfVolumes, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Binary); |
| 210 | + Assert.Equal(expected, volumeThroughput); |
| 211 | + } |
| 212 | + |
| 213 | + [Theory] |
| 214 | + [InlineData("or1", "ora1", 2, "data", "PRIMARY", "ora1-ora-data2")] |
| 215 | + [InlineData("or1", "ora1", 2, "data", "HA", "HA-ora1-ora-data2")] |
| 216 | + [InlineData("or1", "ora1", 2, "data", null, "ora1-ora-data2")] |
| 217 | + [InlineData("or1", "", 1, "data", "", "or1-ora-data1")] |
| 218 | + [InlineData("or1", null, 1, "data","", "or1-ora-data1")] |
| 219 | + [InlineData("or1", "ora1", 2, "binary",null, "ora1-ora-binary")] |
| 220 | + [InlineData("or1", "ora1", 2, "log", null, "ora1-ora-log")] |
| 221 | + public void OracleGenerateVolumeName(string applicationId, string systemId, int numberOfVolume, string volumeType, string systemRole, string expected) |
| 222 | + { |
| 223 | + var volumeName = NewAzureRmNetAppFilesVolumeGroup.GenerateOracleVolumeName(applicationId, systemId, volumeType, numberOfVolume, systemRole); |
| 224 | + Assert.Equal(expected, volumeName); |
| 225 | + } |
| 226 | + |
| 227 | + [Theory] |
| 228 | + [ClassData(typeof(ReplicationObjectData))] |
| 229 | + public void GetReplicationObject(int volumeNumber, string volumeType, NewAzureRmNetAppFilesVolumeGroup cmdLet, ReplicationObject expectedReplicationObject) |
| 230 | + { |
| 231 | + //string expectedVolumeName = "SH1-data-mnt00001"; |
| 232 | + var replicationObject = cmdLet.GetReplicationObject(volumeNumber, volumeType); |
| 233 | + Assert.Equal(expectedReplicationObject.RemoteVolumeResourceId, replicationObject.RemoteVolumeResourceId); |
| 234 | + Assert.Equal(expectedReplicationObject.ReplicationSchedule, replicationObject.ReplicationSchedule); |
| 235 | + } |
| 236 | + } |
| 237 | + |
| 238 | + public class ReplicationObjectData : IEnumerable<object[]> |
| 239 | + { |
| 240 | + public IEnumerator<object[]> GetEnumerator() |
| 241 | + { |
| 242 | + yield return new object[] { |
| 243 | + 1, NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Data, new NewAzureRmNetAppFilesVolumeGroup(){ DataReplicationSourceId= "remote1", DataReplicationSchedule="_10minutely" },new ReplicationObject {RemoteVolumeResourceId="remote1",ReplicationSchedule="_10minutely"} |
| 244 | + }; |
| 245 | + yield return new object[] { |
| 246 | + 2, NewAzureRmNetAppFilesVolumeGroup.SapVolumeType.Data, new NewAzureRmNetAppFilesVolumeGroup(){ Data2ReplicationSourceId= "remote2", Data2ReplicationSchedule="hourly" },new ReplicationObject {RemoteVolumeResourceId="remote2",ReplicationSchedule="hourly"} |
| 247 | + }; |
| 248 | + yield return new object[] { |
| 249 | + 2,NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Data, new NewAzureRmNetAppFilesVolumeGroup(){ Data2ReplicationSourceId= "remote3", Data2ReplicationSchedule="daily" },new ReplicationObject {RemoteVolumeResourceId="remote3",ReplicationSchedule="daily"} |
| 250 | + }; |
| 251 | + yield return new object[] { |
| 252 | + 2,NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Log, new NewAzureRmNetAppFilesVolumeGroup(){ DataReplicationSourceId= "remote3", DataReplicationSchedule="_10minutely", LogReplicationSourceId= "remoteLog3", LogReplicationSchedule="daily" },new ReplicationObject {RemoteVolumeResourceId="remoteLog3",ReplicationSchedule="daily"} |
| 253 | + }; |
| 254 | + yield return new object[] { |
| 255 | + 2,NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Binary, new NewAzureRmNetAppFilesVolumeGroup(){ DataReplicationSourceId= "remote", DataReplicationSchedule="_10minutely", LogMirrorReplicationSourceId= "remoteLogMirror", LogMirrorReplicationSchedule="daily", BinaryReplicationSourceId= "remoteBinary", BinaryReplicationSchedule="daily" }, |
| 256 | + new ReplicationObject {RemoteVolumeResourceId="remoteBinary",ReplicationSchedule="daily"} |
| 257 | + }; |
| 258 | + yield return new object[] { |
| 259 | + 0,NewAzureRmNetAppFilesVolumeGroup.OracleVolumeType.Binary, new NewAzureRmNetAppFilesVolumeGroup(){ DataReplicationSourceId= "remote", DataReplicationSchedule="_10minutely", LogMirrorReplicationSourceId= "remoteLogMirror", LogMirrorReplicationSchedule="daily", BinaryReplicationSourceId= "remoteBinary", BinaryReplicationSchedule="daily" }, |
| 260 | + new ReplicationObject {RemoteVolumeResourceId="remoteBinary",ReplicationSchedule="daily"} |
| 261 | + }; |
| 262 | + } |
| 263 | + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); |
131 | 264 | }
|
132 | 265 | }
|
0 commit comments