Skip to content

Backport #791 and remove ambiguity in Cassandra and DSE versions in tests#805

Merged
tolbertam merged 2 commits into
3.0.xfrom
consistentTestVersioning
Feb 17, 2017
Merged

Backport #791 and remove ambiguity in Cassandra and DSE versions in tests#805
tolbertam merged 2 commits into
3.0.xfrom
consistentTestVersioning

Conversation

@tolbertam
Copy link
Copy Markdown
Contributor

Backports test changes from #791 and also removes ambiguity in Cassandra and DSE versions in tests (see b2e51ab for details).

If accepted, will need to make changes on each upstream branch as we go upwards. I've tested this change on all upstream branches and made the individual fixes, so I should be able to do that quickly when the time comes.

Motivation:

Many tests are failing when using recent versions of C* or DSE.

Modifications:

1) Bump the default C* version to 3.8
2) Redesign @CassandraVersion and @DseVersion to be able to fully accept
tick-tock releases and correctly compare them.
3) Reduce log verbosity for Scassandra tests
4) Prevent thrift from being enabled for C* >= 4.0
5) Fix decommission tests with C* >= 3.12

This commit contains contributions by Andrew Tolbert (@tolbertam).

Result:

All tests should pass.
Copy link
Copy Markdown
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

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

I love your ideas! I just wonder if we go down this path, why not go even further and distinguish DSE from C* from the very top of the stack, i.e. starting with system properties themselves (see my comment in the review).

private static final Logger logger = LoggerFactory.getLogger(CCMBridge.class);

private static final String CASSANDRA_VERSION;
private static final String INPUT_CASSANDRA_VERSION;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is actually only used in the static block below and could be turned into a local variable.


