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

Change cloud test hierarchy, introduce cloud test base #16232

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

travisdowns
Copy link
Member

@travisdowns travisdowns commented Jan 23, 2024

This change changes a bit the inheritance structure of the
RedpandaService tree, and introduces the RedpandaCloudTest.

On the service side, we split RedpandaServiceCloud out so that it is
not a subclass of Service (as it does not use Service nodes nor have
a typical Service lifecycle). It shares some common interface with
RedpandaService but this is currently much smaller than the existing
RedpandaServiceBase.

RedpandaCloudTest is the base class for tests which run in the cloud,
analagous to RedpandaTest for tests which run in vanilla environments.
It automatically creates a RedpandaServiceCloud as the .redpanda
property, giving you type safe access to only the methods which make
sense in the cloud.

Issue https://github.com/redpanda-data/core-internal/issues/1002.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

  • none

@travisdowns travisdowns changed the title Td rptest refactor cloud Change cloud test hierarchy, introduce cloud test base Jan 23, 2024
@travisdowns
Copy link
Member Author

travisdowns commented Jan 23, 2024

@simonlord I put you on here more as an FYI, as you wrote SimpleSelfTest which had a little modification. Currently SimpleSelfTest is the only example I know of which runs both in cloud and non-cloud envs, but I feel free to skip this review entirely.

@vbotbuildovich

This comment was marked as resolved.

A bit of additional typing prior to messing around with
RedpandaServiceCloud.
This change changes a bit the inheritance structure of the
RedpandaService tree, and introduces the RedpandaCloudTest.

On the service side, we split RedpandaServiceCloud out so that it is
not a subclass of Service (as it does no use Service nodes or have
a typical Service lifecycle). It shares some common interface with
RedpandaService but this is currently much smaller than the existing
RedpandaServiceBase.

RedpandaCloudTest is the base class for tests which run in the cloud,
analagous to RedpandaTest for tests which run in vanilla environments.
It automatically creates a RedpandaServiceCloud as the .redpanda
property, giving you type safe access to only the methods which make
sense in the cloud.

Issue redpanda-data/core-internal#1002.
@travisdowns
Copy link
Member Author

Rebase (+fix error in new KubectlSelfTest): 4f2a82b

nvartolomei
nvartolomei previously approved these changes Jan 24, 2024
self._check_attr('context', TestContext)
self._check_attr('logger', Logger)

def healthy(self) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

why this is not an @abstractmethod too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, it's because cloud service does not implement this yet (we have a bug for it). In any case, we don't need this in the ABC as we don't use it elsewhere in the ABC, so I have removed it.

f'num_brokers is {num_brokers}, but setting to None for cloud')
# we save the test context under both names since RedpandaService and Service
# save them under these two names, respetively
self.context = self._context = context
Copy link
Contributor

Choose a reason for hiding this comment

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

why not make RedpandaServiceABC accept these via __init__ and pass them via super().__init__ instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's possible, but is there much of a concrete benefit? This ABC appears in a hierarchy which always provides a .context member. This is also how the KubeServiceMixin behaves, and similarly any other mixin we may add in the future, I guess.

If we pass it, we will need to store it, I guess in self.__context to make it class-private to avoid clobbering the context var from other classes. The behavior of the constructors for the Service hierarchy is not totally straightforward since on the other flavor (RedpandaService) we inherit from Service which isn't really a cooperating base class and wants context as the first positional argument. So run into the mixin/multiple inheritance issue where you need to avoid passing context to a base that doesn't expect it. object doesn't expect it, for example. So you need to then pass context twice from RedpandaService: once as the first positional argument to be consumed (eventually) by Service and once under some other name to be consumed by RedpandaServiceABC.

All for little gain I think. The mixin pattern mostly hides the types from the type-checker anyway (as we are often forwarding **kwargs, essentially erasing the types), which I think is the main benefit of passing it.

Other options are possible, e.g., the ABC could declare an abstract method or property returning a context which the bases would have to implement. This bypasses the constructor.

Despite this wall of text, I'm not convinced one way or the other, so interested to hear your thoughts too.

from RedpandaServiceABC, as it wasn't implemented on the cloud side nor
did we use it in the ABC, so remove it.

Issue redpanda-data/core-internal#1002.
Copy link
Member

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

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

LGTM

i didn't go line-by-line, but from our htt discussions, i agree with this PR and the principle behind the changes, especially:

On the service side, we split RedpandaServiceCloud out so that it is
not a subclass of Service (as it does not use Service nodes nor have
a typical Service lifecycle).

@travisdowns travisdowns merged commit ed56bc8 into redpanda-data:dev Jan 30, 2024
17 checks passed
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.

None yet

4 participants