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 TestListServers()
        {
            IComputeProvider           provider = Bootstrapper.CreateComputeProvider();
            IEnumerable <SimpleServer> servers  = UserComputeTests.ListAllServers(provider);

            Assert.IsNotNull(servers);
            if (!servers.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured servers.");
            }

            Console.WriteLine("Servers");
            foreach (SimpleServer server in servers)
            {
                Assert.IsNotNull(server);

                Console.WriteLine("    {0}: {1}", server.Id, server.Name);

                Assert.IsFalse(string.IsNullOrEmpty(server.Id));
                Assert.IsFalse(string.IsNullOrEmpty(server.Name));
            }
        }
Пример #4
0
        public void TestListServersWithDetails()
        {
            IComputeProvider     provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable <Server> servers  = UserComputeTests.ListAllServersWithDetails(provider);

            Assert.IsNotNull(servers);
            if (!servers.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured servers.");
            }

            Console.WriteLine("Servers (with details)");
            foreach (Server server in servers)
            {
                Assert.IsNotNull(server);

                Console.WriteLine("    {0}: {1}", server.Id, server.Name);
                Console.WriteLine(JsonConvert.SerializeObject(server, Formatting.Indented));

                Assert.IsFalse(string.IsNullOrEmpty(server.Id));
                Assert.IsFalse(string.IsNullOrEmpty(server.Name));
            }
        }
        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);
        }
        public void TestGetDetails()
        {
            IComputeProvider     provider = Bootstrapper.CreateComputeProvider();
            IEnumerable <Server> servers  = UserComputeTests.ListAllServersWithDetails(provider);

            Assert.IsNotNull(servers);
            if (!servers.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured servers.");
            }

            foreach (Server server in servers)
            {
                Assert.IsNotNull(server);
                Server details = provider.GetDetails(server.Id);
                Assert.AreEqual(server.AccessIPv4, details.AccessIPv4);
                Assert.AreEqual(server.AccessIPv6, details.AccessIPv6);
                //Assert.AreEqual(server.Addresses, details.Addresses);
                Assert.AreEqual(server.Created, details.Created);
                Assert.AreEqual(server.DiskConfig, details.DiskConfig);
                Assert.AreEqual(server.Flavor.Id, details.Flavor.Id);
                Assert.AreEqual(server.HostId, details.HostId);
                Assert.AreEqual(server.Id, details.Id);
                Assert.AreEqual(server.Image.Id, details.Image.Id);
                //Assert.AreEqual(server.Links, details.Links);
                Assert.AreEqual(server.Name, details.Name);
                Assert.AreEqual(server.PowerState, details.PowerState);
                //Assert.AreEqual(server.Progress, details.Progress);
                //Assert.AreEqual(server.Status, details.Status);
                //Assert.AreEqual(server.TaskState, details.TaskState);
                Assert.AreEqual(server.TenantId, details.TenantId);
                Assert.AreEqual(server.Updated, details.Updated);
                Assert.AreEqual(server.UserId, details.UserId);
                //Assert.AreEqual(server.VMState, details.VMState);
            }
        }