Skip to content

Conversation

@colings86
Copy link
Contributor

This adds test classes that can be used to test the wire serialisation and (optionally) the XContent serialisation of objects that implement Streamable/Writeable and ToXContent.

These test classes will enable classes such as InternalAggregation (or at least its implementations) to be tested in a consistent way when is comes to testing serialisation.

@colings86 colings86 added review >test Issues or PRs that are addressing/adding tests v5.1.2 v5.2.0 v6.0.0-alpha1 labels Dec 20, 2016
@colings86 colings86 self-assigned this Dec 20, 2016
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

I really wonder if we can have at least one user of those tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

this header is wrong

Copy link
Contributor

Choose a reason for hiding this comment

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

wrong header

Copy link
Contributor

Choose a reason for hiding this comment

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

why don't you make it random ie instead of this constant use randomIntBetween(1, 20)

Copy link
Contributor

Choose a reason for hiding this comment

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

will this work for all serialization classes? I mean queries need to be registered etc. I think we have to add all the ones we need for the subclass. So maybe add a factory method we can override?

Copy link
Contributor

Choose a reason for hiding this comment

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

you should run gradle precommit

Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Agreed with Simon it would help to have one user of this class. Also some protected abstract methods would benefit from having javadocs.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use assertEquals instead to have better error messages

Copy link
Contributor

Choose a reason for hiding this comment

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

can the docs give an example when it is useful to do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from AbstractQueryTestCase but actually I see that it's never used there. I'm not sure when this would be useful and I think we should avoid cases where the order of fields in a JSON object matters since keys in JSON objects are not guaranteed to be ordered so I'm going to remove this

@colings86
Copy link
Contributor Author

@s1monw @jpountz I pushed commits addressing your comments. I have implemented InternalMinTests which uses AbstractWireSerializingTestCase. I plan in a follow up PR to convert AbstractQueryTestCase and BaseAggregationTestCase to extend AbstractSerializingTestCase. Not sure if it's worth keeping the Streamable versions of the test cases since we want to move everything to use Writeable anyway?

@colings86
Copy link
Contributor Author

Also worth noting that because the test cases rely on hashCode and equals being implemented on the test class I had to add implementations to InternalAggregation and InternalNumericMetricAggregation which both declare methods that their subcleasses need to implement. In order to keep this PR mamageable and not require that I implemented hashCode and equals for all InternalAggregations subclasses I added a default implementation of those declared methods which use object identity, as well as adding a norelease comment to them stating that they should be made abstract when all the InternalAggregation subclasses implement the methods

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

I left a comment about the way equals/hashcode are implemented, otherwise LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add javadocs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like having both doEquals and innerEquals. Maybe just override equals to also include the format and still expect sub classes to implement doEquals? (Same for the hashcode)

This adds test classes that can be used to test the wire serialisation and (optionally) the XContent serialisation of objects that implement Streamable/Writeable and ToXContent.

These test classes will enable classes sich as InternalAggregation (or at least its implementations) to be tested in a consistent way when is comes to testsing serialisation.
@colings86
Copy link
Contributor Author

colings86 commented Dec 21, 2016

@jpountz I pushed a new commit addressing your latest comments. Could you give this another look?

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM

@colings86 colings86 merged commit 06576ed into elastic:master Dec 22, 2016
@colings86 colings86 deleted the test/addAbstractSerializingTestCase branch December 22, 2016 10:49
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Dec 22, 2016
* master: (22 commits)
  Support negative numbers in writeVLong (elastic#22314)
  UnicastZenPing's PingingRound should prevent opening connections after being closed
  Add task to clean idea build directory. Make cleanIdea task invoke it.
  add trace logging to UnicastZenPingTests.testResolveReuseExistingNodeConnections
  Adds ingest processor headers to exception for unknown processor. (elastic#22315)
  Remove much ceremony from parsing client yaml test suites (elastic#22311)
  Support numeric bounds with decimal parts for long/integer/short/byte datatypes (elastic#21972)
  inner hits: Don't inline inner hits if the query the inner hits is inlined into can't resolve mappings and ignore_unmapped has been set to true
  Fix stackoverflow error on InternalNumericMetricAggregation
  Date detection should not rely on a hardcoded set of characters. (elastic#22171)
  `value_type` is useful regardless of scripting. (elastic#22160)
  Improve concurrency of ShardCoreKeyMap. (elastic#22316)
  fixed jdocs and removed already fixed norelease
  Adds abstract test classes for serialisation (elastic#22281)
  Introduce translog no-op
  Provide helpful error message if a plugin exists
  Clear static variable after suite
  Repeated language analyzers (elastic#22240)
  Restore deprecation warning for invalid match_mapping_type values (elastic#22304)
  Make `-0` compare less than `+0` consistently. (elastic#22173)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>test Issues or PRs that are addressing/adding tests v6.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants