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

InternalCommandPortListeningCheck not working when linux kernel lists ports as hexadecimal #749

Closed
stevewoodsdd opened this issue Jun 13, 2018 · 11 comments

Comments

@stevewoodsdd
Copy link

Kernel details:
Linux jenkins-v2 3.10.0-693.21.1.el7.x86_64 #1 SMP Fri Feb 23 18:54:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Command that should fix the issue:
{"/bin/sh", "-c", format("cat /proc/net/tcp6 | awk ‘{print $2}’ | awk --non-decimal-data -F: ‘{print (“0x”$2)+0}’ | grep -i %x && echo %s", internalPort, SUCCESS_MARKER)}

@bsideup
Copy link
Member

bsideup commented Jun 13, 2018

Hi @stevewoodsdd, that was fixed long time ago in #524, please make sure you're using the latest version (1.7.3)

@stevewoodsdd
Copy link
Author

Hi @bsideup, wow that was quick. Im using 'org.testcontainers:kafka:1.7.3'

The port does not appear with cat /proc/net/tcp it need cat /proc/net/tcp6

@bsideup
Copy link
Member

bsideup commented Jun 13, 2018

@stevewoodsdd I see. Thanks for reporting! I'll take a look. Let me know if you want to contribute your awesome finding :)

@stevewoodsdd
Copy link
Author

If you could add the fix that would be much appreciated. Thanks for maintaining such a powerful library.

@stevewoodsdd stevewoodsdd changed the title InternalCommandPortListeningCheck not working when linux kernel lists ports has hexadecimal InternalCommandPortListeningCheck not working when linux kernel lists ports as hexadecimal Jun 13, 2018
@bsideup bsideup added this to the next milestone Jun 13, 2018
@rnorth
Copy link
Member

rnorth commented Jun 13, 2018

Thanks for reporting this Steve! 😀
We’ll get the fix out soon.

@bsideup
Copy link
Member

bsideup commented Jun 15, 2018

Hi @stevewoodsdd, could you please try 1.8.0?

@stevewoodsdd
Copy link
Author

Hi @bsideup,

I have tried 1.8.0 this morning and unfortunately no luck.

Looking at the fix the issue seems to be that tcp6 lists the IP and ports in hex. Hence the more elaborate suggestion:
{"/bin/sh", "-c", format("cat /proc/net/tcp6 | awk ‘{print $2}’ | awk --non-decimal-data -F: ‘{print (“0x”$2)+0}’ | grep -i %x && echo %s", internalPort, SUCCESS_MARKER)}

All the best,
Steve

@bsideup
Copy link
Member

bsideup commented Jun 15, 2018

@stevewoodsdd could you please give an example of that tcp6 returns?

@stevewoodsdd
Copy link
Author

stevewoodsdd commented Jun 15, 2018

@bsideup Sure no problem see attached:
sample-output.txt

@rnorth
Copy link
Member

rnorth commented Jun 15, 2018

Hmm, I'm not sure about this. We already compensate for the fact that the port number will be expressed in hex in a /proc/net/tcp or /proc/net/tcp6 file.

The grep -i :%x will be rendered into the shell string (by Java's String.format) as grep -i :1f90 for example, if the port we're interested in is 8080.

It looks like your code would try and convert the actual port numbers into decimal, but would then still be grepping for the hex form.

Could you try putting a breakpoint in InternalCommandPortListeningCheck and evaluate some different invocations of ExecInContainerPattern.execInContainer(waitStrategyTarget.getContainerInfo(), "SOME COMMAND WE EXPECT TO WORK && echo here").getStdout()?

Alternatively if this is running against a public image it would be interesting to have a direct look.

BTW if debugging on Slack is easier we have https://slack.testcontainers.org. If as your username suggests, you're the Steve Woods I used to work with, then I'm also a guest user on your Slack team 😄

@stevewoodsdd
Copy link
Author

O I see yes that should work now it includes tcp6 I must have another issue so I will close this and do some more digging.

Hats of as well @bsideup & @rnorth the solution you have come up with is far more elegant then what I suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants