@@ -36,6 +36,8 @@ public class CloudServersTests
3636 private static SimpleServerImage _initImage ;
3737 private static Flavor _initFlavor ;
3838 private const string NewPassword = "my_new_password" ;
39+ private static CloudNetwork _testNetwork ;
40+ private static VirtualInterface _virtualInterface ;
3941
4042 /// <summary>
4143 ///Gets or sets the test context which provides
@@ -64,6 +66,10 @@ public static void Init(TestContext context)
6466
6567 _initImage = provider . ListImages ( imageName : "CentOS 6.3" ) . First ( ) ;
6668 _initFlavor = provider . ListFlavors ( ) . OrderBy ( f => f . Id ) . First ( ) ;
69+
70+ var netProvider = new CloudNetworksProvider ( _testIdentity ) ;
71+ var networks = netProvider . ListNetworks ( ) ;
72+ _testNetwork = networks . FirstOrDefault ( n => ! n . Label . Equals ( "public" ) && ! n . Label . Equals ( "private" ) ) ;
6773 }
6874
6975 [ Timeout ( 1800000 ) , TestMethod ]
@@ -928,8 +934,84 @@ public void Should_NOT_Contain_Attached_Volume_In_Server_Volume_List()
928934
929935 #endregion
930936
931- #region Cleanup
937+ #region Virtual Interfaces
932938
939+ [ TestMethod ]
940+ public void Should_Get_List_Of_Virtual_Interfaces ( )
941+ {
942+ var interfaces = _testServer . ListVirtualInterfaces ( ) ;
943+
944+ Assert . IsNotNull ( interfaces ) ;
945+ Assert . IsTrue ( interfaces . Any ( ) ) ;
946+ }
947+
948+ [ TestMethod ]
949+ public void Should_Creat_Virtual_Interface_For_Test_Network ( )
950+ {
951+ Assert . IsNotNull ( _testNetwork , "Cannot run test because no test network was found" ) ;
952+
953+ var virtualInterface = _testServer . CreateVirtualInterface ( _testNetwork . Id ) ;
954+
955+ Assert . IsNotNull ( virtualInterface ) ;
956+ }
957+
958+ [ TestMethod ]
959+ public void Should_Get_List_Of_Virtual_Interfaces_Including_New_Virtual_Interface ( )
960+ {
961+ Assert . IsNotNull ( _testNetwork , "Cannot run test because no test network was found" ) ;
962+
963+ int count = 0 ;
964+ _virtualInterface = null ;
965+
966+ while ( _virtualInterface == null && count < 120 )
967+ {
968+ var virtualInterfaces = _testServer . ListVirtualInterfaces ( ) ;
969+ _virtualInterface = virtualInterfaces . FirstOrDefault ( vi => vi . Addresses . Any ( a => a . NetworkLabel . Equals ( _testNetwork . Label ) ) ) ;
970+
971+ if ( _virtualInterface == null )
972+ Thread . Sleep ( 5000 ) ;
973+
974+ count = count + 1 ;
975+ }
976+
977+ Assert . IsNotNull ( _virtualInterface ) ;
978+ }
979+
980+ [ TestMethod ]
981+ public void Should_Delete_New_Virtual_Interface_For_Test_Network ( )
982+ {
983+ Assert . IsNotNull ( _virtualInterface , "Cannot run test because no test network was found" ) ;
984+
985+ var virtualInterface = _testServer . DeleteVirtualInterface ( _virtualInterface . Id ) ;
986+
987+ Assert . IsNotNull ( virtualInterface ) ;
988+ }
989+
990+ [ TestMethod ]
991+ public void Should_Get_List_Of_Virtual_Interfaces_Without_New_Virtual_Interface ( )
992+ {
993+ Assert . IsNotNull ( _testNetwork , "Cannot run test because no test network was found" ) ;
994+
995+ int count = 0 ;
996+
997+ while ( _virtualInterface != null && count < 120 )
998+ {
999+ var virtualInterfaces = _testServer . ListVirtualInterfaces ( ) ;
1000+ _virtualInterface = virtualInterfaces . FirstOrDefault ( vi => vi . Addresses . Any ( a => a . NetworkLabel . Equals ( _testNetwork . Label ) ) ) ;
1001+
1002+ if ( _virtualInterface != null )
1003+ Thread . Sleep ( 5000 ) ;
1004+
1005+ count = count + 1 ;
1006+ }
1007+
1008+ Assert . IsNull ( _virtualInterface ) ;
1009+ }
1010+
1011+ #endregion
1012+
1013+ #region Cleanup
1014+
9331015 [ TestMethod ]
9341016 public void Should_Mark_The_Server_For_Deletion ( )
9351017 {
0 commit comments