Exemplo n.º 1
0
        public void AzureWebSites_AddConnectionStrings_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // Create Azure WebSite
                portal.WebSites.CreateWebSite(TestConstants.WebSiteName);
                Assert.IsTrue(portal.WebSites.WebSiteExists(TestConstants.WebSiteName));

                // When modifiying the site config, start by getting the existing config.
                // Otherwise, you might delete important settings, such as default documents.
                var config       = portal.WebSites.GetWebSiteConfig(TestConstants.WebSiteName);
                var updateParams = portal.WebSites.CreateWebSiteUpdateParameters(config);
                updateParams.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo {
                    Name             = "MyConnectionString",
                    ConnectionString = "Initial Catalog=test",
                    Type             = "SQLAzure",
                });

                // Add a new connection string
                portal.WebSites.UpdateWebSiteConfig(TestConstants.WebSiteName, updateParams);

                // verify the connection string was added
                config = portal.WebSites.GetWebSiteConfig(TestConstants.WebSiteName);
                Assert.AreEqual(1, config.ConnectionStrings.Count);
            }
        }
Exemplo n.º 2
0
        public void AzureCloudServices_CreateHostedService_ReuseExisting()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // first, create an affinity group in a different location
                portal.AffinityGroups.CreateAffinityGroup(new Microsoft.WindowsAzure.Management.Models.AffinityGroupCreateParameters
                    {
                        Name = "bvtAffinityGroupEast",
                        Location = "East US",
                    });

                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                    {
                        ServiceName = TestConstants.HostedServiceName,
                        AffinityGroup = "bvtAffinityGroupEast",
                    });

                // now "create" the duplicate, which will reuse the existing
                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                {
                    ServiceName = TestConstants.HostedServiceName,
                    AffinityGroup = "bvtAffinityGroupWest",
                });

                var service = portal.CloudServices.GetHostedService(TestConstants.HostedServiceName);

                Assert.AreEqual("bvtAffinityGroupEast", service.Properties.AffinityGroup, true);
            }
        }
Exemplo n.º 3
0
        public void AzureCloudServices_CreateHostedService_ReuseExisting()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // first, create an affinity group in a different location
                portal.AffinityGroups.CreateAffinityGroup(new Microsoft.WindowsAzure.Management.Models.AffinityGroupCreateParameters
                {
                    Name     = "bvtAffinityGroupEast",
                    Location = "East US",
                });

                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                {
                    ServiceName   = TestConstants.HostedServiceName,
                    AffinityGroup = "bvtAffinityGroupEast",
                });

                // now "create" the duplicate, which will reuse the existing
                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                {
                    ServiceName   = TestConstants.HostedServiceName,
                    AffinityGroup = "bvtAffinityGroupWest",
                });

                var service = portal.CloudServices.GetHostedService(TestConstants.HostedServiceName);

                Assert.AreEqual("bvtAffinityGroupEast", service.Properties.AffinityGroup, true);
            }
        }
Exemplo n.º 4
0
        public void AzureWebSites_E2E_FTP_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(DefaultSubscription))
            {
                // first check if this website exist by some reason from previous Bvt run
                if (portal.WebSites.WebSiteExists("mywebsite1112"))
                {
                    portal.WebSites.DeleteWebSite("mywebsite1112");
                }

                // Create Azure WebSite
                WebSite site = portal.WebSites.CreateWebSite("mywebsite1112");
                Assert.IsTrue(portal.WebSites.WebSiteExists("mywebsite1112"));

                // Deploy website content
                portal.WebSites.PublishWebSite(Path.GetFullPath("TestEasyWebSite"), "mywebsite1112", PublishMethod.Ftp, siteRootRelativePath: "musicstore");
                portal.WebSites.PublishDirectory(Path.GetFullPath("TestEasyWebSite"), "mywebsite1112", PublishMethod.Ftp, siteRootRelativePath: "packages");         // at .../site/wwwroot/packages
                portal.WebSites.PublishDirectory(Path.GetFullPath("TestEasyWebSite"), "mywebsite1112", PublishMethod.Ftp, siteRootRelativePath: "..\\packages");     // .../site/packages
                portal.WebSites.PublishDirectory(Path.GetFullPath("TestEasyWebSite"), "mywebsite1112", PublishMethod.Ftp, siteRootRelativePath: "..\\..\\packages"); // .../packages

                // Ping website
                Assert.IsTrue(TestEasyHelpers.Web.PingUrl(site.GetUrl() + "/musicstore/default.html"));
            }
        }
