Repository navigation
test(verify): run the source operators, and report what is covered #8364
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
Draft
kz930
wants to merge
23
commits into
apache:main
Choose a base branch
from
kz930:feat/verify-sources-and-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f9f6877
test(verify): run the source operators, and report what is covered
kz930 59f7984
test(verify): move the per-operator spec here, where its callees alre…
kz930 c4bc40e
test(verify): keep the guard, drop the table it printed around it
kz930 2f66569
test(verify): say it once, in the shape the code does not already give
kz930 d2e44e4
test(verify): report an operator that writes to the frame it was handed
kz930 f3355ba
test(verify): read the accessor spellings of the same assignment
kz930 f66d6e5
test(verify): say what each of the two code-reading checks reaches
kz930 1ee3dd2
build(verify): bound the pool the operator sweep runs in
kz930 f8d0015
Revert "build(verify): bound the pool the operator sweep runs in"
kz930 cb6125c
test(verify): cut the doc to what the code cannot say
kz930 396d10e
Merge remote-tracking branch 'upstream/main' into feat/verify-sources…
kz930 cfcddaf
build: open the packages Kryo reaches once both halves run together
kz930 de34e86
test(verify): encode the canonical table as Parquet
kz930 556bbca
test(verify): hand the script the schemas the read produced
kz930 92e6713
test(verify): read each source through the cases a reader gets wrong
kz930 a0254b5
test(verify): read source timestamps past the millisecond, with an of…
kz930 33559af
Merge upstream/main into feat/verify-sources-and-coverage
kz930 2c5cd24
test(verify): write each CSV variant's fixture with its own delimiter
kz930 acb0cc9
test(verify): quote the CSV fixture's Unnamed header under any delimiter
kz930 41564e7
test(verify): fail the coverage guard on a must-run operator discover…
kz930 c64f749
test: read the files the drivers are handed as UTF-8
kz930 2235fa3
feat(verify): verify File Scan as a transform fed the shared table
kz930 7dbad1b
test(verify): name a source column like the variable a script binds
kz930 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
72 changes: 72 additions & 0 deletions
72
...service/src/test/scala/org/apache/texera/amber/translator/verify/ConfigCoverageSpec.scala
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.translator.verify | ||
|
|
||
| import org.apache.texera.amber.operator.LogicalOp | ||
| import org.scalatest.flatspec.AnyFlatSpec | ||
| import org.scalatest.matchers.should.Matchers | ||
|
|
||
| /** | ||
| * Holds the floor under what the harness can run. | ||
| * | ||
| * Every operator carrying standalone code is classified runnable or flagged, and | ||
| * a flag is how an operator stops being checked at all. For most that is a state | ||
| * someone is working through. For the ones below it would be a regression: they | ||
| * are the plainest operators the harness has, they take the shared table as it | ||
| * is, and nothing about them is hard to run. An operator arriving here means | ||
| * something upstream of the disposition broke rather than that this operator | ||
| * became difficult. | ||
| */ | ||
| class ConfigCoverageSpec extends AnyFlatSpec with Matchers { | ||
|
|
||
| private val mustRun = Set( | ||
| "IntersectOpDesc", | ||
| "DifferenceOpDesc", | ||
| "SymmetricDifferenceOpDesc", | ||
| "HashJoinOpDesc", | ||
| "SpecializedFilterOpDesc", | ||
| "SortOpDesc", | ||
| "LimitOpDesc" | ||
| ) | ||
|
|
||
| "the harness" should "keep runnable every operator it must be able to run" in { | ||
| val discovered = OperatorBehaviorSpec | ||
| .discoverStandaloneOperators() | ||
| .filter(opClass => mustRun.contains(opClass.getSimpleName)) | ||
| // Losing standalone support drops an operator from discovery, which would | ||
| // otherwise pass the runnable check below without it ever being asked. | ||
| val missing = mustRun -- discovered.map(_.getSimpleName) | ||
| withClue(s"must-run operators no longer discovered: $missing") { | ||
| missing shouldBe empty | ||
| } | ||
| val flagged = discovered.filterNot(runnable).map(_.getSimpleName) | ||
| withClue(s"must-run operators no longer runnable: $flagged") { | ||
| flagged shouldBe empty | ||
| } | ||
| } | ||
|
|
||
| private def runnable(opClass: Class[_ <: LogicalOp]): Boolean = | ||
| if (SourceCategoryRunner.runsAsSource(opClass)) | ||
| SourceCategoryRunner.canRun(opClass) | ||
| else | ||
| TransformVerificationRunner | ||
| .disposition(opClass) | ||
| .isInstanceOf[TransformVerificationRunner.Runnable] | ||
| } | ||
140 changes: 140 additions & 0 deletions
140
...rvice/src/test/scala/org/apache/texera/amber/translator/verify/OperatorBehaviorSpec.scala
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.texera.amber.translator.verify | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonSubTypes | ||
| import org.apache.texera.amber.operator.{LogicalOp, StandaloneCodeGenerator} | ||
| import org.apache.texera.amber.translator.verify.tags.IntegrationTest | ||
| import org.scalatest.ParallelTestExecution | ||
| import org.scalatest.flatspec.AnyFlatSpec | ||
| import org.scalatest.matchers.should.Matchers | ||
|
|
||
| /** | ||
| * A parity test per operator: every one registered in [[LogicalOp]]'s | ||
| * `@JsonSubTypes` that implements [[StandaloneCodeGenerator]] runs through the | ||
| * Texera executor and through its generated Python, and the two outputs are | ||
| * compared. Adding an operator needs no edit here. | ||
| * | ||
| * [[TransformVerificationRunner]] configures each non-source transform and | ||
| * decides whether it can run; sources go to [[SourceCategoryRunner]]. Every | ||
| * test's NAME carries its verdict, the tier that ran it or the reason it could | ||
| * not, so the report lists every operator and says what it did not check. | ||
| * | ||
| * Requires Python 3 with pandas on the [[Comparator]] / [[StandaloneRunner]] | ||
| * resolution chain (`UDF_PYTHON_PATH` env var, then `python3.12`). | ||
| */ | ||
| // Tagged @IntegrationTest: it forks Python, so CI routes it to the | ||
| // Python-provisioned integration job (see workflow-compiling-service/build.sbt | ||
| // WCS_TEST_FILTER). | ||
| @IntegrationTest | ||
| class OperatorBehaviorSpec extends AnyFlatSpec with Matchers with ParallelTestExecution { | ||
|
|
||
| // The test list is built at class construction, one test per operator. | ||
| OperatorBehaviorSpec.discoverStandaloneOperators().foreach { opClass => | ||
| val name = opClass.getSimpleName | ||
|
|
||
| if (!OperatorBehaviorSpec.isSelected(name)) { | ||
| // Only a local run sets those, and CI therefore runs the lot. | ||
| name should "NARROWED OUT — outside this run's VERIFY_ONLY / VERIFY_SKIP" ignore {} | ||
| } else if (SourceCategoryRunner.runsAsSource(opClass)) { | ||
| // A source has no input port, so its own runner writes the shared table | ||
| // into the file format each one reads. | ||
| if (SourceCategoryRunner.canRun(opClass)) { | ||
| name should "produce equivalent output in Texera and standalone Python (source)" in { | ||
| SourceCategoryRunner.run(opClass) | ||
| } | ||
| } else { | ||
| name should s"FLAGGED — ${SourceCategoryRunner.flagReason(opClass)}" ignore {} | ||
| } | ||
| } else { | ||
| TransformVerificationRunner.disposition(opClass) match { | ||
| case TransformVerificationRunner.Runnable(tier) => | ||
| name should s"produce equivalent output in Texera and standalone Python ($tier)" in { | ||
| TransformVerificationRunner.run(opClass) | ||
| } | ||
| case TransformVerificationRunner.Flagged(reason) => | ||
| // ConfigCoverageSpec aggregates these into its table. | ||
| name should s"FLAGGED — $reason" ignore {} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Not one test per operator like the rest of this spec: it is one assertion | ||
| // over all of them, and it deliberately ignores the selection knobs above so a | ||
| // VERIFY_ONLY run still cannot hide a broken splice site. | ||
| "Generated standalone code" should "stay parseable when the column names are hostile" in { | ||
| StandaloneEscapingCheck.run() shouldBe empty | ||
| } | ||
|
|
||
| // Also one assertion over all of them: a workflow that draws two charts from | ||
| // one upstream hands both the same variable, and only a plan with a branch | ||
| // ever notices an operator writing to it. | ||
| it should "leave the frame it was handed alone" in { | ||
| StandaloneInputCheck.run() shouldBe empty | ||
| } | ||
| } | ||
|
|
||
| object OperatorBehaviorSpec { | ||
|
|
||
| // Case-sensitive substrings of the operator's simple name, comma-separated. | ||
| // | ||
| // There is deliberately no third list withholding operators by default: a | ||
| // name here would withdraw an operator's every variant and record nothing | ||
| // about what is wrong with it. Withholding lives where it can say why, in | ||
| // [[TransformVerificationRunner]]'s `variantsNotRun` or its `knownIssues`. | ||
| private def patterns(envVar: String): Seq[String] = | ||
| sys.env.getOrElse(envVar, "").split(",").iterator.map(_.trim).filter(_.nonEmpty).toSeq | ||
|
|
||
| private lazy val onlyPatterns: Seq[String] = patterns("VERIFY_ONLY") | ||
| private lazy val skipPatterns: Seq[String] = patterns("VERIFY_SKIP") | ||
|
|
||
| /** True if `name` should run: in VERIFY_ONLY when that is set, and not in | ||
| * VERIFY_SKIP. True for everything when neither is set. | ||
| */ | ||
| def isSelected(name: String): Boolean = { | ||
| val included = onlyPatterns.isEmpty || onlyPatterns.exists(name.contains) | ||
| val excluded = skipPatterns.exists(name.contains) | ||
| included && !excluded | ||
| } | ||
|
|
||
| /** | ||
| * Enumerates every concrete subclass of [[LogicalOp]] declared in its | ||
| * `@JsonSubTypes` annotation, filters to those implementing | ||
| * [[StandaloneCodeGenerator]], and returns them sorted by simple name | ||
| * (stable test report order). | ||
| * | ||
| * Uses the same registry Jackson uses to deserialize operators — no | ||
| * separate discovery mechanism needed. Adding an operator to | ||
| * `LogicalOp.@JsonSubTypes` makes it visible here automatically. | ||
| */ | ||
| def discoverStandaloneOperators(): Seq[Class[_ <: LogicalOp]] = { | ||
| val annotation = classOf[LogicalOp].getAnnotation(classOf[JsonSubTypes]) | ||
| if (annotation == null) Seq.empty | ||
| else | ||
| annotation | ||
| .value() | ||
| .toSeq | ||
| .map(_.value()) | ||
| .filter(classOf[StandaloneCodeGenerator].isAssignableFrom) | ||
| .map(_.asInstanceOf[Class[_ <: LogicalOp]]) | ||
| .distinct | ||
| .sortBy(_.getSimpleName) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.