Skip to content

Commit 1aebd9c

Browse files
lenalaanuchandy
authored andcommitted
Fixing network watcher tests (#1892)
1 parent 0b2ced9 commit 1aebd9c

File tree

4 files changed

+1253
-1094
lines changed

4 files changed

+1253
-1094
lines changed

azure/src/test/java/com/microsoft/azure/management/AzureTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ public void testNetworkWatcherFunctions() throws Exception {
584584
.withRemotePort("443")
585585
.execute();
586586
Assert.assertEquals(Access.ALLOW, verificationIPFlow.access());
587-
Assert.assertEquals("defaultSecurityRules/AllowInternetOutBound", verificationIPFlow.ruleName());
587+
Assert.assertEquals("DefaultRule_AllowInternetOutBound", verificationIPFlow.ruleName());
588588

589589
// test packet capture
590590
List<PacketCapture> packetCaptures = nw.packetCaptures().list();

azure/src/test/java/com/microsoft/azure/management/TestNetworkWatcher.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ private void initializeResourceNames() {
4141
public NetworkWatcher createResource(NetworkWatchers networkWatchers) throws Exception {
4242
// Network Watcher should be in the same region as monitored resources
4343
initializeResourceNames();
44+
45+
// make sure Network Watcher is disabled in current subscription and region as only one can exist
46+
List<NetworkWatcher> nwList = networkWatchers.list();
47+
for (NetworkWatcher nw : nwList) {
48+
if (REGION.equals(nw.region())) {
49+
networkWatchers.deleteById(nw.id());
50+
}
51+
}
52+
// create Network Watcher
4453
NetworkWatcher nw = networkWatchers.define(nwName)
4554
.withRegion(REGION)
4655
.withNewResourceGroup()

0 commit comments

Comments
 (0)