Repository navigation
Add RavenDB index deployment tests and approve index definitions as deployed - #6133
Open
danielmarbach wants to merge 5 commits into
Open
danielmarbach wants to merge 5 commits into
danielmarbach wants to merge 5 commits into
Conversation
…letes GetInstance assigned the static field before the server was reachable and before the database setup finished, while the fast path returned it without taking the semaphore. A test running in parallel could use the server too early and fail with a connection refused error in its setup.
IndexDeployment sends all indexes of a persister in one call, so an index the server rejects blocks the deployment of every other index. These tests deploy each index on its own to a new database and check that it is in the Normal state and uses Lucene. The audit tests also query each index and check the analyzer the server stores for the full-text field. The tests come from the characterization tests in #6049. They use IndexDeployment.FindIndexes and DocumentStoreConventions.Create, which did not exist when that pull request was written.
The index definition approvals now deploy the indexes to a new database on the embedded server before they render the definitions. The approved text is what the server received, including a search engine that IndexDeployment sets on an index. The rendering adds the index type, the source type, compound fields, the archived data behavior, the reduce output index, and every field option the client serializes. IndexDefinitionTests replaces IndexDefinitionApprovals from #6013 in both RavenDB persistence test projects. Both tests share the renderer in TestHelper, so the audit approval covers the same properties as the primary one. The approved maps, reduces, and field options are the same as before. The tests come from the characterization tests in #6049.
The audit approval deployed to a database without a search engine setting, so IndexDeployment set Lucene on every index and the approved file carried that line on each of them. With the line always present, an index definition that starts to set its own search engine left the approved file unchanged, although RavenDB rebuilds such an index on a database that defaults to Lucene. The audit approval now deploys to a database created with the Lucene settings that DatabaseSetup uses, as the primary approval does. The indexes inherit the search engine, so a Configuration line in an approved file comes from the index definition itself.
…fails SharedEmbeddedServer left the server running when the connection or the database setup failed after the start. The server was not published, so every later caller tried to start it again and failed with "The server was already started", which hid the first error, and Stop did not dispose it. The server is now disposed when its setup fails, so the next caller starts a new one. ScratchDatabase and CleanDatabaseFixture dispose the document store when creating the database fails or deleting it throws. The audit index searches pass the test timeout token, so a stalled query ends with the test timeout.
This file contains hidden or 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
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.
This brings the RavenDB index tests from #6049 to master. #6049 is not being merged yet. Its tests cover two things master lacks: a check that each index deploys on its own, and an approval of the index definitions as deployed. Only tests, test helpers, and
docs/testing.mdchange.What changes
IndexDeploymentTestsin both RavenDB persistence test projects deploy each index on its own to a new database.IndexDeploymentsends all indexes of a persister in one call, so an index the server rejects blocks every other index. Each test checks that the index is in theNormalstate and uses Lucene. The audit tests also query each index and check the analyzer the server stores for the full-text field.IndexDefinitionTestsreplacesIndexDefinitionApprovalsfrom Approve RavenDB index definitions to catch changes that trigger a rebuild #6013 in both projects. The test deploys the indexes to a new database first and then approves the definitions, so the approved text is what a new installation deploys.TestHelper/IndexDefinitionTextstays the one renderer for both projects. It now also prints the index type, the source type, compound fields, the archived data behavior, and the reduce output index. It prints field options and additional assemblies as JSON, which adds the spatial bounds and the assembly usings that the earlier renderer left out.SharedEmbeddedServerpublishes the test server only after its setup completes, and disposes it when the setup fails.ScratchDatabaseandCleanDatabaseFixturedispose their document store when creating or deleting the database fails.The approved files contain the same index names, map and reduce text, and field options as the files they replace. The additions are the
TypeandSourceTypelines.Why the approvals deploy to a Lucene database
Both approvals deploy to a database created with the Lucene settings that
DatabaseSetupuses for new databases. The indexes inherit the search engine, soIndexDeploymentadds nothing, and aConfigurationline in an approved file can only come from the index definition.In #6049 the audit approval deployed to a database without a search engine setting.
IndexDeploymentthen set Lucene on every index, and the approved file carried that line on each of them. I tried what that hides: I setSearchEngineType = Lucenein one index definition per persister. The audit approval still passed. The primary approval, which already deployed to a Lucene database, failed with one newConfigurationline. The comment on rule 4 inIndexDeploymentsays RavenDB rebuilds an index when a search engine is added to its configuration. That applies also when the engine is the same. I did not test that rebuild against a server.The rules that set Lucene on an index keep their own tests in the audit
IndexSetupTests. The auditIndexDeploymentTestsstill deploy to a database without a setting and assert Lucene there.Differences from #6049
IndexDeployment.FindIndexesand the shared renderer. In Update RavenDB to 7.2.7 #6049 it had a fixed list of four indexes and rendered fewer properties than Approve RavenDB index definitions to catch changes that trigger a rebuild #6013 already did.IndexDeployment.FindIndexesreplacesPrimaryIndexes.cs. Master gainedFindIndexesafter Update RavenDB to 7.2.7 #6049 was written.DocumentStoreConventions.Create(), so a change to the conventions still fails the approval.The other characterization tests stay in #6049: expiration metadata, server JSON contracts, throughput time series, the Lucene and Corax query tests, server logging, and
MessagesViewIndexTests.Docs
docs/testing.md: updated. It namesIndexDefinitionTests, says why the approval deploys to a Lucene database, and describesIndexDeploymentTests.docs/decisions/2026-10-20-ravendb-index-search-engine-and-rebuilds.md: reviewed, no change. It describes an approval test that renders every index definition the persisters deploy, which still holds.docs/README.md: reviewed, no change. No canonical source was added or retired.Records consulted: #6049, #6013, the ADR above, and
docs/testing.md. Internal context was consulted and has no record on these tests.