예제 #1
0
        public async Task DoesNotSkipPackagesWhenExceptionOccurs(string catalogUri, string expectedCursorBeforeRetry)
        {
            // Arrange
            SharedInit(useLegacy: true, useSemVer2: false);

            var catalogStorage = Catalogs.CreateTestCatalogWithCommitThenTwoPackageCommit();
            await _mockServer.AddStorageAsync(catalogStorage);

            // Make the first request for a catalog leaf node fail. This will cause the registration collector
            // to fail the first time but pass the second time.
            FailFirstRequest(catalogUri);

            expectedCursorBeforeRetry = expectedCursorBeforeRetry ?? MemoryCursor.MinValue.ToString("O");

            ReadWriteCursor front = new DurableCursor(
                _legacyStorage.ResolveUri("cursor.json"),
                _legacyStorage,
                MemoryCursor.MinValue);
            ReadCursor back = MemoryCursor.CreateMax();

            // Act
            await Assert.ThrowsAsync <BatchProcessingException>(
                () => _target.RunAsync(front, back, CancellationToken.None));

            var cursorBeforeRetry = front.Value;
            await _target.RunAsync(front, back, CancellationToken.None);

            var cursorAfterRetry = front.Value;

            // Assert
            var unlistedPackage100 = _legacyStorage
                                     .Content
                                     .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/unlistedpackage/1.0.0.json"));

            Assert.NotNull(unlistedPackage100.Key);

            var listedPackage101 = _legacyStorage
                                   .Content
                                   .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/listedpackage/1.0.1.json"));

            Assert.NotNull(listedPackage101.Key);

            var anotherPackage100 = _legacyStorage
                                    .Content
                                    .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/anotherpackage/1.0.0.json"));

            Assert.NotNull(anotherPackage100.Key);

            Assert.Equal(MemoryCursor.MinValue, cursorBeforeRetry);
            Assert.Equal(DateTime.Parse("2015-10-12T10:08:55.3335317Z").ToUniversalTime(), cursorAfterRetry);
        }
예제 #2
0
        private async Task ExecuteCatalog2RegistrationAsync(PerBatchContext context, Uri catalogIndexUri)
        {
            var serviceProvider = GetServiceProvider(
                context,
                context.Global.RegistrationContainerName,
                storagePath: null);

            var registrationStorageFactories = serviceProvider.GetRequiredService <RegistrationStorageFactories>();

            var collector = new RegistrationCollector(
                catalogIndexUri,
                registrationStorageFactories.LegacyStorageFactory,
                registrationStorageFactories.SemVer2StorageFactory,
                context.Global.ContentBaseAddress,
                serviceProvider.GetRequiredService <ITelemetryService>(),
                () => serviceProvider.GetRequiredService <HttpMessageHandler>());

            await collector.RunAsync(CancellationToken.None);
        }