示例#1
0
            public async Task WritesToReplicaHives()
            {
                ReplicaHives.Add(HiveType.Gzipped);
                ReplicaHives.Add(HiveType.SemVer2);

                await Target.WriteLeafAsync(Hive, ReplicaHives, Id, Version, Leaf);

                LegacyBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once);
                GzippedBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once);
                SemVer2Blob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once);
                EntityBuilder.Verify(x => x.UpdateLeafUrls(It.IsAny <RegistrationLeaf>(), It.IsAny <HiveType>(), It.IsAny <HiveType>()), Times.Exactly(3));
                EntityBuilder.Verify(x => x.UpdateLeafUrls(Leaf, HiveType.Legacy, HiveType.Gzipped), Times.Once);
                EntityBuilder.Verify(x => x.UpdateLeafUrls(Leaf, HiveType.Gzipped, HiveType.SemVer2), Times.Once);
                EntityBuilder.Verify(x => x.UpdateLeafUrls(Leaf, HiveType.SemVer2, HiveType.Legacy), Times.Once);
            }
示例#2
0
            public async Task MergesSemVer2VersionsOnSemVer2Hives()
            {
                AddPackageDetails("2.0.0-beta.1");

                await Target.UpdateAsync(Hive, ReplicaHives, Id, Entries, EntryToCatalogLeaf, RegistrationCommit);

                EntityBuilder.Verify(
                    x => x.NewLeaf(It.Is <RegistrationLeafItem>(i => i.CatalogEntry.Version == "2.0.0-beta.1")),
                    Times.Once);
                Storage.Verify(
                    x => x.WriteLeafAsync(Hive, ReplicaHives, Id, NuGetVersion.Parse("2.0.0-beta.1"), RegistrationLeaf),
                    Times.Once);
                Storage.Verify(
                    x => x.WriteIndexAsync(Hive, ReplicaHives, Id, RegistrationIndex),
                    Times.Once);
                Assert.Equal("2.0.0-beta.1", RegistrationIndex.Items[0].Items[1].CatalogEntry.Version);
            }
示例#3
0
        public IntegrationTests(ITestOutputHelper output)
        {
            Options = new Mock <IOptionsSnapshot <Catalog2RegistrationConfiguration> >();
            Config  = new Catalog2RegistrationConfiguration
            {
                LegacyBaseUrl                  = "https://example/v3/reg",
                LegacyStorageContainer         = "v3-reg",
                GzippedBaseUrl                 = "https://example/v3/reg-gz",
                GzippedStorageContainer        = "v3-reg-gz",
                SemVer2BaseUrl                 = "https://example/v3/reg-gz-semver2",
                SemVer2StorageContainer        = "v3-reg-gz-semver2",
                FlatContainerBaseUrl           = "https://example/v3/flatcontainer",
                GalleryBaseUrl                 = "https://example-gallery",
                MaxConcurrentHivesPerId        = 1,
                MaxConcurrentIds               = 1,
                MaxConcurrentOperationsPerHive = 1,
                MaxConcurrentStorageOperations = 1,
                EnsureSingleSnapshot           = false,
            };
            Options.Setup(x => x.Value).Returns(() => Config);

            CloudBlobClient        = new InMemoryCloudBlobClient();
            RegistrationUrlBuilder = new RegistrationUrlBuilder(Options.Object);
            EntityBuilder          = new EntityBuilder(RegistrationUrlBuilder, Options.Object);
            Throttle    = NullThrottle.Instance;
            HiveStorage = new HiveStorage(
                CloudBlobClient,
                RegistrationUrlBuilder,
                EntityBuilder,
                Throttle,
                Options.Object,
                output.GetLogger <HiveStorage>());
            HiveMerger  = new HiveMerger(Options.Object, output.GetLogger <HiveMerger>());
            HiveUpdater = new HiveUpdater(
                HiveStorage,
                HiveMerger,
                EntityBuilder,
                Options.Object,
                output.GetLogger <HiveUpdater>());
            RegistrationUpdater = new RegistrationUpdater(
                HiveUpdater,
                Options.Object,
                output.GetLogger <RegistrationUpdater>());
        }
示例#4
0
            public async Task ExcludesSemVer2VersionsFromSemVer1Hives(HiveType hive)
            {
                Hive = hive;
                AddPackageDetails("2.0.0-beta.1");

                await Target.UpdateAsync(Hive, ReplicaHives, Id, Entries, EntryToCatalogLeaf, RegistrationCommit);

                EntityBuilder.Verify(x => x.NewLeaf(It.IsAny <RegistrationLeafItem>()), Times.Never);
                Storage.Verify(
                    x => x.WriteLeafAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <NuGetVersion>(), It.IsAny <RegistrationLeaf>()),
                    Times.Never);
                Storage.Verify(
                    x => x.WritePageAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <NuGetVersion>(), It.IsAny <NuGetVersion>(), It.IsAny <RegistrationPage>()),
                    Times.Never);
                Storage.Verify(
                    x => x.WriteIndexAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <RegistrationIndex>()),
                    Times.Never);
                Assert.Equal(2, RegistrationIndex.Items[0].Items.Count);
                Assert.DoesNotContain("2.0.0-beta.1", RegistrationIndex.Items[0].Items.Select(x => x.CatalogEntry.Version));
            }
示例#5
0
            public async Task MergesCatalogCommitItems()
            {
                AddPackageDetails("2.0.0");

                await Target.UpdateAsync(Hive, ReplicaHives, Id, Entries, EntryToCatalogLeaf, RegistrationCommit);

                Merger.Verify(
                    x => x.MergeAsync(It.IsAny <IndexInfo>(), It.IsAny <IReadOnlyList <CatalogCommitItem> >()),
                    Times.Once);
                EntityBuilder.Verify(
                    x => x.NewLeaf(It.IsAny <RegistrationLeafItem>()),
                    Times.Once);
                EntityBuilder.Verify(
                    x => x.NewLeaf(It.Is <RegistrationLeafItem>(i => i.CatalogEntry.Version == "2.0.0")),
                    Times.Once);
                EntityBuilder.Verify(
                    x => x.NewLeaf(RegistrationIndex.Items[0].Items[1]),
                    Times.Once);
                Storage.Verify(
                    x => x.WriteLeafAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <NuGetVersion>(), It.IsAny <RegistrationLeaf>()),
                    Times.Once);
                Storage.Verify(
                    x => x.WriteLeafAsync(Hive, ReplicaHives, Id, NuGetVersion.Parse("2.0.0"), RegistrationLeaf),
                    Times.Once);
                Storage.Verify(
                    x => x.WritePageAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <NuGetVersion>(), It.IsAny <NuGetVersion>(), It.IsAny <RegistrationPage>()),
                    Times.Never);
                Storage.Verify(
                    x => x.WriteIndexAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>(), It.IsAny <RegistrationIndex>()),
                    Times.Once);
                Storage.Verify(
                    x => x.WriteIndexAsync(Hive, ReplicaHives, Id, RegistrationIndex),
                    Times.Once);
                Storage.Verify(
                    x => x.DeleteIndexAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>()),
                    Times.Never);
                Storage.Verify(
                    x => x.DeleteUrlAsync(It.IsAny <HiveType>(), It.IsAny <IReadOnlyList <HiveType> >(), It.IsAny <string>()),
                    Times.Never);
                Assert.Equal("2.0.0", RegistrationIndex.Items[0].Items[1].CatalogEntry.Version);
            }