Exemplo n.º 5
0
        public void AzureCloudServices_SwapDeployment_StagingToProduction()
        {
            var packagePath = Path.GetFullPath("SamplePackage.cspkg");
            var configPath  = Path.GetFullPath("SampleServiceConfiguration.Cloud.cscfg");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var webRole = portal.CloudServices.DeployRole(packagePath, configPath, deploymentSlot: DeploymentSlot.Staging);

                // wait for webRole to populate
                portal.CloudServices.WaitForRoleToRespond(webRole, 5000 /* increase timeout here to 600000 in real tests */);

                var deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Staging);
                Assert.IsNotNull(deployment);

                portal.CloudServices.SwapDeployment(webRole.HostedService, new DeploymentSwapParameters
                {
                    SourceDeployment = webRole.Deployment.Name,
                });

                deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Production);
                Assert.IsNotNull(deployment);
                deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Staging);
                Assert.IsNull(deployment);
            }
        }
Exemplo n.º 6
0
        public void AzureSql_PublishDatabase_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(DefaultSubscription))
            {
                // create two databases from scratch (they are empty but for feature demonstration its ok)
                var databaseSource      = portal.Sql.CreateSqlDatabase("mytestdbxs");
                var server              = databaseSource.Server;
                var databaseDestination = portal.Sql.CreateSqlDatabase("mytestdbxd", server);

                // now use WebDeploy to publish source database to destination including data(!).
                // Note: that calling publish database can be called sequentially and next time would bring only
                // database updates.
                portal.Sql.PublishDatabase(
                    WebDeployDatabaseType.FullSql,
                    databaseSource.ConnectionString,
                    WebDeployDatabaseType.FullSql,
                    databaseDestination.ConnectionString,
                    includeData: true);

                // now remove database and server
                server.DropDatabase(databaseSource);
                server.DropDatabase(databaseDestination);
                portal.Sql.DeleteSqlServer(server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(server.Name));
            }
        }
Exemplo n.º 7
0
        public void AzureWebSites_AddConnectionStrings_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // Create Azure WebSite
                portal.WebSites.CreateWebSite(TestConstants.WebSiteName);
                Assert.IsTrue(portal.WebSites.WebSiteExists(TestConstants.WebSiteName));

                // When modifiying the site config, start by getting the existing config.
                // Otherwise, you might delete important settings, such as default documents.
                var config = portal.WebSites.GetWebSiteConfig(TestConstants.WebSiteName);
                var updateParams = portal.WebSites.CreateWebSiteUpdateParameters(config);
                updateParams.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo { 
                    Name = "MyConnectionString", 
                    ConnectionString = "Initial Catalog=test",
                    Type = "SQLAzure",
                });

                // Add a new connection string
                portal.WebSites.UpdateWebSiteConfig(TestConstants.WebSiteName, updateParams);

                // verify the connection string was added
                config = portal.WebSites.GetWebSiteConfig(TestConstants.WebSiteName);
                Assert.AreEqual(1, config.ConnectionStrings.Count);
            }
        }
Exemplo n.º 8
0
        public void AffinityGroups_EnsureAffinityGroupExists_CreatesNewGroup()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.EnsureAffinityGroupExists(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 9
0
        public void AffinityGroups_EnsureAffinityGroupExists_CreatesNewGroup()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.EnsureAffinityGroupExists(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 10
0
 public void Cleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.WebSites.WebSiteExists(TestConstants.WebSiteName))
         {
             portal.WebSites.DeleteWebSite(TestConstants.WebSiteName);
         }
     }
 }
