Пример #1
0
        [Ignore] // Nuget.Core returns the downloadcount for package registration always and doesnt return the count for package versions. Ignoring it for now.
        public void DownloadStatsForPackageVersions()
        {
            string packageId = testContextInstance.TestName + DateTime.Now.Ticks.ToString();

            //Upload package.
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
            //Upload 2.0 for the same package.
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");

            //check download count for the package registration and package versions.
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatistics(packageId).Equals(0), "Package download count is not zero as soon as uploading. Actual value : {0}", ClientSDKHelper.GetDownLoadStatistics(packageId));
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "1.0.0").Equals(0), "Package version download count is not zero as soon as uploading. Actual value : {0}", ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "1.0.0"));
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "2.0.0").Equals(0), "Package version download count is not zero as soon as uploading. Actual value : {0}", ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "2.0.0"));

            //Download the new package.
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId, "1.0.0");
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId, "2.0.0");

            //Wait for a max of 5 mins ( as the stats job runs every 5 mins).
            int downloadCount = ClientSDKHelper.GetDownLoadStatistics(packageId);
            int waittime      = 0;

            while (downloadCount == 0 && waittime <= 300)
            {
                downloadCount = ClientSDKHelper.GetDownLoadStatistics(packageId);
                System.Threading.Thread.Sleep(30 * 1000);//sleep for 30 seconds.
                waittime += 30;
            }
            //check download count. Download count for the package registration should be 2 and the download count for the package versions should be 1.
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatistics(packageId) == 2, "Package download count is not increased after downloading a new package. Actual value : {0}", ClientSDKHelper.GetDownLoadStatistics(packageId));
            //TBD : Seems like NuGet.Core returns the download count for package registration always.
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "1.0.0") == 1, "Package version download count is not 1 after downloading a new package. Actual value : {0}", ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "1.0.0"));
            Assert.IsTrue(ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "2.0.0") == 1, "Package version download count is not 1 after downloading a new package. Actual value : {0}", ClientSDKHelper.GetDownLoadStatisticsForPackageVersion(packageId, "2.0.0"));
        }
 /// <summary>
 /// Downloads a package to local folder and see if the download is successful. Used to individual tests which extend the download scenarios.
 /// </summary>
 /// <param name="packageId"></param>
 public static void DownloadPackageAndVerify(string packageId, string version = "1.0.0")
 {
     ClientSDKHelper.ClearMachineCache();
     ClientSDKHelper.ClearLocalPackageFolder(packageId);
     new PackageManager(PackageRepositoryFactory.Default.CreateRepository(UrlHelper.V2FeedRootUrl), Environment.CurrentDirectory).InstallPackage(packageId, new SemanticVersion(version));
     Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionInstalled(packageId, version), "Package install failed. Either the file is not present on disk or it is corrupted. Check logs for details");
 }
        public void UploadMultipleVersionOfPackage()
        {
            string packageId = "TestMultipleVersion" + "." + DateTime.Now.Ticks.ToString();

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");
            int actualCount = ClientSDKHelper.GetVersionCount(packageId);

            Assert.IsTrue(actualCount.Equals(2), " 2 versions of package {0} not found after uploading. Actual versions found {1}", packageId, actualCount);
        }
        public void DownPackageWithNuGetCommandLineTest()
        {
            string packageId = Constants.TestPackageId; //try to down load a pre-defined test package.

            ClientSDKHelper.ClearLocalPackageFolder(packageId);
            int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl);

            Assert.IsTrue((exitCode == 0), "The package install via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream");
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), "Package install failed. Either the file is not present on disk or it is corrupted. Check logs for details");
        }
        public void DownloadPackageWithNuGetCommandLineTest()
        {
            string packageId = Constants.TestPackageId; //try to down load a pre-defined test package.

            ClientSDKHelper.ClearLocalPackageFolder(packageId);
            int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl, Environment.CurrentDirectory);

            Assert.IsTrue((exitCode == 0), Constants.PackageDownloadFailureMessage);
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), Constants.PackageInstallFailureMessage);
        }
 public void DownloadPackageWithNuGetCommandLineTest()
 {
     // Temporary work around for the SSL issue, which keeps the upload tests from working on sites with cloudapp.net
     if (UrlHelper.BaseUrl.Contains("nugettest.org") || UrlHelper.BaseUrl.Contains("nuget.org"))
     {
         string packageId = Constants.TestPackageId; //try to down load a pre-defined test package.
         ClientSDKHelper.ClearLocalPackageFolder(packageId);
         int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl, Environment.CurrentDirectory);
         Assert.IsTrue((exitCode == 0), Constants.PackageDownloadFailureMessage);
         Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), Constants.PackageInstallFailureMessage);
     }
 }
