Skip to content

Conversation

@clintropolis
Copy link
Member

@clintropolis clintropolis commented Jul 10, 2025

Some improvements to the embedded test stuff from my experience writing test for #18176, which is a query oriented test.

The primary change is a new beforeStart method on EmbeddedResource interface, which allows them to perform additional operations when starting up (with access to the EmbeddedDruidCluster at this point, so shared resources are available).

I have added usage of this new functionality to clean up how druid service properties are set, specifically EmbeddedDruidService has a new addBeforeStart method that takes a function add to a list of things to call during its implementation of the new beforeStart method. With this, I've cleaned up the getStartupProperties method to just copy all the stuff from the map, and moved all of the previous logic into the beforeStart hooks (and the historical specific logic into the EmbeddedHistorical).

While i was here, I made the durable shuffle test re-use the same ingested data between runs instead of reingesting per test.

Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀
The startup properties flow seems nicer now.

public final EmbeddedDruidCluster addExtensions(Class<? extends DruidModule>... moduleClasses)
{
validateNotStarted();
extensionModules.addAll(Arrays.asList(moduleClasses));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: reads a little better

Suggested change
extensionModules.addAll(Arrays.asList(moduleClasses));
extensionModules.addAll(List.of(moduleClasses));

return (T) this;
}

public final T addBeforeStart(BeforeStart hook)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a short javadoc to this. It can just link to EmbeddedResource.beforeStart().

{
public EmbeddedHistorical()
{
super();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Is this explicit call needed?

return (T) this;
}

public final T addBeforeStart(BeforeStart hook)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: On the name, I feel we should either call it doBeforeStart or addBeforeStartHook.

logsDirectory,
storageDirectory
);
self.addProperty("druid.host", "localhost");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, did you run into any issue with this not being hardcoded here?

Copy link
Member Author

Choose a reason for hiding this comment

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

not currently, but i have had problems with stuff like this in the past so was proactively changing it. The problem i was running into was that some networks DNS services try to be "helpful" and redirect to a search page or the like, so what should be an unresolvable local network hostname ends up being a real address that is definitely not localhost when using InetAddress.getLocalHost().getCanonicalHostName().

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. That makes sense.
I am currently working on something where I think I might need the non-localhost hostname.
But I will see what I can do to avoid that requirement as it is cleaner to just have it be localhost.

/**
* Adds an extension to this cluster. The list of extensions is populated in
* the common property {@code druid.extensions.modulesForSimulation}.
* the common property {@code druid.extensions.modulesForEmbeddedTest}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this!

@kfaraz
Copy link
Contributor

kfaraz commented Jul 10, 2025

UT failure seems unrelated to the change here, @uds5501 is taking a look.

@clintropolis clintropolis merged commit 3413057 into apache:master Jul 11, 2025
76 checks passed
@clintropolis clintropolis deleted the embedded-test-query-enhancements branch July 11, 2025 01:45
@cecemei cecemei added this to the 35.0.0 milestone Oct 21, 2025
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