Exemplo n.º 11
0
 public void AzureVirtualMachines_GetListOfAllAvailableOsImages_Test()
 {
     // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
     // the case of exception, which would ensure all resources cleaned up.
     using (var portal = new AzurePortal(DefaultSubscription))
     {
         var oses = portal.VirtualMachines.GetOsImages();
         Assert.IsTrue(oses.Any());
     }
 }
Exemplo n.º 12
0
 public void AzureVirtualMachines_GetListOfAllAvailableOsImages_Test()
 {
     // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
     // the case of exception, which would ensure all resources cleaned up.
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         var oses = portal.VirtualMachines.GetOsImages();
         Assert.IsTrue(oses.Any());
     }
 }
Exemplo n.º 13
0
 public void TestCleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.CloudServices.GetHostedService(TestConstants.HostedServiceName) != null)
         {
             portal.CloudServices.DeleteHostedService(TestConstants.HostedServiceName);
         }
     }
 }
Exemplo n.º 14
0
 public void Cleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.WebSites.WebSiteExists(TestConstants.WebSiteName))
         {
             portal.WebSites.DeleteWebSite(TestConstants.WebSiteName);
         }
     }
 }
Exemplo n.º 15
0
 public void TestCleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName) != null)
         {
             portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);
         }
     }
 }
Exemplo n.º 16
0
 public void TestCleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.CloudServices.GetHostedService(TestConstants.HostedServiceName) != null)
         {
             portal.CloudServices.DeleteHostedService(TestConstants.HostedServiceName);
         }
     }
 }
Exemplo n.º 17
0
 public void TestCleanup()
 {
     using (var portal = new AzurePortal(TestConstants.TestSubscription))
     {
         if (portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName) != null)
         {
             portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);
         }
     }
 }
Exemplo n.º 18
0
        public void AzureStorageServices_CleanupOnDisposal()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.Storage.CreateStorageService(TestConstants.StorageServiceName);
            }

            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var service = portal.Storage.GetStorageService(TestConstants.StorageServiceName);
                Assert.IsNull(service);
            }
        }
Exemplo n.º 19
0
        public void AffinityGroups_Create_Delete_E2E()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));

                portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 20
0
        public void AffinityGroups_Create_Delete_E2E()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));

                portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 21
0
        public void AzureStorageServices_CleanupOnDisposal()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.Storage.CreateStorageService(TestConstants.StorageServiceName);
            }

            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var service = portal.Storage.GetStorageService(TestConstants.StorageServiceName);
                Assert.IsNull(service);
            }

        }
Exemplo n.º 22
0
        public void AzureCloudServices_CleanupHostedServicesAfterTest()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.CloudServices.CreateHostedService(TestConstants.HostedServiceName);

                Assert.IsNotNull(portal.CloudServices.GetHostedService(TestConstants.HostedServiceName));
            }

            // verify hosted service was cleaned up
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                Assert.IsNull(portal.CloudServices.GetHostedService(TestConstants.HostedServiceName));
            }
        }
Exemplo n.º 23
0
        public void AffinityGroups_CleanedUpAfterTest()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }

            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // affinity group should have been cleaned up when previous Portal instance was disposed.
                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 24
0
        public void AffinityGroups_CleanedUpAfterTest()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }

            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // affinity group should have been cleaned up when previous Portal instance was disposed.
                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 25
0
        public void AzureWebSites_E2E_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // Create Azure WebSite
                var site = portal.WebSites.CreateWebSite(TestConstants.WebSiteName);
                Assert.IsTrue(portal.WebSites.WebSiteExists(TestConstants.WebSiteName));

                // Deploy website content
                portal.WebSites.PublishWebSite(Path.GetFullPath("TestEasyWebSite"), TestConstants.WebSiteName);

                // Ping website
                Assert.IsTrue(TestEasyHelpers.Web.PingUrl(site.GetUrl() + "/default.html"));
            }
        }