Пример #7
0
        public void AddPackageToWindows8CuratedFeed()
        {
            string packageId       = testContextInstance.TestName + DateTime.Now.Ticks.ToString();
            string packageFullPath = PackageCreationHelper.CreateWindows8CuratedPackage(packageId);
            int    exitCode        = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl);

            Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream");
            //check if the package is present in windows 8 feed.
            //TBD : Need to check the exact the url for curated feed.
            System.Threading.Thread.Sleep(60000);
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageExistsInSource(packageId, UrlHelper.Windows8CuratedFeedUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.Windows8CuratedFeedUrl);
        }
Пример #8
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //Upload a new package.
            string packageId = this.Name + DateTime.Now.Ticks.ToString();
            string version   = "1.0.0";

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, version);

            //Do initial login to be able to perform delete ops.
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            logonGet = null;
            WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);

            yield return(logonPost);

            logonPost = null;

            string deletePackagePageUrl = UrlHelper.GetPackageDeletePageUrl(packageId, version);


            WebTestRequest deletePackageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(deletePackagePageUrl);

            yield return(deletePackageRequest);

            deletePackageRequest = null;

            WebTestRequest deletePackagePagePostRequest = new WebTestRequest(deletePackagePageUrl);

            deletePackagePagePostRequest.Method = "POST";
            //once the listing is done, it should return back to the packages page.
            deletePackagePagePostRequest.ExpectedResponseUrl = UrlHelper.GetPackagePageUrl(packageId, version);
            FormPostHttpBody deletePackagePostRequestForm = new FormPostHttpBody();

            deletePackagePostRequestForm.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            deletePackagePostRequestForm.FormPostParameters.Add("Listed", this.Context["$HIDDEN1.Listed"].ToString());
            deletePackagePagePostRequest.Body = deletePackagePostRequestForm;

            //Make sure that the package page shows the message saying that it has been unlisted.
            ValidationRuleFindText findTextRule = new ValidationRuleFindText();

            findTextRule.FindText = Constants.UnListedPackageText;
            deletePackagePagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(findTextRule.Validate);
            yield return(deletePackagePagePostRequest);

            deletePackagePagePostRequest = null;

            //check if it shows up in search and cross check with client SDK.
            Assert.IsTrue(ClientSDKHelper.IsPackageVersionUnListed(packageId, version), "Package not returned as unlisted by Nuget core after unlisting it in gallery");
        }
Пример #9
0
        public bool CheckPackageExistInCuratedFeed(string packageName, FeedType feedType)
        {
            string curatedFeedUrl = GetCuratedFeedUrl(feedType);
            bool   applied        = false;

            for (int i = 0; i < 10 && applied == false; i++)
            {
                System.Threading.Thread.Sleep(30 * 1000);
                if (ClientSDKHelper.CheckIfPackageExistsInSource(packageName, curatedFeedUrl))
                {
                    applied = true;
                }
            }
            return(applied);
        }