static {
CASSANDRA_VERSION = System.getProperty("cassandra.version");
INPUT_CASSANDRA_VERSION = System.getProperty("cassandra.version");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about distinguishing two different system properties for default versions to use: one for OSS C*, one for DSE?

One could e.g. specify that tests requiring DSE should by default use 5.0.3, but tests requiring OSS C* should rather use 3.10.

In this case, the dse system property is useless and the mapping from a DSE version to an OSS C* one should only be used when determining the corresponding C* version of a DSE version (which might be different than the "global" C* version).

I can give it a try myself if you don't mind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to change the existing system properties, I'll think on this for a bit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussion for system properties is on the consistentTestVersioning-adu branch didn't want to address that here.

private static final String CASSANDRA_VERSION;
private static final String INPUT_CASSANDRA_VERSION;

private static final VersionNumber CASSANDRA_VERSION_NUMBER;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about calling these constants GLOBAL_XXX to match their getter method names?

*
* @return The version of this CCM cluster.
*/
VersionNumber getDSEVersion();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure how much it makes sense to have a CCM cluster instance reporting two different versions. A CCMAccess is a bridge to either a DSE cluster or a C* cluster, not both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh my bad, I see it now, getCassandraVersion() is filled automatically with the corresponding C* version if this instance is a DSE cluster, correct? If so, please disregard my previous comment.

Copy link
Copy Markdown
Contributor Author

@tolbertam tolbertam Feb 15, 2017

Choose a reason for hiding this comment

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

👍 in the case the dse version is provided, the cassandra version is just the derived cassandra verson from dse for deriving test behavior based on that version. I'll update the comments to reflect that.

/**
* @return The desired target protocol version based on the 'cassandra.version' System property.
*/
ProtocolVersion getDesiredProtocolVersion();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: replace "desired" – its meaning is quite unclear here – with "target", e.g. getTargetProtocolVersion os even simply getProtocolVersion.
The javadocs need to be updated, here the returned version is the version that matches this specific instance, not the global system property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would describe it as the highest version common to the driver and the server, is that accurate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, that is the intent of this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see that the documentation doesn't completely reflect that, i'll fix that up:

 The target protocol version based on the 'cassandra.version' System property.


@Override
public ProtocolVersion getDesiredProtocolVersion() {
VersionNumber version = getCassandraVersion();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is only checking cassandra versions, shouldn't it be checking dse versions as well? Anyway as per my previous comment I think a single CCMBridge instance should carry only one version, and a boolean flag to indicate if it is a DSE cluster or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For now the Cassandra version (which is the compatible cassandra version when DSE version is provided) is adequate for determining the protocol version.

*/
public Builder withoutDSE() {
this.isDSE = false;
public Builder withCassandraVersion(VersionNumber versionNumber) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, not sure this makes sense, since withCassandraVersion and withDSEVersion are mutually exclusive (see assertions) why not keep just one method withVersion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, reverting this back as it isn't necessary in this particular case.

@tolbertam tolbertam closed this Feb 15, 2017
@tolbertam tolbertam deleted the consistentTestVersioning branch February 15, 2017 21:19
@tolbertam
Copy link
Copy Markdown
Contributor Author

woops, didn't mean to delete this 🤦‍♂️

@tolbertam tolbertam reopened this Feb 15, 2017
Copy link
Copy Markdown
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

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

Looks great, only minor remarks 👍

@Override
@SuppressWarnings("SimplifiableIfStatement")
public boolean equals(Object o) {
// do not include cluster name and start, only
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should keep the comment about cluster name because indeed a cluster name is unique, but two CCM instances should still be considered equal if their characteristics are identical. As for the start property, I am not sure anymore, but I think we can include it the computation of equals() and hashcode().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch will fix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hrmm it doesn't look like cluster name is even part of the builder anymore since this is randomly generated, so maybe that comment isn't relevant anymore?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah right, silly me :)

/**
* Helper for generating a DynamicCompositeType {@link ByteBuffer} from the given parameters.
*
* <p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is minor but I think the convention is to use <p/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch, IntelliJ's autoformatter behaves differently between when you have JDK 8 configured and otherwise. For some reason with JDK 8 it omits /. I'll fix it.

Motivation:

Originally CCMBridge was developed targeting running Apache Cassandra
clusters using CCM.  Over time this has changed to also work with
DataStax Enterprise.  There are some cases where there was ambiguity
with regards to whether the DSE or Cassandra version was used.  This
attempts to fix this.

Also, there were some places where the globally configured Cassandra/DSE
version was used (passed in via -Dcassandra.version) instead of a
locally configured one for a particular test.  This commit also fixes
this.

In Addition, TestUtils.getDesiredProtocolVersion was made available to
determine the ProtocolVersion to use based on the globally configured
Cassandra version.   This functionality has been moved to CCMAccess, so
one can get the ProtocolVersion tied to the version of Cassandra used
scoped to the test.

Finally, update default cassandra.version used in tests to 3.10.

Modifications:

Break out CCMAccess.getVersion() into two methods,
CCMAccess.getCassandraVersion() and CCMAccess.getDSEVersion().  If DSE
is not configured getDSEVersion() returns null, if it is configured
getCassandraVersion() returns the mapped version of Cassandra from DSE.

Move TestUtils.getDesiredProtocolVersion to CCMAccess.

Rename CCMBridge.CASSANDRA_VERSION to CCMBridge.INPUT_CASSANDRA_VERSION.
Add CCMBridge.CASSANDRA_VERSION_NUMBER and CCMBridge.DSE_VERSION_NUMBER.

Rename CCMBridge.getCassandraVersion() and getDSEVersion() to
CCMBridge.getGlobalCassandraVersion() and
CCMBridge.getGlobalDSEVersion().  These methods return VersionNumber
instead of String.

Result:

Ambiguity removed between Cassandra and DSE versions.  Annotations that
call out CCM remain unchanged.
@tolbertam tolbertam force-pushed the consistentTestVersioning branch from 9a61173 to 202770e Compare February 17, 2017 17:11
@tolbertam
Copy link
Copy Markdown
Contributor Author

tolbertam commented Feb 17, 2017

Squashed the Additional Feedback commits into 202770e, will merge this later today (will let it run through CI for an additional sanity check).

@tolbertam tolbertam merged commit a7044d5 into 3.0.x Feb 17, 2017
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