Skip to content

Attempt to make crate-testing work under windows#92

Open
mackerl wants to merge 1 commit into
crate:masterfrom
mackerl:master
Open

Attempt to make crate-testing work under windows#92
mackerl wants to merge 1 commit into
crate:masterfrom
mackerl:master

Conversation

@mackerl
Copy link
Copy Markdown
Contributor

@mackerl mackerl commented Nov 21, 2025

  • handle child process exits
  • handle temporary file locks
  • different urls for windows and linux
  • upgrade cratedb tested version as 3.x is not released as zip
  • no latest test as there is no latest download link for windows
  • TODO: few fixes left, but don't know how at the moment
  • TODO: cannot upload large files in src/test/resources - locally I had there the 6.1.1 for windows and not windows

Summary of the changes / Why this is an improvement

Checklist

  • Link to issue this PR refers to (if applicable): Fixes #???

* handle child process exits
* handle temporary file locks
* different urls for windows and linux
* upgrade cratedb tested version as 3.x is not released as zip
* no latest test as there is no latest download link for windows
* TODO: few fixes left, but don't know how at the moment
@mackerl
Copy link
Copy Markdown
Contributor Author

mackerl commented Nov 21, 2025

I came quite far with supporting windows, altough its a pain :) (files access, child processes ...)
However now I face some limitations ... I cannot upload huge zips, tar.gz to fork in lfs mode as I am not the branch owner
I failed to fix some tests as I lack there knowledge whats happening in crate.

@amotl
Copy link
Copy Markdown
Member

amotl commented Nov 21, 2025

I came quite far with supporting windows, altough its a pain :) (files access, child processes ...)

Hi Mario. Thanks a stack for your contribution. I experienced similar pains like you when trying to manage the CrateDB process lifecycle on Windows the other day in Python lands at mfussenegger/cr8#337. 1

Footnotes

  1. In order not to hijack the discussion on this PR, I've elaborated about it in Support for testing on Windows #93, also to explore the problem domain beyond crate-java-testing, looking at potential solutions around using container technologies instead of manual process management.

@matriv
Copy link
Copy Markdown
Contributor

matriv commented Nov 25, 2025

Thx @mackerl I will take a look in the next days.

@matriv matriv self-assigned this Nov 25, 2025
@matriv
Copy link
Copy Markdown
Contributor

matriv commented Mar 17, 2026

Hi @mackerl, thanks a lot for your effort here!

I've been trying to make it work based on your changes but I haven't been able so far.
I'm experiencing errors for locked files when trying to start a crate server, therefore seems to be that some previous crate server process is not shutdown, which I verified, since I killed my intellij and any gradle processes and I still can see java processes in windows task manager. Maybe we should try to use https://junit.org/junit4/javadoc/4.12/org/junit/rules/TemporaryFolder.html to be sure that things are deleted after each test case. Moreover, we definitely need to find out why processes are not killed, maybe we need to have the logic of try/finally on each test case to make sure that crate server is killed regardless of success/failure. This issue is happening on test classes that have more than one test method which supports my finding. Additionally, some other times the crate server doesn't come up (the 30s await for startup just timeouts), without any log entries (different case than the locked files) and I haven't figured out why, yet.

Furthermore we can completely drop the tests regarding the jdk required for crate, as since long time now, the jdk is shipped in the zip file and it's not required to have a specific version installed in the developer's system. We can just focus on crate 6.2.x .

Will you be able to spend more time on this @mackerl in the near future?

@mackerl
Copy link
Copy Markdown
Contributor Author

mackerl commented Mar 18, 2026

Hi @matriv unfortunately will be hard to find time soon. I also found it very difficult to find out why crate cannot shut down on windows.
I found for me a small workaround to use a very slim crate launcher for CI testing and on windows, whereas going for testcotainer on linux.
Maybe I do a PR in the crate samples repository for my solution.

@matriv
Copy link
Copy Markdown
Contributor

matriv commented Mar 18, 2026

Thx for the prompt response @mackerl, Please share the code you mention.
FYI: you can use testcontainers in Windows as well. I've tried it myself with success.
You need to add the following dependencies (for gradle):

testImplementation("org.testcontainers:testcontainers-cratedb:2.0.2")
testImplementation("org.postgresql:postgresql:42.7.10")

and a test method would look like this:

@Test
public void testCrateDB() throws SQLException {
    try (CrateDBContainer crateDB = new CrateDBContainer("crate:6.2.2")) {
        crateDB.start();
        String url = "jdbc:tc:cratedb:6.2.2://localhost:5432/crate?user=crate";
        Connection conn = DriverManager.getConnection(url, new Properties());
        var stmt = conn.createStatement();
        var rs = stmt.executeQuery("SELECT * FROM sys.nodes");
        while (rs.next()) {
            System.out.println("nodeName: " + rs.getString("name"));
        }
    }
}

of course you need docker installed on your windows machine.

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.

5 participants