-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating tests that depend on Published Cache from the old test project #11242
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…t, moves new test to where it should be.
…r pattern for models.
…rl-collision' into v9/task/published-cache-tests
…ache-tests # Conflicts: # src/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/StackQueueTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/ContentFinderByAliasWithDomainsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/ContentFinderByUrlWithDomainsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/DomainsAndCulturesTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/UrlRoutingTestBase.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/UrlsProviderWithDomainsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Core/Routing/UrlsWithNestedDomains.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/PublishedCache/ContentSerializationTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/PublishedCache/PublishedContentTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/PublishedCache/PublishedSnapshotServiceCollectionTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/PublishedCache/UrlRoutesTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Serialization/AutoInterningStringConverterTests.cs # src/Umbraco.Tests/Collections/StackQueueTests.cs # src/Umbraco.Tests/PublishedContent/ContentSerializationTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs # src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs # src/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs # src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs # src/Umbraco.Tests/Routing/UrlRoutesTests.cs # src/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs # src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs # src/Umbraco.Tests/Serialization/AutoInterningStringConverterTests.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/AutoPublishedContentType.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/ContentType2.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/ContentType2Sub.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/InternalPublishedPropertyWithLanguageVariants.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/PublishedContentStrong1.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/PublishedContentStrong1Sub.cs # tests/Umbraco.Tests.Common/TestHelpers/PublishedContent/PublishedContentStrong2.cs # tests/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs # tests/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs # tests/Umbraco.Tests/Collections/StackQueueTests.cs # tests/Umbraco.Tests/Issues/U9560.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/ContentXmlDto.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/DomainCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/BackgroundTaskRunner.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/BackgroundTaskRunnerOptions.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTask.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTaskRunner.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/ILatchedBackgroundTask.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/LatchedBackgroundTaskBase.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/TaskEventArgs.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/ThreadingTaskImmutable.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PreviewContent.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PreviewXmlDto.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMember.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMemberCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/PublishedSnapshot.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/RoutesCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/SafeXmlReaderWriter.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/UmbracoContextCache.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedProperty.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs # tests/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs # tests/Umbraco.Tests/Models/ContentXmlTest.cs # tests/Umbraco.Tests/Models/MediaXmlTest.cs # tests/Umbraco.Tests/Persistence/FaultHandling/ConnectionRetryTest.cs # tests/Umbraco.Tests/Persistence/Mappers/MapperTestBase.cs # tests/Umbraco.Tests/Persistence/NPocoTests/PetaPocoCachesTest.cs # tests/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs # tests/Umbraco.Tests/Plugins/PluginManagerTests.cs # tests/Umbraco.Tests/PublishedContent/ContentSerializationTests.cs # tests/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # tests/Umbraco.Tests/PublishedContent/NuCacheTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentExtensionTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs # tests/Umbraco.Tests/PublishedContent/PublishedContentTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs # tests/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs # tests/Umbraco.Tests/PublishedContent/RootNodeTests.cs # tests/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs # tests/Umbraco.Tests/PublishedContent/StronglyTypedModels/Home.cs # tests/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByIdTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByUrlAndTemplateTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByUrlTests.cs # tests/Umbraco.Tests/Routing/ContentFinderByUrlWithDomainsTests.cs # tests/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs # tests/Umbraco.Tests/Routing/GetContentUrlsTests.cs # tests/Umbraco.Tests/Routing/RouteTestExtensions.cs # tests/Umbraco.Tests/Routing/RoutesCacheTests.cs # tests/Umbraco.Tests/Routing/UrlProviderWithHideTopLevelNodeFromPathTests.cs # tests/Umbraco.Tests/Routing/UrlProviderWithoutHideTopLevelNodeFromPathTests.cs # tests/Umbraco.Tests/Routing/UrlRoutesTests.cs # tests/Umbraco.Tests/Routing/UrlRoutingTestBase.cs # tests/Umbraco.Tests/Routing/UrlsProviderWithDomainsTests.cs # tests/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs # tests/Umbraco.Tests/Scoping/PassThroughEventDispatcherTests.cs # tests/Umbraco.Tests/Scoping/ScopedXmlTests.cs # tests/Umbraco.Tests/Serialization/AutoInterningStringConverterTests.cs # tests/Umbraco.Tests/Services/Importing/Dictionary-Package.xml # tests/Umbraco.Tests/Services/TestWithSomeContentBase.cs # tests/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs # tests/Umbraco.Tests/TestHelpers/BaseWebTest.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/AuthenticateEverythingExtensions.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/AuthenticateEverythingMiddleware.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/SpecificAssemblyResolver.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivator.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/TestStartup.cs # tests/Umbraco.Tests/TestHelpers/ControllerTesting/TraceExceptionLogger.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedContent.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedEntity.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedMedia.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedMember.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedPropertyTypes.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedUser.cs # tests/Umbraco.Tests/TestHelpers/Entities/MockedUserGroup.cs # tests/Umbraco.Tests/TestHelpers/FakeHttpContextFactory.cs # tests/Umbraco.Tests/TestHelpers/Stubs/TestControllerFactory.cs # tests/Umbraco.Tests/TestHelpers/Stubs/TestExamineManager.cs # tests/Umbraco.Tests/TestHelpers/Stubs/TestLastChanceFinder.cs # tests/Umbraco.Tests/TestHelpers/Stubs/TestUserPasswordConfig.cs # tests/Umbraco.Tests/TestHelpers/TestHelper.cs # tests/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs # tests/Umbraco.Tests/TestHelpers/TestObjects.cs # tests/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs # tests/Umbraco.Tests/Testing/Objects/Accessors/NoHttpContextAccessor.cs # tests/Umbraco.Tests/Testing/Objects/TestDataSource.cs # tests/Umbraco.Tests/Testing/UmbracoTestBase.cs # tests/Umbraco.Tests/Web/HttpCookieExtensionsTests.cs # tests/Umbraco.Tests/Web/Mvc/ViewDataDictionaryExtensionTests.cs # tests/Umbraco.Tests/masterpages/site1/template2.master
bergmania
approved these changes
Oct 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are many tests that weren't ported to netcore due to their reliance on the published cache infrastructure. These tests primarily relied on the old XML cache implementation. These changes make it possible to translate the old XML structures into the 'nucache' Published Cache layer. This is all done in the Unit Tests project because it doesn't rely on integration tests, databases, etc...
The way this works is fairly simple:
TestNuCacheContentService
which is an implementation ofINuCacheContentService
used to populate nucache. This just takes a collection ofContentNodeKit
just like what would happen on startup when we create collections of these from either reading from the bplustree file or from the db.PublishedContentXmlAdapter.GetContentNodeKits
. This gets passed some XML and it outputsIEnumerable<ContentNodeKit>
. It also outputs a collection of ContentType and DataType that correspond with the XML data. These outputs are then also used to initialize the cache. An example of using this:ContentDataBuilder
createsContentData
to be used to populate aContentNodeKit
for nucache. This builder will dynamically update anyContentType
passed to theBuild
method based on the data being created in the builder. This helps save some code by not having to manually define all corresponding property types on the ContentType. This also allows for building up variant content data (the XML translator above does not support variant data because the Xml didn't support it).ContentNodeKitBuilder
: builds a ContentNodeKit for use with nucache. It has a bunch of methods but for the most part it's simpler to use the helper method:ContentNodeKitBuilder.CreateWithContent
which gets passed ContentData previously built. The data passed to the Path will dynamically set things like ParentId and Level, though those can be explicitly passed in too. Example (there's lots of examples in this PR):Completed:
Breaking changes
These need reviewing but mostly it's just that we had models that should be immutable and based on ctor injection but they weren't. Now they are, but this means binary breaking changes, though some of these may be internal which would be ok. It would be simple to unbreak them by just making the properties mutable again and having an empty ctor overload. But these models should really be immutable in future versions!
TODO
There's only a few more tests to port over:
With a little work the builder pattern for ContentNodeKit could probably be simplified further to make creating a nucache data source even easier.
Important!
I had to revert changes from #10845 for SiteDomainMapper + UrlProviderExtensions.
The changes in that PR break functionality and diverge from what is happening in v8. I've made a comment about this here: #10845 (comment)
I'm unsure if other parts of that PR break functionality but the SiteMapperChanges there break several of the tests that have been ported over such as nested domain tests, etc...
IMO I think the whole PR #10845 should be reverted and then re-investigated and also based on v8 because we haven't changed the logic there so if there's a bug, it will in theory also be in v8. And then whatever is fixed must be covered by these tests.
This PR
Next steps
Whenever migrating from v8 -> v9 make sure that you look at any new tests that have been written in the old test project, they will need to be manually moved.