Пример #10
0
 public static void CheckIfBaseTestPackageExists()
 {
     //Check if the BaseTestPackage exists in current source and if not upload it. This will be used by the download related tests.
     try
     {
         if (!ClientSDKHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl))
         {
             AssertAndValidationHelper.UploadNewPackageAndVerify(Constants.TestPackageId);
         }
     }
     catch (AssertFailedException)
     {
         Assert.Inconclusive("The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl);
     }
 }
        public void UploadAndDownLoadPackageWithMinClientVersion()
        {
            string packageId       = DateTime.Now.Ticks.ToString() + "PackageWithDotCsNames.Cs";
            string version         = "1.0.0";
            string packageFullPath = PackageCreationHelper.CreatePackageWithMinClientVersion(packageId, version, "2.3");
            int    exitCode        = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl);

            Assert.IsTrue((exitCode == 0), Constants.UploadFailureMessage);
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), Constants.PackageNotFoundAfterUpload, packageId, UrlHelper.V2FeedRootUrl);

            //Delete package from local disk so once it gets uploaded
            if (File.Exists(packageFullPath))
            {
                File.Delete(packageFullPath);
                Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true);
            }
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);
        }
        [Ignore] //This method is marked ignore as we don't it to be run in regular runs. It will be run only when required.
        public void UploadAndDownLoadTestBombPackage()
        {
            string packageId       = DateTime.Now.Ticks.ToString() + testContextInstance.TestName;
            string version         = "1.0.0";
            string packageFullPath = PackageCreationHelper.CreateGalleryTestBombPackage(packageId);
            int    exitCode        = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl);

            Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream");
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.V2FeedRootUrl);

            //Delete package from local disk so once it gets uploaded
            if (File.Exists(packageFullPath))
            {
                File.Delete(packageFullPath);
                Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true);
            }

            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);
        }
Пример #13
0
 public static void AssemblyInit(TestContext context)
 {
     //Check if functional tests is enabled. If not, do an assert inconclusive.
     if (!EnvironmentSettings.RunFunctionalTests.Equals("True", StringComparison.OrdinalIgnoreCase))
     {
         Assert.Inconclusive("Functional tests are disabled in the current run. Please set environment variable RunFuntionalTests to True to enable them");
     }
     //Check if the BaseTestPackage exists in current source and if not upload it. This will be used by the download related tests.
     try
     {
         if (!ClientSDKHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl))
         {
             AssertAndValidationHelper.UploadNewPackageAndVerify(Constants.TestPackageId);
         }
     }
     catch (AssertFailedException)
     {
         Assert.Inconclusive("The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl);
     }
 }
Пример #14
0
 public void RestorePackageFromV2Feed()
 {
     ClientSDKHelper.ClearMachineCache(); //clear local cache.
     try
     {
         string        packageId    = Constants.TestPackageId; //the package name shall be fixed as it really doesnt matter which package we are trying to install.
         string        version      = "1.0.0";
         Task <string> downloadTask = ODataHelper.DownloadPackageFromFeed(packageId, version, "Restore");
         string        filename     = downloadTask.Result;
         //check if the file exists.
         Assert.IsTrue(File.Exists(filename), " Package restore from V2 feed didnt work");
         string downloadedPackageId = ClientSDKHelper.GetPackageIdFromNupkgFile(filename);
         //Check that the downloaded Nupkg file is not corrupt and it indeed corresponds to the package which we were trying to download.
         Assert.IsTrue(downloadedPackageId.Equals(packageId), "Unable to unzip the package restored via V2 Feed. Check log for details");
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Пример #15
0
 public void DownloadPackageFromV2Feed()
 {
     ClientSDKHelper.ClearMachineCache(); //clear local cache.
     try
     {
         string        packageId    = Constants.TestPackageId; //try to down load a pre-defined test package.
         string        version      = "1.0.0";
         Task <string> downloadTask = DownloadPackage(packageId, version);
         string        filename     = downloadTask.Result;
         //check if the file exists.
         Assert.IsTrue(File.Exists(filename), " Package download from V2 feed didnt work");
         string downloadedPackageId = ClientSDKHelper.GetPackageIdFromNupkgFile(filename);
         //Check that the downloaded Nupkg file is not corrupt and it indeed corresponds to the package which we were trying to download.
         Assert.IsTrue(downloadedPackageId.Equals(packageId), "Unable to unzip the package downloaded via V2 feed. Check log for details");
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
        /// <summary>
        /// Creates a package with the specified Id and Version and uploads it and checks if the upload has suceeded.
        /// This will be used by test classes which tests scenarios on top of upload.
        /// </summary>
        /// <param name="packageId"></param>
        /// <param name="version"></param>
        public static void UploadNewPackageAndVerify(string packageId, string version = "1.0.0")
        {
            if (string.IsNullOrEmpty(packageId))
            {
                packageId = DateTime.Now.Ticks.ToString();
            }
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId, version);
            string standardOutput  = string.Empty;
            string standardError   = string.Empty;
            int    exitCode        = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl, out standardOutput, out standardError);

            Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream.  Exit Code: " + exitCode + ". Error message: \"" + standardError + "\"");
            Console.WriteLine(standardOutput);
            Console.WriteLine(standardError);
            Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.V2FeedRootUrl);

            //Delete package from local disk so once it gets uploaded
            if (File.Exists(packageFullPath))
            {
                File.Delete(packageFullPath);
                Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true);
            }
        }
Пример #17
0
        public void SearchWebMatrixCuratedFeed()
        {
            string packageName     = "NuGetGallery.FunctionalTests.SearchWebMatrixCuratedFeed";
            string ticks           = DateTime.Now.Ticks.ToString();
            string version         = new System.Version(ticks.Substring(0, 6) + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString();
            string packageFullPath = PackageCreationHelper.CreateWebMatrixCuratedPackage(packageName, version);

            int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl);

            Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream");

            // The feed could update anytime in the next 5 minutes and this test would be considered a success.
            bool applied = false;

            for (int i = 0; i < 10 && applied == false; i++)
            {
                System.Threading.Thread.Sleep(30000);
                if (ClientSDKHelper.CheckIfPackageExistsInSource(packageName, UrlHelper.WebMatrixCuratedFeedUrl))
                {
                    applied = true;
                }
            }
            Assert.IsTrue(applied, "Package {0} is not found in the site {1} after uploading.", packageName, UrlHelper.WebMatrixCuratedFeedUrl);
        }
Пример #18
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            // take package names from the data source
            string         packageId          = Constants.TestPackageId;
            WebTestRequest packagePageRequest = new WebTestRequest(UrlHelper.BaseUrl + @"/Packages/" + packageId);

            //Rule to check if the title contains the package id and the latest stable version of the package.
            ValidateHtmlTagInnerText packageTitleValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.Title.ToString(), string.Empty, string.Empty, "NuGet Gallery | " + packageId + " " + ClientSDKHelper.GetLatestStableVersion(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(packageTitleValidationRule.Validate);
            //rule to check that the download count is present in the response.
            ValidationRuleFindText downloadCountValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(ClientSDKHelper.GetFormattedDownLoadStatistics(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(downloadCountValidationRule.Validate);

            yield return(packagePageRequest);

            packagePageRequest = null;
        }
Пример #19
0
 public bool PackageExists(string packageName, string version, string url)
 {
     return(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageName, version, url));
 }
Пример #20
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //Use a predefined test package.
            string         packageId          = Constants.TestPackageId;
            WebTestRequest packagePageRequest = new WebTestRequest(UrlHelper.BaseUrl + @"/Packages/" + packageId);

            //Rule to check if the title contains the package id and the latest stable version of the package.
            ValidationRuleFindText packageTitleValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(packageId + " " + ClientSDKHelper.GetLatestStableVersion(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(packageTitleValidationRule.Validate);
            //rule to check that the download count is present in the response.
            ValidationRuleFindText downloadCountValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(ClientSDKHelper.GetFormattedDownLoadStatistics(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(downloadCountValidationRule.Validate);

            yield return(packagePageRequest);

            packagePageRequest = null;
        }
Пример #21
0
 public void TestInit()
 {
     //Clear the machine cache during the start of every test to make sure that we always hit the gallery         .
     ClientSDKHelper.ClearMachineCache();
 }