Skip to content
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

Move test code in respective projects #5330

Merged
merged 17 commits into from
Apr 17, 2024
Merged

Move test code in respective projects #5330

merged 17 commits into from
Apr 17, 2024

Conversation

RustedBones
Copy link
Contributor

@RustedBones RustedBones commented Apr 9, 2024

Splitting scio-test in sub modules

  • scio-test-core: depending on scio-core + some avro deps for pretty printing
  • scio-test-google-cloud-platform: depending on scio-test-core + GCP deps
  • scio-test-parquet: for future helpers

In order to use scio-test-core in scio-core/test scope, I created a symlink to the com.spotify.scio.testing package.

As most scio module test scope require test data, set the dependency on scio-core % "test->test" to get access to test helpers from scio-test-core

@RustedBones RustedBones force-pushed the scio-test-split branch 2 times, most recently from acc8175 to a7e31e4 Compare April 10, 2024 16:22
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 61.37%. Comparing base (6ebf9c4) to head (3c8f12c).
Report is 23 commits behind head on main.

❗ Current head 3c8f12c differs from pull request most recent head 1329726. Consider uploading reports for the commit 1329726 to get more accurate results

Files Patch % Lines
...c/main/scala/com/spotify/scio/testing/Pretty.scala 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5330      +/-   ##
==========================================
- Coverage   62.69%   61.37%   -1.32%     
==========================================
  Files         301      302       +1     
  Lines       10848    10818      -30     
  Branches      773      786      +13     
==========================================
- Hits         6801     6640     -161     
- Misses       4047     4178     +131     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -55 to -68
}, {
"type": "record",
"name": "TestRecord",
"namespace": "com.spotify.scio.avro",
"doc": "Record for testing",
"fields": [
{"name": "int_field", "type": ["null", "int"], "default": null},
{"name": "long_field", "type": ["null", "long"], "default": null},
{"name": "float_field", "type": ["null", "float"], "default": null},
{"name": "double_field", "type": ["null", "double"], "default": null},
{"name": "boolean_field", "type": ["null", "boolean"], "default": null},
{"name": "string_field", "type": ["null", "string"], "default": null},
{"name": "array_field", "type": {"type": "array", "items": "string"}, "default": null}
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one stayed in scio-core/test to test kryo for avro

Comment on lines -119 to -123
def getInput: String
def setInput(input: String): Unit
def getTestInput: String
def setTestInput(input: String): Unit
@Required
def getOutput: String
def setOutput(output: String): Unit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PipelineOptions are dynamically loaded, Some tests were failing because the --input and --output parameters were transformed into options instead of staying in the args. Renamed the values to avoid conflicts wit other tests

@@ -38,7 +39,7 @@ object AvroUtils {
.array()
.items()
.stringType()
.noDefault()
.arrayDefault(Collections.emptyList())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to match with the specific record

Comment on lines +49 to +56
// additional kryo registrar for avro schema null value
// deserializes null to the singleton instance for schema equality
@KryoRegistrar
class TestKryoRegistrar extends IKryoRegistrar {

override def apply(k: Kryo): Unit =
k.forClass[NullNode](new SingletonSerializer(NullNode.getInstance()))
}
Copy link
Contributor Author

@RustedBones RustedBones Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, this test suite was not run before.
This registrar is needed for the set so schema equality passes. Without this, kryo creates a new NullNode instance failing equality checks

@@ -65,8 +80,7 @@ class KryoAtomicCoderTest extends PipelineSpec {
Pair("record", 10) kryoCoderShould roundtrip()
}

// Enable once https://github.com/scala/scala/pull/10425 is release
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix is now live

Copy link
Contributor

@clairemcginty clairemcginty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is amazing! thanks for your hard work doing this refactor

libraryDependencies ++= Seq(
"com.google.api.grpc" % "proto-google-cloud-bigtable-v2" % googleCloudProtoBigTableVersion,
"com.google.http-client" % "google-http-client" % googleHttpClientVersion,
"com.google.http-client" % "google-http-client" % googleHttpClientVersion, // TODO should we have this here ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to move to google-cloud-platform test module?

Copy link
Contributor Author

@RustedBones RustedBones Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required by the Pretty module. Instead of using toString in the scio SCollection matchers, we rely on this with custom formatting for

  • avro
  • gson

Ideally we should use smth like the cat's Show typeclass so any etension can give its formatting. Kept as is to avoid breaking the test API.

val schema: Schema = AvroUtils.schema
implicit def coder: Coder[GenericRecord] = avroGenericRecordCoder(schema)

"AvroTap" should "support saveAsAvroFile with SpecificRecord" in withTempDir { dir =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt about moving the withTempDir functionality into scio-test-core? It seems to have a lot of usage both within Scio and within many pipeline projects. (doesn't have to be in this PR!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will expose this in a separate PR

@kellen
Copy link
Contributor

kellen commented Apr 12, 2024

Should we retarget this for 0.15?

@RustedBones
Copy link
Contributor Author

I think @clairemcginty wanted this to ship some test helpers sooner.
Here the mima sais is breaking because classes moved from one artifact to another. There should in practice be no breaking changes as scio-test depends on scio-test-core and scio-test-google-cloud-service containing the same classes as before.

@RustedBones
Copy link
Contributor Author

I can actually try to run mima on scio-test-core with scio-test artifact localy to make sure if I didn't overlooked something

@kellen
Copy link
Contributor

kellen commented Apr 12, 2024

Was thinking more for the ease of merging 0.15 later, but if there is an urgent need we can get it out sooner and just deal with the merge issues.

@RustedBones
Copy link
Contributor Author

This is the result of the binary compatibility check

[error] scio-test-core: Failed binary compatibility check against com.spotify:scio-test_2.13:0.14.3! Found 1 potential problems
[error]  * interface com.spotify.scio.testing.BigtableMatchers does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[MissingClassProblem]("com.spotify.scio.testing.BigtableMatchers")

which is expected because moved to scio-test-google-cloud-platform

@RustedBones RustedBones marked this pull request as ready for review April 15, 2024 13:38
@RustedBones RustedBones merged commit c15591d into main Apr 17, 2024
11 checks passed
@RustedBones RustedBones deleted the scio-test-split branch April 17, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants