public static void ClassInitialize(TestContext testContext) { IComputeProvider provider = Bootstrapper.CreateComputeProvider(); string serverName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName(); Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault(); if (flavor == null) Assert.Inconclusive("Couldn't find a flavor to use for the test server."); SimpleServerImage[] images = UserComputeTests.ListAllImages(provider).ToArray(); SimpleServerImage image = images.FirstOrDefault(i => i.Name.IndexOf(TestImageNameSubstring, StringComparison.OrdinalIgnoreCase) >= 0); if (image == null) Assert.Inconclusive(string.Format("Couldn't find the {0} image to use for the test server.", TestImageNameSubstring)); Stopwatch timer = Stopwatch.StartNew(); Console.Write("Creating server for image {0}...", image.Name); NewServer server = provider.CreateServer(serverName, image.Id, flavor.Id, attachToServiceNetwork: true); Assert.IsNotNull(server); Assert.IsFalse(string.IsNullOrEmpty(server.Id)); _password = server.AdminPassword; _server = provider.WaitForServerActive(server.Id); Assert.IsNotNull(_server); Assert.AreEqual(server.Id, _server.Id); Assert.AreEqual(ServerState.Active, _server.Status); Console.WriteLine("done. {0} seconds", timer.Elapsed.TotalSeconds); }
private async Task<CloudServersServerNode> CreateServerNodeAsync(CloudServersProvider provider, Server server, FlavorDetails[] flavors, ServerImage[] images) { FlavorDetails flavor = flavors.FirstOrDefault(i => server.Flavor != null && string.Equals(server.Flavor.Id, i.Id, StringComparison.OrdinalIgnoreCase)); try { if (flavor == null && server.Flavor != null) flavor = await Task.Run(() => provider.GetFlavor(server.Flavor.Id)); } catch (ResponseException) { // ignore flavor = null; } ServerImage image = images.FirstOrDefault(i => server.Image != null && string.Equals(server.Image.Id, i.Id, StringComparison.OrdinalIgnoreCase)); try { if (image == null && server.Image != null) image = await Task.Run(() => provider.GetImage(server.Image.Id)); } catch (ResponseException) { // ignore image = null; } return new CloudServersServerNode(provider, server, flavor, image); }
public CloudServersServerNode(CloudServersProvider provider, Server server, FlavorDetails flavor, ServerImage image) { if (provider == null) throw new ArgumentNullException("provider"); if (server == null) throw new ArgumentNullException("server"); this._provider = provider; this._server = server; this._flavor = flavor; this._image = image; }
public void Should_Get_Details_For_Newly_Created_Server_In_DFW() { _testServer = _newTestServer.GetDetails(); Assert.IsNotNull(_testServer); Assert.AreEqual("net-sdk-test-server", _testServer.Name); Assert.AreEqual(_initImage.Id, _testServer.Image.Id); Assert.AreEqual(_initFlavor.Id, _testServer.Flavor.Id); }
public void Should_Rebuild_Server() { _preBuildDetails = _testServer.GetDetails(); var provider = new CloudServersProvider(_testIdentity); var image = provider.ListImages().First(i => i.Name.Contains("CentOS") && i.Id != _preBuildDetails.Image.Id); var flavor = int.Parse(_preBuildDetails.Flavor.Id) + 1; _rebuildServerSuccess = _testServer.Rebuild(string.Format("{0}_REBUILD", _preBuildDetails.Name), image.Id, flavor.ToString(), _newTestServer.AdminPassword); Assert.IsTrue(_rebuildServerSuccess); }
public void TestRevertServerResize() { IComputeProvider provider = Bootstrapper.CreateComputeProvider(); string serverName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName(); Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault(i => !i.Id.Equals(_server.Flavor.Id, StringComparison.OrdinalIgnoreCase)); if (flavor == null) Assert.Inconclusive("Couldn't find a flavor to use for the test server."); bool resized = provider.ResizeServer(_server.Id, serverName, flavor.Id); Assert.IsTrue(resized); Server resizedServer = provider.WaitForServerState(_server.Id, ServerState.VerifyResize, new[] { ServerState.Active, ServerState.Error, ServerState.Unknown, ServerState.Suspended }); Assert.AreEqual(ServerState.VerifyResize, resizedServer.Status); _server = resizedServer; bool reverted = provider.RevertServerResize(resizedServer.Id); Assert.IsTrue(reverted); Server revertedServer = provider.WaitForServerActive(_server.Id); Assert.AreEqual(ServerState.Active, revertedServer.Status); _server = revertedServer; }
public void TestRebuildServer() { IComputeProvider provider = Bootstrapper.CreateComputeProvider(); Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault(); if (flavor == null) Assert.Inconclusive("Couldn't find a flavor to use for the test server."); SimpleServerImage[] images = UserComputeTests.ListAllImages(provider).ToArray(); SimpleServerImage image = images.FirstOrDefault(i => i.Name.IndexOf(TestImageNameSubstring, StringComparison.OrdinalIgnoreCase) >= 0); if (image == null) Assert.Inconclusive(string.Format("Couldn't find the {0} image to use for the test server.", TestImageNameSubstring)); Server rebuilt = provider.RebuildServer(_server.Id, null, image.Id, flavor.Id, _password); Assert.IsNotNull(rebuilt); Server rebuiltServer = provider.WaitForServerActive(rebuilt.Id); Assert.AreEqual(ServerState.Active, rebuiltServer.Status); _server = rebuiltServer; }
public void TestUpdateServer() { IComputeProvider provider = Bootstrapper.CreateComputeProvider(); string newName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName() + "²"; bool updated = provider.UpdateServer(_server.Id, name: newName); Assert.IsTrue(updated); Server updatedServer = provider.GetDetails(_server.Id); Assert.AreEqual(_server.Id, updatedServer.Id); Assert.AreEqual(newName, updatedServer.Name); Assert.AreNotEqual(_server.Name, updatedServer.Name); _server = updatedServer; }
public ServerProperties(CloudServersProvider provider, Server server, FlavorDetails flavor, ServerImage image) { if (provider == null) throw new ArgumentNullException("provider"); if (server == null) throw new ArgumentNullException("server"); _provider = provider; _server = server; _flavor = flavor; _image = image; }