Esempio n. 1
0
        private static string GetRepositoryPath(string repoName, string repoCloneUrl, string appName)
        {
            TestRepository testRepository = null;

            string localRepo = KuduUtils.GetCachedRepositoryPath(repoName);

            if (localRepo == null)
            {
                testRepository = Git.Clone(appName, repoCloneUrl);
                localRepo      = testRepository.PhysicalPath;
            }
            return(localRepo);
        }
Esempio n. 2
0
        private static void PushAndDeployApps(string name, string repoName, string repoCloneUrl, string defaultBranchName,
                                              string verificationText, HttpStatusCode expectedResponseCode, string verificationLogText)
        {
            TestRepository testRepository = null;

            string localRepo      = KuduUtils.GetCachedRepositoryPath(repoName);
            string randomTestName = KuduUtils.GetRandomWebsiteName(repoName);

            if (localRepo == null)
            {
                testRepository = Git.Clone(randomTestName, repoCloneUrl);
                localRepo      = testRepository.PhysicalPath;
            }

            try
            {
                ApplicationManager.Run(randomTestName, appManager =>
                {
                    // Act
                    appManager.GitDeploy(localRepo, defaultBranchName);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText, expectedResponseCode);
                    if (!String.IsNullOrEmpty(verificationLogText.Trim()))
                    {
                        KuduAssert.VerifyLogOutput(appManager, results[0].Id, verificationLogText.Trim());
                    }
                });
            }
            finally
            {
                if (testRepository != null)
                {
                    testRepository.Dispose();
                }
            }
        }
Esempio n. 3
0
        public void TestLogStreamSubFolder()
        {
            string appName      = KuduUtils.GetRandomWebsiteName("TestLogStreamFilter");
            string repoName     = "LogTester";
            string repoCloneUrl = "https://github.com/KuduApps/LogTester.git";

            TestRepository testRepository = null;
            string         localRepo      = KuduUtils.GetCachedRepositoryPath(repoName);

            if (localRepo == null)
            {
                testRepository = Git.Clone(appName, repoCloneUrl);
                localRepo      = testRepository.PhysicalPath;
            }

            ApplicationManager.Run(appName, appManager =>
            {
                // Act
                appManager.GitDeploy(localRepo);
                List <string> logFiles = new List <string>();
                List <LogStreamWaitHandle> waitHandles = new List <LogStreamWaitHandle>();
                for (int i = 0; i < 2; ++i)
                {
                    logFiles.Add(@"LogFiles\Folder" + i + "\\temp.txt");
                    //Create the directory
                    CreateLogDirectory(appManager.SiteUrl, @"LogFiles\Folder" + i);
                    RemoteLogStreamManager mgr = appManager.CreateLogStreamManager("folder" + i);
                    var waitHandle             = new LogStreamWaitHandle(mgr.GetStream().Result);
                    string line = waitHandle.WaitNextLine(10000);
                    Assert.True(!string.IsNullOrEmpty(line) && line.Contains("Welcome"), "check welcome message: " + line);
                    waitHandles.Add(waitHandle);
                }

                using (LogStreamWaitHandle waitHandle = new LogStreamWaitHandle(appManager.LogStreamManager.GetStream().Result))
                {
                    try
                    {
                        string line = waitHandle.WaitNextLine(10000);
                        Assert.True(!string.IsNullOrEmpty(line) && line.Contains("Welcome"), "check welcome message: " + line);

                        // write to folder0, we should not get any live stream for folder1 listener
                        string content = Guid.NewGuid().ToString();
                        WriteLogText(appManager.SiteUrl, logFiles[0], content);
                        line = waitHandle.WaitNextLine(10000);
                        Assert.Equal(content, line);
                        line = waitHandles[0].WaitNextLine(10000);
                        Assert.Equal(content, line);
                        line = waitHandles[1].WaitNextLine(1000);
                        Assert.True(line == null, "no more message: " + line);

                        // write to folder1, we should not get any live stream for folder0 listener
                        content = Guid.NewGuid().ToString();
                        WriteLogText(appManager.SiteUrl, logFiles[1], content);
                        line = waitHandle.WaitNextLine(10000);
                        Assert.Equal(content, line);
                        line = waitHandles[1].WaitNextLine(10000);
                        Assert.Equal(content, line);
                        line = waitHandles[0].WaitNextLine(1000);
                        Assert.True(line == null, "no more message: " + line);
                    }
                    finally
                    {
                        waitHandles[0].Dispose();
                        waitHandles[1].Dispose();
                    }
                }
            });
        }