Exemplo n.º 26
0
        public void AzureWebSites_E2E_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // Create Azure WebSite
                var site = portal.WebSites.CreateWebSite(TestConstants.WebSiteName);
                Assert.IsTrue(portal.WebSites.WebSiteExists(TestConstants.WebSiteName));

                // Deploy website content
                portal.WebSites.PublishWebSite(Path.GetFullPath("TestEasyWebSite"), TestConstants.WebSiteName);

                // Ping website
                Assert.IsTrue(TestEasyHelpers.Web.PingUrl(site.GetUrl() + "/default.html"));
            }
        }
Exemplo n.º 27
0
        public void AffinityGroups_Waml_Create_Delete_E2E()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(new Microsoft.WindowsAzure.Management.Models.AffinityGroupCreateParameters
                {
                    Name = TestConstants.AffinityGroupName,
                    Location = "West US",
                });

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));

                portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 28
0
        public void AffinityGroups_Waml_Create_Delete_E2E()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.AffinityGroups.CreateAffinityGroup(new Microsoft.WindowsAzure.Management.Models.AffinityGroupCreateParameters
                {
                    Name     = TestConstants.AffinityGroupName,
                    Location = "West US",
                });

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));

                portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);

                Assert.IsNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 29
0
        public void AzureCloudServices_CreateHostedServiceFromWaml_EnsureAffinityGroupExists()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                if (portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName) != null)
                {
                    portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);
                }

                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                {
                    ServiceName   = TestConstants.HostedServiceName,
                    AffinityGroup = TestConstants.AffinityGroupName,
                });

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 30
0
        public void AzureCloudServices_CreateHostedServiceFromWaml_EnsureAffinityGroupExists()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                if(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName) != null)
                {
                    portal.AffinityGroups.DeleteAffinityGroup(TestConstants.AffinityGroupName);
                }

                portal.CloudServices.CreateHostedService(new HostedServiceCreateParameters
                    {
                        ServiceName = TestConstants.HostedServiceName,
                        AffinityGroup = TestConstants.AffinityGroupName,
                    });

                Assert.IsNotNull(portal.AffinityGroups.GetAffinityGroup(TestConstants.AffinityGroupName));
            }
        }
Exemplo n.º 31
0
        public void AzureSql_E2E_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {

                // Create Azure Sql server. Notice that here we specified admin user name and password, however all parameters
                // are optional. If user and password are not specified, TestEasy default ones will be used.
                var server = portal.Sql.CreateSqlServer(user: "******", password: "******");

                // by default when we use Sql.CreateServer, current machine is added to firewall rules by TestEasy
                // however you can add your own server firewall rules
                var rule = server.CreateFirewallRule("mydummyrule", "10.0.0.1", "10.0.0.100");

                Assert.IsTrue(server.FirewallRuleExists(rule.Name));
                Assert.AreEqual("10.0.0.1", rule.StartIPAddress);
                Assert.AreEqual("10.0.0.100", rule.EndIPAddress);

                // delete now our firewall rule
                server.DeleteFirewallRule(rule.Name);

                Assert.IsFalse(server.FirewallRuleExists(rule.Name));

                // create a database on just created server
                var database = server.CreateDatabase("MyTestDatabase");

                // check if database was created for server
                Assert.AreEqual(1, server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                // now remove database
                server.DropDatabase(database);
                Assert.AreEqual(0, server.Databases.Count());

                // remove server
                portal.Sql.DeleteSqlServer(server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(server.Name));
            }
        }
Exemplo n.º 32
0
        public void AzureCloudServices_FastWebRoleCreate_Test()
        {
            var packagePath = Path.GetFullPath("SamplePackage.cspkg");
            var configPath = Path.GetFullPath("SampleServiceConfiguration.Cloud.cscfg");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var webRole = portal.CloudServices.DeployRole(packagePath, configPath);

                // wait for webRole to populate
                portal.CloudServices.WaitForRoleToRespond(webRole, 5000 /* increase timeout here to 600000 in real tests */);

                // now remove WebRole
                portal.CloudServices.DeleteRole(webRole);
                Assert.IsNull(portal.CloudServices.GetDeployment(webRole.HostedService, webRole.Deployment.Name));
            }
        }
