Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions audits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,9 @@ deletes the legacy fixture directory and records the move in `audits/catalog/fix
Run it before editing the legacy test, because it records the bound method's body digest; then move
the body into the named test, move the fixture's declaration in `form-review.json` from
`declarations` to `migrated` (it keeps pinning the source, and the ledger's copy must match it), and
regenerate `example-bindings.json`, the repair inventory and the form report. `convert <root> <revision> <fixture>` converts a `testPipeline` case with an exact accepted override
in place: its legacy fixture files are replaced by the scenario, its unchanged test runs through the
regenerate `example-bindings.json`, the repair inventory and the form report. `convert <root> <revision> <fixture>` converts a `testPipeline` case with an accepted override (its
declared form rules travel with the scenario; retypes, corrections and alternative commands are not
supported yet) in place: its legacy fixture files are replaced by the scenario, its unchanged test runs through the
runner's compatibility adapter, and the ledger records the move (kind `CONVERTED`, with the legacy
body text). Move its declaration to `migrated` as for `migrate`.

Expand Down
2 changes: 1 addition & 1 deletion audits/catalog/curated-repairs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7969,7 +7969,7 @@
"folder" : "aggregation/stages/shardedDataDistribution",
"reason" : "an admin function and not generally suited for morphia"
} ],
"repositoryRevision" : "24d39a8da7a73e1a2535cb6796911812223d904f",
"repositoryRevision" : "70fde7825fcaa6f09efde4cab59b09318dfe6ee6",
"schemaVersion" : 1,
"summary" : {
"assertion.BEHAVIOR" : 465,
Expand Down
72 changes: 72 additions & 0 deletions audits/catalog/fixture-migration.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
{
"migrations" : [ {
"files" : {
"action.json" : "5fdbbe45d012f52390c69aad293ba52ec62233c1bc68de6474ce18d98ccfc2f6",
"data.json" : "02426b96130e602fe499e5facd289d6034d67a41bb9f51aa214cefa15907806e",
"expected.json" : "15f55e0bd596ae038967567cc42de49868748c317582050906a2a1757b0e8f92",
"lock" : "fd98b0ba84e5fbdeca45e858c631317602ece197b444b671a8cd4240b93cc532",
"name" : "0d6e4079e36703ebd37c00722f5891d28b0e2811dc114b129215123adcce3605"
},
"fixture" : "aggregation/expressions/cond/condExpressionOperator",
"kind" : "CONVERTED",
"legacyBody" : "{\n testPipeline(aggregation -> aggregation\n .pipeline(project().include(\"item\").include(\"discount\", condition(gte(\"$qty\", 250), 30, 20))));\n\n }",
"legacyBodySha256" : "bbadedc5ee76f1ad69f74e87cd57eab278d67a4a9b47029546c3275489dab556",
"legacyMethod" : "testCondExpressionOperator",
"legacyType" : "dev.morphia.test.aggregation.expressions.TestCond",
"ordered" : true,
"override" : {
"blocks" : [ {
"role" : "ACTION",
"sha256" : "f289394396ce7e30e0b85586f77b6f04e741c0aee8840d7ab42f9b663128574e",
"text" : "db.inventory.aggregate(\n [\n {\n $project:\n {\n item: 1,\n discount:\n {\n $cond: { if: { $gte: [ \"$qty\", 250 ] }, then: 30, else: 20 }\n }\n }\n }\n ]\n)"
}, {
"role" : "DATA",
"sha256" : "02426b96130e602fe499e5facd289d6034d67a41bb9f51aa214cefa15907806e",
"text" : "{ \"_id\" : 1, \"item\" : \"abc1\", qty: 300 }\n{ \"_id\" : 2, \"item\" : \"abc2\", qty: 200 }\n{ \"_id\" : 3, \"item\" : \"xyz1\", qty: 250 }"
}, {
"role" : "EXPECTED",
"sha256" : "15f55e0bd596ae038967567cc42de49868748c317582050906a2a1757b0e8f92",
"text" : "{ \"_id\" : 1, \"item\" : \"abc1\", \"discount\" : 30 }\n{ \"_id\" : 2, \"item\" : \"abc2\", \"discount\" : 20 }\n{ \"_id\" : 3, \"item\" : \"xyz1\", \"discount\" : 30 }"
} ],
"collections" : { },
"corrections" : [ ],
"example" : "main",
"fixture" : "aggregation/expressions/cond/condExpressionOperator",
"fixtureFiles" : {
"action.json" : "5fdbbe45d012f52390c69aad293ba52ec62233c1bc68de6474ce18d98ccfc2f6",
"data.json" : "02426b96130e602fe499e5facd289d6034d67a41bb9f51aa214cefa15907806e",
"expected.json" : "15f55e0bd596ae038967567cc42de49868748c317582050906a2a1757b0e8f92",
"name" : "0d6e4079e36703ebd37c00722f5891d28b0e2811dc114b129215123adcce3605"
},
"includes" : [ {
"blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa",
"path" : "source/includes/fact-compatibility.rst"
}, {
"blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4",
"path" : "source/includes/fact-environments.rst"
}, {
"blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f",
"path" : "source/includes/fact-environments-atlas-only.rst"
}, {
"blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476",
"path" : "source/includes/fact-environments-onprem-only.rst"
} ],
"origin" : "948049a3364491f4905246224922d2dbb4197154",
"pageBlob" : "914125372599704f56defd0ab1a9776d921d2fe5",
"retiredLock" : {
"name" : "lock",
"sha256" : "fd98b0ba84e5fbdeca45e858c631317602ece197b444b671a8cd4240b93cc532",
"text" : "morphia generates the more succinct array version vs the document version from the docs"
},
"retypes" : [ ],
"rules" : [ "COND_ARRAY" ],
"shape" : "PIPELINE",
"source" : {
"commit" : "9005b68f8945b96e78e9f10adcec016616681cfb",
"path" : "source/reference/operator/aggregation/cond.txt",
"relation" : "AT_ORIGIN"
},
"unexpandedIncludes" : [ ]
},
"scenario" : "core/src/test/resources/dev/morphia/test/aggregation/expressions/cond/condExpressionOperator/scenario.json",
"scenarioSha256" : "9627b77e4649c4391067edb6f2a81ef987735807885784502949c255813279e9",
"test" : "dev.morphia.test.aggregation.expressions.TestCond#testCondExpressionOperator"
}, {
"files" : {
"action.json" : "d021d059fcb4c579e318b3b18c4b2741f0f7ac93716ad642a485e9c71ec06fbb",
"data.json" : "669ec93b0aaf5f20eb39340618bbdb152ed0b1b8c411d33c8e2a57a6588f3f6d",
Expand Down
59 changes: 3 additions & 56 deletions audits/catalog/form-migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,59 +460,6 @@
"relation" : "AT_ORIGIN"
},
"unexpandedIncludes" : [ ]
}, {
"blocks" : [ {
"role" : "ACTION",
"sha256" : "f289394396ce7e30e0b85586f77b6f04e741c0aee8840d7ab42f9b663128574e",
"text" : "db.inventory.aggregate(\n [\n {\n $project:\n {\n item: 1,\n discount:\n {\n $cond: { if: { $gte: [ \"$qty\", 250 ] }, then: 30, else: 20 }\n }\n }\n }\n ]\n)"
}, {
"role" : "DATA",
"sha256" : "02426b96130e602fe499e5facd289d6034d67a41bb9f51aa214cefa15907806e",
"text" : "{ \"_id\" : 1, \"item\" : \"abc1\", qty: 300 }\n{ \"_id\" : 2, \"item\" : \"abc2\", qty: 200 }\n{ \"_id\" : 3, \"item\" : \"xyz1\", qty: 250 }"
}, {
"role" : "EXPECTED",
"sha256" : "15f55e0bd596ae038967567cc42de49868748c317582050906a2a1757b0e8f92",
"text" : "{ \"_id\" : 1, \"item\" : \"abc1\", \"discount\" : 30 }\n{ \"_id\" : 2, \"item\" : \"abc2\", \"discount\" : 20 }\n{ \"_id\" : 3, \"item\" : \"xyz1\", \"discount\" : 30 }"
} ],
"collections" : { },
"corrections" : [ ],
"example" : "main",
"fixture" : "aggregation/expressions/cond/condExpressionOperator",
"fixtureFiles" : {
"action.json" : "5fdbbe45d012f52390c69aad293ba52ec62233c1bc68de6474ce18d98ccfc2f6",
"data.json" : "02426b96130e602fe499e5facd289d6034d67a41bb9f51aa214cefa15907806e",
"expected.json" : "15f55e0bd596ae038967567cc42de49868748c317582050906a2a1757b0e8f92",
"name" : "0d6e4079e36703ebd37c00722f5891d28b0e2811dc114b129215123adcce3605"
},
"includes" : [ {
"blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa",
"path" : "source/includes/fact-compatibility.rst"
}, {
"blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4",
"path" : "source/includes/fact-environments.rst"
}, {
"blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f",
"path" : "source/includes/fact-environments-atlas-only.rst"
}, {
"blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476",
"path" : "source/includes/fact-environments-onprem-only.rst"
} ],
"origin" : "948049a3364491f4905246224922d2dbb4197154",
"pageBlob" : "914125372599704f56defd0ab1a9776d921d2fe5",
"retiredLock" : {
"name" : "lock",
"sha256" : "fd98b0ba84e5fbdeca45e858c631317602ece197b444b671a8cd4240b93cc532",
"text" : "morphia generates the more succinct array version vs the document version from the docs"
},
"retypes" : [ ],
"rules" : [ "COND_ARRAY" ],
"shape" : "PIPELINE",
"source" : {
"commit" : "9005b68f8945b96e78e9f10adcec016616681cfb",
"path" : "source/reference/operator/aggregation/cond.txt",
"relation" : "AT_ORIGIN"
},
"unexpandedIncludes" : [ ]
}, {
"blocks" : [ {
"role" : "ACTION",
Expand Down Expand Up @@ -7089,7 +7036,7 @@
},
"unexpandedIncludes" : [ ]
} ],
"repositoryRevision" : "24d39a8da7a73e1a2535cb6796911812223d904f",
"repositoryRevision" : "70fde7825fcaa6f09efde4cab59b09318dfe6ee6",
"rules" : [ {
"description" : "$cond: {if: a, then: b, else: c} and $cond: [a, b, c] are the same expression; the array form is canonical.",
"rule" : "COND_ARRAY"
Expand Down Expand Up @@ -7130,12 +7077,12 @@
"gap.REJECTED" : 1,
"gap.RESIDUAL_DIFFERENCE" : 48,
"gap.SOURCE_UNSUPPORTED" : 34,
"overrides" : 136,
"overrides" : 135,
"overrides.corrected" : 20,
"overrides.exact" : 55,
"overrides.retyped" : 16,
"rule.ALTERNATIVE_COMMANDS" : 1,
"rule.COND_ARRAY" : 14,
"rule.COND_ARRAY" : 13,
"rule.EQ_SHORTHAND" : 4,
"rule.FIELD_OPERATORS_AND" : 1,
"rule.NAMED_ARGUMENTS" : 14,
Expand Down
56 changes: 28 additions & 28 deletions audits/catalog/form-review.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,34 +210,6 @@
"path" : "source/reference/operator/aggregation/cmp.txt",
"relation" : "AT_ORIGIN"
}
}, {
"corrections" : [ ],
"fixture" : "aggregation/expressions/cond/condExpressionOperator",
"includes" : [ {
"blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa",
"path" : "source/includes/fact-compatibility.rst"
}, {
"blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4",
"path" : "source/includes/fact-environments.rst"
}, {
"blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f",
"path" : "source/includes/fact-environments-atlas-only.rst"
}, {
"blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476",
"path" : "source/includes/fact-environments-onprem-only.rst"
} ],
"justification" : null,
"lock" : "morphia generates the more succinct array version vs the document version from the docs",
"marker" : "lock",
"origin" : "948049a3364491f4905246224922d2dbb4197154",
"pageBlob" : "914125372599704f56defd0ab1a9776d921d2fe5",
"retypes" : [ ],
"rules" : [ "COND_ARRAY" ],
"source" : {
"commit" : "9005b68f8945b96e78e9f10adcec016616681cfb",
"path" : "source/reference/operator/aggregation/cond.txt",
"relation" : "AT_ORIGIN"
}
}, {
"corrections" : [ ],
"fixture" : "aggregation/expressions/cosh/hyperbolicCosineInDegrees",
Expand Down Expand Up @@ -3722,6 +3694,34 @@
}
} ],
"migrated" : [ {
"corrections" : [ ],
"fixture" : "aggregation/expressions/cond/condExpressionOperator",
"includes" : [ {
"blob" : "a140ad76120c4e6b1b54a9596dddb4c5d1dcb6fa",
"path" : "source/includes/fact-compatibility.rst"
}, {
"blob" : "af0e90475267dcf0a4b56e11aae76eeee3805ee4",
"path" : "source/includes/fact-environments.rst"
}, {
"blob" : "b770b45bc50f47b7b5d8cd771754c17a113b364f",
"path" : "source/includes/fact-environments-atlas-only.rst"
}, {
"blob" : "a7fa92b7a8083b9a17700e67517a1831f359c476",
"path" : "source/includes/fact-environments-onprem-only.rst"
} ],
"justification" : null,
"lock" : "morphia generates the more succinct array version vs the document version from the docs",
"marker" : "lock",
"origin" : "948049a3364491f4905246224922d2dbb4197154",
"pageBlob" : "914125372599704f56defd0ab1a9776d921d2fe5",
"retypes" : [ ],
"rules" : [ "COND_ARRAY" ],
"source" : {
"commit" : "9005b68f8945b96e78e9f10adcec016616681cfb",
"path" : "source/reference/operator/aggregation/cond.txt",
"relation" : "AT_ORIGIN"
}
}, {
"corrections" : [ ],
"fixture" : "aggregation/expressions/round/roundExpressionOperator",
"includes" : [ ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object FixtureMigration {
"comparison",
BsonDocument()
.append("order", BsonString(if (ordered) "ORDERED" else "UNORDERED"))
.append("rules", BsonArray())
.append("rules", BsonArray(override.rules.map { BsonString(it.name) }))
.append("ignore", BsonArray())
.append("tolerance", BsonNull.VALUE),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,19 @@ object FormMigration {
}

/**
* The documented operation an exact override (no rules, retypes, corrections or extra
* collections) was proven against, read from its recorded source text.
* The documented operation an override was proven against, read from its recorded source text.
* Its declared rules travel with it to the runner; retypes, corrections, extra collections and
* alternative commands are not supported yet.
*/
fun documented(override: FormOverride): DocumentedScenario {
require(
override.rules.isEmpty() &&
FormRule.ALTERNATIVE_COMMANDS !in override.rules &&
override.retypes.isEmpty() &&
override.corrections.isEmpty() &&
override.collections.isEmpty()
) {
"${override.fixture}: only exact single-collection overrides are supported"
"${override.fixture}: only single-collection overrides without retypes, corrections " +
"or alternative commands are supported"
}
override.blocks.forEach {
require(sha256(it.text.toByteArray()) == it.sha256) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.morphia.audits.offline
import dev.morphia.audits.coverage.AuditJson
import dev.morphia.audits.repairs.CaseManifests
import dev.morphia.audits.repairs.FixtureMigration
import dev.morphia.audits.repairs.FormRule
import dev.morphia.audits.repairs.MIGRATED
import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -127,11 +128,25 @@ class FixtureMigrationTest {
}

@Test
fun onlyExactOverridesCanBeMigrated() {
fun overridesWithRetypesOrCorrectionsCannotBeMigratedYet() {
val form = AuditJson.formMigration(read("audits/catalog/form-migration.json"))
val withRules = form.overrides.first { it.rules.isNotEmpty() }
assertThrows(IllegalArgumentException::class.java) {
FixtureMigration.scenario(withRules, false)
}
listOf(
form.overrides.first { it.retypes.isNotEmpty() },
form.overrides.first { it.corrections.isNotEmpty() },
)
.forEach {
assertThrows(IllegalArgumentException::class.java) {
FixtureMigration.scenario(it, true)
}
}
// Declared rules travel with the scenario.
val withRules =
form.overrides.first {
it.rules == listOf(FormRule.COND_ARRAY) &&
it.retypes.isEmpty() &&
it.corrections.isEmpty() &&
it.collections.isEmpty()
}
assertTrue("\"COND_ARRAY\"" in FixtureMigration.scenario(withRules, true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ class FormMigrationTest {
.map { it.fixture }
.toSet(),
)
assertEquals(136, report.overrides.size)
assertEquals(135, report.overrides.size)
assertEquals(96, report.unresolved.size)
}
}
Loading