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

DBZ-8363 creation of single test artifact #136

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

smiklosovic
Copy link
Member

@smiklosovic smiklosovic commented Oct 29, 2024

@jpechane

This PR introduces a single test artifact which is made a dependency of each respective implementation module. By doing that, we run all tests (when not excluded programmatically) for each module while tests are written just once.

The solution uses ServiceLoader mechanism for loading bits which differ and tests load this and use it.

For review purposes, it is adviced if reviewers open the code in IDE to see what is going on here.

From development perspective, the workflow is that when a new test is being written, it would be written in respective module but upon commit, it would need to be moved into tests artifact. Upon development, a developer will very likely want to have a quick feedback loop and placing test into tests artifact means he is not able to test that individual test in IDE. Hence, a test would be developed in some module but it would be moved to tests upon commit. Another option is to run just one test via Maven "somehow" but a developer very likely wants to debug in IDE as well, hence the first approach is suggested.

If that test class is meant to be run just for a specific Cassandra version, it might stay in the implementation module instead of the tests module.

Copy link
Contributor

@jpechane jpechane left a comment

Choose a reason for hiding this comment

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

@smiklosovic Thanks a lot! I really like the approach. The only comments I do have relates to changes in CassandraConnectorConfig. If something new is intorduced there then there should be a separate Jira (enhancement) and separate commit for it. The new config options would need a documentation PR too.

public static final Field CASSANDRA_CLUSTER_NAME = Field.create("cassandra.cluster.name")
.withType(Type.STRING)
.withDescription("Name of Cassandra cluster.")
.withDefault("Test Cluster");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it was not necessary to override it before?

Copy link
Member Author

@smiklosovic smiklosovic Nov 4, 2024

Choose a reason for hiding this comment

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

@jpechane

It is used in production. In CassandraConnectorTaskTemplate in initProcessorGroup. Before that, there was deserializerProvider.getClusterName() at taskContext.getClusterName() place.

processorGroup.addProcessor(new SnapshotProcessor(taskContext, taskContext.getClusterName()));

Now if you think, about that, what the hell does CassandraTypeProvider have in common with name of the cluster? It was implemented like this:

    @Override
    public String getClusterName() {
        return DatabaseDescriptor.getClusterName();
    }

So, the only reason we put this into CassandraTypeProvider before was that we were trying to "hide" this somewhere so DatabaseDescriptor is on the class path and it is module specific. We could not put this into "core" because DatabaseDescriptor is not there (we are not depending on any specific Cassandra version there).

Cluster name should be fetched from CassandraConnectorContext. We have one implementation of the context - DefaultCassandraConnectorContext which is in core, in CassandraConnectorTaskTemplate. So we can not put there DatabaseDescriptor.getClusterName because that class is not in core. Hence I made a configuration property out of that.

The same logic holds for the other property but I see it is used in tests only so I will remove the other one but cluster name has to stay.

Copy link
Member Author

@smiklosovic smiklosovic Nov 4, 2024

Choose a reason for hiding this comment

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

I am not sure how to deliver this PR while we would not refactor the configuration option at the same time like here.

I would have to move changes in CassandraTypeProvider back (even they are pretty nonsensical) just for the sake of delivering this patch and then we would need to create yet another JIRA to fix it.

Is this what you indeed prefer me to do?

Copy link
Contributor

Choose a reason for hiding this comment

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

@smiklosovic We've also createInternal to create field definition. So it might be fine to use it and just add proper description.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jpechane I created https://issues.redhat.com/browse/DBZ-8373

I have removed it and put it back to CassandraTypeProvider even it does not make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jpechane ah, I noticed you comment just now ... I am not completely sure if createInternal is the right thing to do. It is not internal. I think that property (cluster name) which is used in SnapshotProcessor uses name of cluster internally etc so I think that property is really something a user should have a control over.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, lte me rephrase it. If it is something that user can and should use then let's keep it as is. I don't like the default value but it is apparently matching the one in driver so I am going to accept it.
BTW, there slight misunderstanding. I did not ask originally for the removal, just explanation.

Copy link
Member Author

@smiklosovic smiklosovic Nov 4, 2024

Choose a reason for hiding this comment

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

@jpechane I am fine to rework it in DBZ-8373 just to be more explicit about that. If it was delivered with this patch then it would be all burried in this big patch with all changes. Let's just deliver this as it is now and then we can refactor in the other one. That is totally fine to me.

@smiklosovic
Copy link
Member Author

@jpechane thank you for the feedback, I shall get back to this next week.

@smiklosovic smiklosovic force-pushed the DBZ-8363 branch 2 times, most recently from e9f9d9e to 4447f1e Compare November 4, 2024 09:40
@smiklosovic
Copy link
Member Author

not sure why the PR stopped to be built automatically

@jpechane
Copy link
Contributor

jpechane commented Nov 4, 2024

@smiklosovic I see it built

@jpechane jpechane merged commit 3cd89ef into debezium:main Nov 5, 2024
3 checks passed
@jpechane
Copy link
Contributor

jpechane commented Nov 5, 2024

@smiklosovic Deal done, applied. Thanks!

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.

2 participants