protected void VerifyRDP(string serviceName, string rdpPath)
        {
            Utilities.GetDeploymentAndWaitForReady(serviceName, DeploymentSlotType.Production, 10, 600);

            vmPowershellCmdlets.GetAzureRemoteDesktopFile("WebRole1_IN_0", serviceName, rdpPath, false);

            string dns;

            using (var stream = new StreamReader(rdpPath))
            {
                string firstLine = stream.ReadLine();
                dns = Utilities.FindSubstring(firstLine, ':', 2);
            }

            Assert.IsTrue((Utilities.RDPtestPaaS(dns, "WebRole1", 0, username, password, true)), "Cannot RDP to the instance!!");
        }
Exemple #2
0
        public void AzureServiceExtensionTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            const string rdpPath = @".\WebRole2.rdp";

            try
            {
                Collection <ExtensionImageContext> resultExtensions = vmPowershellCmdlets.GetAzureServiceAvailableExtension();

                foreach (var extension in resultExtensions)
                {
                    if (extension.ExtensionName == "RDP")
                    {
                        _extensionName     = extension.ExtensionName;
                        _providerNamespace = extension.ProviderNameSpace;
                        break;
                    }
                }

                vmPowershellCmdlets.NewAzureService(_serviceName, _serviceName, locationName);
                Console.WriteLine("service, {0}, is created.", _serviceName);

                vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath.FullName, _configPath.FullName,
                                                       DeploymentSlotType.Production, DeploymentLabel, DeploymentName, false, false);

                DeploymentInfoContext result = vmPowershellCmdlets.GetAzureDeployment(_serviceName, DeploymentSlotType.Production);
                pass = Utilities.PrintAndCompareDeployment(result, _serviceName, DeploymentName, DeploymentLabel, DeploymentSlotType.Production, null, 2);
                Console.WriteLine("successfully deployed the package");

                vmPowershellCmdlets.SetAzureServiceExtension(
                    serviceName: _serviceName,
                    extensionName: _extensionName,
                    providerNamespace: _providerNamespace,
                    publicConfig: PublicConfig,
                    privateConfig: PrivateConfig
                    );

                ExtensionContext resultExtensionContext = vmPowershellCmdlets.GetAzureServiceExtension(_serviceName)[0];

                Utilities.PrintContext(resultExtensionContext);

                VerifyExtensionContext(resultExtensionContext, "AllRoles", _extensionName, _providerNamespace);

                RemoteDesktopExtensionContext resultContext = vmPowershellCmdlets.GetAzureServiceRemoteDesktopExtension(_serviceName)[0];

                Utilities.PrintContext(resultContext);

                vmPowershellCmdlets.GetAzureRemoteDesktopFile("WebRole1_IN_0", _serviceName, rdpPath, false);

                string dns;

                using (var stream = new StreamReader(rdpPath))
                {
                    string firstLine = stream.ReadLine();
                    dns = Utilities.FindSubstring(firstLine, ':', 2);
                }

                Assert.IsTrue((Utilities.RDPtestPaaS(dns, "WebRole1", 0, username, password, true)), "Cannot RDP to the instance!!");

                vmPowershellCmdlets.RemoveAzureServiceExtension(
                    serviceName: _serviceName,
                    extensionName: _extensionName,
                    providerNamespace: _providerNamespace,
                    uninstall: true);

                try
                {
                    vmPowershellCmdlets.GetAzureRemoteDesktopFile("WebRole1_IN_0", _serviceName, rdpPath, false);
                    Assert.Fail("Succeeded, but extected to fail!");
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    Console.WriteLine("Failed to get RDP file as expected");
                }

                vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true);

                pass &= Utilities.CheckRemove(vmPowershellCmdlets.GetAzureDeployment, _serviceName, DeploymentSlotType.Production);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred: {0}", e);
                throw;
            }
        }