Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }