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

Fix jkube-kit/build/service module's unit tests on Windows #2640

Closed
rohanKanojia opened this issue Feb 8, 2024 · 16 comments · Fixed by #2678
Closed

Fix jkube-kit/build/service module's unit tests on Windows #2640

rohanKanojia opened this issue Feb 8, 2024 · 16 comments · Fixed by #2678
Assignees
Labels
help wanted Extra attention is needed
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Feb 8, 2024

Component

JKube Kit

Task description

Description

Related to #1338

⚠️ A windows machine is required to reproduce and fix problems in this issue.

Originally posted by @l3002 in #2629 (comment)

a few tests are still failing in jkube-kit/build/service module. Here's a screenshot for your reference

When running mvn clean install on Windows, I see the following tests failing in jkube-kit/build/service module:

TODO: Figure out what's not working as expected and propose a way to fix this

Screenshot 2024-02-08 124307

@l3002
Copy link
Contributor

l3002 commented Feb 8, 2024

@rohanKanojia, I can pick this up, Please assign this to me.

@rohanKanojia
Copy link
Member Author

I haven't checked what's causing the failure. Make sure you share your findings for root cause first before fixing the issue.

@l3002
Copy link
Contributor

l3002 commented Feb 8, 2024

Yeah @rohanKanojia, I'm just trying to figure that out only, I'll first rule out any possible issues with my local environment. I am still not sure if this is a issue with my local machine or the module itself.

@rohanKanojia rohanKanojia added the help wanted Extra attention is needed label Feb 8, 2024
@l3002
Copy link
Contributor

l3002 commented Feb 13, 2024

@rohanKanojia, I have been a bit busy over the past few days, I hope it won't be a problem if this takes a few more day?

@rohanKanojia
Copy link
Member Author

@l3002 : No problem, take your time.

@l3002
Copy link
Contributor

l3002 commented Feb 14, 2024

@rohanKanojia, Seems like the problem is occurring due to the outputDirectory used in WatchContext.buildContext. See below:

image

Here, we are using the absolute path of the directory rather than using just the name. Due to which when we invoke BuildDirs.getDir(), it uses that absolute path of the output directory rather than just using the name of the output directory.

image

This method then returns a file path like this:

C:\Users\Tdgf\AppData\Local\Temp\junit8869024635707207334\C:\Users\Tdgf\AppData\Local\Temp\junit8869024635707207334\target\test-app\build

and is used in the BuildDirs.createDir() leading to the throw statement

image

We can solve the issue by changing the absolute path to just the name. See below:

image

Changing the getAbsolutePath() to getName().

@l3002
Copy link
Contributor

l3002 commented Feb 14, 2024

I've tried building the project on both windows and linux after the changes and it seems to pass all the test in jkube-kit/build/service module. If you are ok with it then I can raise a pull request for the same.

@rohanKanojia
Copy link
Member Author

@l3002 : Nice work! Your analysis looks correct to me. outputDirectory is a relative path to base directory not absolute path.

It was working incorrectly on Linux as well, but we didn't notice it because on Linux it was creating nested directories:

/tmp/junit15664568372380832823
├── file.txt
├── target
└── tmp
    └── junit15664568372380832823
        └── target
            └── test-app
                ├── build
                └── work

@l3002
Copy link
Contributor

l3002 commented Feb 15, 2024

@rohanKanojia: Thanks, Should I raise a PR with the mentioned changes?

Also, After making those changes to the fork on my local system and building the project, there is still a unit test failing in enricher module. Could you please create an issue for that too?

image

While building the project in windows, the following test seems to be failing in jkube-kit/enricher/api module:

  • MetadataVisitorTest

@rohanKanojia
Copy link
Member Author

You can go ahead and create pull request 👍

@rohanKanojia
Copy link
Member Author

Also, After making those changes to the fork on my local system and building the project, there is still a unit test failing in enricher module. Could you please create an issue for that too?

image

While building the project in windows, the following test seems to be failing in jkube-kit/enricher/api module:

  • MetadataVisitorTest

Please don't hesitate in opening up new issue on repository. Anyone can create issues. Just try to follow the same format I used in previous issues.

@l3002
Copy link
Contributor

l3002 commented Feb 15, 2024

Got it.

@manusa
Copy link
Member

manusa commented Feb 16, 2024

This method then returns a file path like this:

C:\Users\Tdgf\AppData\Local\Temp\junit8869024635707207334\C:\Users\Tdgf\AppData\Local\Temp\junit8869024635707207334\target\test-app\build

It was working incorrectly on Linux as well, but we didn't notice it because on Linux it was creating nested directories:

I haven't checked, but this looks like a bug. Probably we should warn about this or even throw an exception if this configuration is provided.

@manusa
Copy link
Member

manusa commented Feb 16, 2024

Yes, I know.
This is exactly my point. Maybe we want to warn those users who provide an absolute path in the outputDirectory configuration, since JKube won't behave as they expect to.

@l3002
Copy link
Contributor

l3002 commented Feb 16, 2024

@manusa, I had a concern regarding this too, if this was undetected here then anyone configuring it manually might face issue later on. We should provide exception if anyone tries to use the absolute path instead to the relative path.

@manusa manusa added this to the 1.17.0 milestone Feb 19, 2024
@manusa manusa modified the milestones: 1.17.0, 1.16.1 Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
3 participants