Exemplo n.º 33
0
        public void AzureCloudServices_FastWebRoleCreate_Test()
        {
            var packagePath = Path.GetFullPath("SamplePackage.cspkg");
            var configPath  = Path.GetFullPath("SampleServiceConfiguration.Cloud.cscfg");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var webRole = portal.CloudServices.DeployRole(packagePath, configPath);

                // wait for webRole to populate
                portal.CloudServices.WaitForRoleToRespond(webRole, 5000 /* increase timeout here to 600000 in real tests */);

                // now remove WebRole
                portal.CloudServices.DeleteRole(webRole);
                Assert.IsNull(portal.CloudServices.GetDeployment(webRole.HostedService, webRole.Deployment.Name));
            }
        }
Exemplo n.º 34
0
        public void AzureSql_E2E_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(DefaultSubscription))
            {
                // Create Azure Sql server. Notice that here we specified admin user name and password, however all parameters
                // are optional. If user and password are not specified, TestEasy default ones will be used.
                var server = portal.Sql.CreateSqlServer(user: "******", password: "******");

                // by default when we use Sql.CreateServer, current machine is added to firewall rules by TestEasy
                // however you can add your own server firewall rules
                var rule = server.CreateFirewallRule("mydummyrule", "10.0.0.1", "10.0.0.100");

                Assert.IsTrue(server.FirewallRuleExists(rule.Name));
                Assert.AreEqual("10.0.0.1", rule.StartIPAddress);
                Assert.AreEqual("10.0.0.100", rule.EndIPAddress);

                // delete now our firewall rule
                server.DeleteFirewallRule(rule.Name);

                Assert.IsFalse(server.FirewallRuleExists(rule.Name));

                // create a database on just created server
                var database = server.CreateDatabase("MyTestDatabase");

                // check if database was created for server
                Assert.AreEqual(1, server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                // now remove database
                server.DropDatabase(database);
                Assert.AreEqual(0, server.Databases.Count());

                // remove server
                portal.Sql.DeleteSqlServer(server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(server.Name));
            }
        }
Exemplo n.º 35
0
        public void AzureSql_FastCreateDatabase_Test()
        {
            TestEasyLog.Instance.StartScenario("Sample for quick database creation");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {

                TestEasyLog.Instance.StartScenario("Create database");

                // This is fastest way to create database from scratch.
                // Note: if you don't specify server name here, new server will be created for your database.
                // If you would remove server at the end it would be ok, however if each test would createa separate 
                // server for each scenario it may overload subscription capacity. To avoid that make sure you reuse 
                // servers and databases accross scenario of the same test class, unless it is needed by scenario to
                // have fresh objects. 
                // In this API default user and password would be used to create server and your machine's IP would be 
                // automatically added to firewallrules on a new server.
                var database = portal.Sql.CreateSqlDatabase("mytestdbx");

                TestEasyLog.Instance.EndScenario("Database created");

                // check if database was created for server
                Assert.AreEqual(1, database.Server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                TestEasyLog.Instance.StartScenario("Drop database");
                // now remove database and server
                database.Server.DropDatabase(database);

                TestEasyLog.Instance.EndScenario("Database dropped");

                // check if server was deleted
                Assert.IsFalse(database.Server.DatabaseExists(database));
            }

            TestEasyLog.Instance.EndScenario("Sample complete");
        }
Exemplo n.º 36
0
        public void AzureSql_ExplicitResourceCleanup_Test()
        {
            // Create an entry point to all Azure functionality
            var portal = new AzurePortal(DefaultSubscription);

            var database = portal.Sql.CreateSqlDatabase("mytestdbx");

            // check if database was created for server
            Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

            // It is important to call this method in the end of your test to clean up all Azure resources
            // you have used explicitly or implicitly while using TestEasy API. TestEasy remembers all resources
            // that were created and frees them. If we don't free resources subscription will reach it's limits soon,
            // and tests will be blocked.
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            portal.CleanupResources();

            // check if server was deleted
            Assert.IsFalse(database.Server.DatabaseExists(database));
        }
Exemplo n.º 37
0
        public void AzureSql_FastCreateWebSiteWithDatabase_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(DefaultSubscription))
            {
                // This is fastest way to create database from scratch.
                // Note: if you don't specify server name here, new server will be created for your database.
                // If you would remove server at the end it would be ok, however if each test would createa separate
                // server for each scenario it may overload subscription capacity. To avoid that make sure you reuse
                // servers and databases accross scenario of the same test class, unless it is needed by scenario to
                // have fresh objects.
                // In this API default user and password would be used to create server and your machine's IP would be
                // automatically added to firewallrules on a new server.
                var database = portal.Sql.CreateSqlDatabase("mytestdbx");

                // check if database was created for server
                Assert.AreEqual(1, database.Server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                var site = portal.WebSites.CreateWebSite(
                    connectionStringInfo: new Microsoft.WindowsAzure.Management.WebSites.Models.WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                {
                    Name             = "DefaultConnectionString",
                    ConnectionString = database.ConnectionString,
                    Type             = "SQLAzure",
                });

                Assert.IsTrue(TestEasyHelpers.Web.PingUrl(site.GetUrl()));

                // now remove database and server
                database.Server.DropDatabase(database);
                portal.Sql.DeleteSqlServer(database.Server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(database.Server.Name));
            }
        }
Exemplo n.º 38
0
        public void AzureSql_FastCreateDatabase_Test()
        {
            TestEasyLog.Instance.StartScenario("Sample for quick database creation");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                TestEasyLog.Instance.StartScenario("Create database");

                // This is fastest way to create database from scratch.
                // Note: if you don't specify server name here, new server will be created for your database.
                // If you would remove server at the end it would be ok, however if each test would createa separate
                // server for each scenario it may overload subscription capacity. To avoid that make sure you reuse
                // servers and databases accross scenario of the same test class, unless it is needed by scenario to
                // have fresh objects.
                // In this API default user and password would be used to create server and your machine's IP would be
                // automatically added to firewallrules on a new server.
                var database = portal.Sql.CreateSqlDatabase("mytestdbx");

                TestEasyLog.Instance.EndScenario("Database created");

                // check if database was created for server
                Assert.AreEqual(1, database.Server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                TestEasyLog.Instance.StartScenario("Drop database");
                // now remove database and server
                database.Server.DropDatabase(database);

                TestEasyLog.Instance.EndScenario("Database dropped");

                // check if server was deleted
                Assert.IsFalse(database.Server.DatabaseExists(database));
            }

            TestEasyLog.Instance.EndScenario("Sample complete");
        }
Exemplo n.º 39
0
        public void AzureSql_FastCreateWebSiteWithDatabase_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                // This is fastest way to create database from scratch.
                // Note: if you don't specify server name here, new server will be created for your database.
                // If you would remove server at the end it would be ok, however if each test would createa separate 
                // server for each scenario it may overload subscription capacity. To avoid that make sure you reuse 
                // servers and databases accross scenario of the same test class, unless it is needed by scenario to
                // have fresh objects. 
                // In this API default user and password would be used to create server and your machine's IP would be 
                // automatically added to firewallrules on a new server.
                var database = portal.Sql.CreateSqlDatabase("mytestdbx");

                // check if database was created for server
                Assert.AreEqual(1, database.Server.Databases.Count());

                // just dummy check that connection string is not empty
                Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

                var site = portal.WebSites.CreateWebSite(
                    connectionStringInfo: new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                    {
                        Name = "DefaultConnectionString",
                        ConnectionString = database.ConnectionString,
                        Type = "SQLAzure",
                    });

                Assert.IsTrue(TestEasyHelpers.Web.PingUrl(site.GetUrl()));

                // now remove database and server
                database.Server.DropDatabase(database);
                portal.Sql.DeleteSqlServer(database.Server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(database.Server.Name));
            }
        }
Exemplo n.º 40
0
        public void AzureCloudServices_SwapDeployment_StagingToProduction()
        {
            var packagePath = Path.GetFullPath("SamplePackage.cspkg");
            var configPath = Path.GetFullPath("SampleServiceConfiguration.Cloud.cscfg");

            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                var webRole = portal.CloudServices.DeployRole(packagePath, configPath, deploymentSlot: DeploymentSlot.Staging);

                // wait for webRole to populate
                portal.CloudServices.WaitForRoleToRespond(webRole, 5000 /* increase timeout here to 600000 in real tests */);

                var deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Staging);
                Assert.IsNotNull(deployment);

                portal.CloudServices.SwapDeployment(webRole.HostedService, new DeploymentSwapParameters
                {
                    SourceDeployment = webRole.Deployment.Name,
                });

                deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Production);
                Assert.IsNotNull(deployment);
                deployment = portal.CloudServices.GetDeploymentBySlot(webRole.HostedService, DeploymentSlot.Staging);
                Assert.IsNull(deployment);
            }
        }
Exemplo n.º 41
0
        public void AzureSql_PublishDatabase_Test()
        {
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {

                // create two databases from scratch (they are empty but for feature demonstration its ok)
                var databaseSource = portal.Sql.CreateSqlDatabase("mytestdbxs");
                var server = databaseSource.Server;
                var databaseDestination = portal.Sql.CreateSqlDatabase("mytestdbxd", server);

                // now use WebDeploy to publish source database to destination including data(!).
                // Note: that calling publish database can be called sequentially and next time would bring only 
                // database updates.
                portal.Sql.PublishDatabase(
                    WebDeployDatabaseType.FullSql,
                    databaseSource.ConnectionString,
                    WebDeployDatabaseType.FullSql,
                    databaseDestination.ConnectionString,
                    includeData: true);

                // now remove database and server
                server.DropDatabase(databaseSource);
                server.DropDatabase(databaseDestination);
                portal.Sql.DeleteSqlServer(server.Name);

                // check if server was deleted
                Assert.IsNull(portal.Sql.GetSqlServer(server.Name));
            }
        }
Exemplo n.º 42
0
        public void AzureCloudServices_CleanupHostedServicesAfterTest()
        {
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                portal.CloudServices.CreateHostedService(TestConstants.HostedServiceName);

                Assert.IsNotNull(portal.CloudServices.GetHostedService(TestConstants.HostedServiceName));
            }

            // verify hosted service was cleaned up
            using (var portal = new AzurePortal(TestConstants.TestSubscription))
            {
                Assert.IsNull(portal.CloudServices.GetHostedService(TestConstants.HostedServiceName));
            }
        }
Exemplo n.º 43
0
        public void AzureSql_ExplicitResourceCleanup_Test()
        {
            // Create an entry point to all Azure functionality
            var portal = new AzurePortal(TestConstants.TestSubscription);

            var database = portal.Sql.CreateSqlDatabase("mytestdbx");

            // check if database was created for server
            Assert.AreEqual(1, database.Server.Databases.Count());
            Assert.IsFalse(string.IsNullOrEmpty(database.ConnectionString));

            // It is important to call this method in the end of your test to clean up all Azure resources
            // you have used explicitly or implicitly while using TestEasy API. TestEasy remembers all resources 
            // that were created and frees them. If we don't free resources subscription will reach it's limits soon,
            // and tests will be blocked.
            // Note: !!! it is recommended though to use "using" statement since it would call Dispose even in 
            // the case of exception, which would ensure all resources cleaned up.
            portal.CleanupResources();

            // check if server was deleted
            Assert.IsFalse(database.Server.DatabaseExists(database));

        }