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: Make sure to use current pid to verify Camel app status #1284

Closed

Conversation

gansheer
Copy link
Contributor

@gansheer gansheer commented Dec 18, 2024

Bug

The integration tests org.citrusframework.camel.yaml.JBangTest.shouldLoadCamelActions and org.citrusframework.camel.xml.JBangTest.shouldLoadCamelActions fails on my local environement.
The Camel Jbang CamelRunIntegrationAction sets the wrong process pid from a temporary descendant process in the context. This descendant process is not the Camel Jbang run process. When the CamelVerifyIntegrationAction use the pid from the context object and keeps waiting for the integration process to be Running.
The descendant process is not active very long.

Processing 19951 command: Optional[/usr/bin/bash -c jbang -Dgreeting="Hello Camel" camel@apache/camel run --name hello-yaml --verbose /home/user1/work/sources/gansheer/citrus/endpoints/citrus-camel/target/test-classes/org/citrusframework/camel/integration/route.yaml]
Processing descendant 19963 command: Optional[/usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc41.x86_64/bin/java -classpath /home/user1/.jbang/bin/jbang.jar dev.jbang.Main -Dgreeting=Hello Camel camel@apache/camel run --name hello-yaml --verbose /home/user1/work/sources/gansheer/citrus/endpoints/citrus-camel/target/test-classes/org/citrusframework/camel/integration/route.yaml]
2024-12-17 09:41:01.372|INFO |main|CamelRunIntegrationAction - Started Camel integration 'hello-yaml' (19963)
2024-12-17 09:41:01.382|INFO |main|CamelRunIntegrationAction - Waiting for the Camel integration 'hello-yaml' (19963) to be running ...
2024-12-17 09:41:02.344|INFO |main|CamelVerifyIntegrationAction - Camel JBang version: 4.9.0

2024-12-17 09:41:02.344|INFO |main|CamelVerifyIntegrationAction - Verify Camel integration 'hello-yaml' ...
2024-12-17 09:41:02.344|INFO |main|INTEGRATION_STATUS - Waiting for Camel integration 'hello-yaml' to be in state 'Running'
2024-12-17 09:41:04.263|INFO |main|CamelVerifyIntegrationAction - 
  PID   NAME        READY  STATUS   AGE  TOTAL  REMOTE  FAIL  INFLIGHT   
 19951  hello-yaml   1/1   Running   3s      0       0   0/0       0/0   


2024-12-17 09:41:06.560|INFO |main|CamelVerifyIntegrationAction - Waiting for Camel integration 'hello-yaml' to be in state 'Running'- retry in 2000 ms
2024-12-17 09:41:08.353|INFO |main|CamelVerifyIntegrationAction - 
  PID   NAME       READY  STATUS   AGE  TOTAL  REMOTE  FAIL  INFLIGHT   
 19951  hello-yaml   1/1   Running   7s      4       0   0/0       0/0 

Fix

  • Use the parent process pid to identify the running Camel JBang application
  • Camel JBang pid may change on Unix OS due to descendant process being launched
  • Racing conditions may lead to parent pid being stored in test context
  • Make sure to also search for descendant process ids when verifying the Camel integration app status

Copy link
Collaborator

@bbortt bbortt left a comment

Choose a reason for hiding this comment

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

hello and thanks for the attempted fix. there are probably differences in local execution vs pipeline. this currently doesn't run: https://github.com/citrusframework/citrus/pull/1284/checks#step:6:54177.

additionally, I've left one remark on your code.

try {
Thread.sleep(delayBetweenAttempts);
} catch (InterruptedException e) {
logger.warn("Interrupted while waiting for Camel integration '%s' first log".formatted(name), e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logger.warn("Interrupted while waiting for Camel integration '%s' first log".formatted(name), e);
logger.warn("Interrupted while waiting for Camel integration '{}' first log", name, e);

please use the logger-internal formatting.

@bbortt bbortt assigned bbortt and gansheer and unassigned bbortt Dec 19, 2024
@bbortt bbortt added Type: Bug Prio: High State: Review If pull-request has been opened an is ready/in review labels Dec 19, 2024
@christophd
Copy link
Member

I have created another branch with potential fix: https://github.com/citrusframework/citrus/tree/fix_pid_camel_jbang_run

@gansheer can you please checkout this branch and see if the fix works on your machine?

I have added some logic in the Camel JBang verification test action to also look for descendant process ids. PR is here: #1285

Let's see what GH actions results do report for this fix

christophd and others added 2 commits December 19, 2024 12:29
- Auto adjust the pid that identifies the running Camel JBang application
- Camel JBang pid may change on Unix OS due to descendant process being launched
- Racing conditions may lead to parent pid being stored in test context
- Make sure to also search for descendant process ids when verifying the Camel integration app status
@gansheer gansheer force-pushed the fix_pid_camel_jbang_run branch from efcf482 to bdae2d8 Compare December 19, 2024 11:58
@gansheer gansheer changed the title fix: use valid pid in camel-jbang tests fix: Make sure to use current pid to verify Camel app status Dec 19, 2024
@gansheer
Copy link
Contributor Author

gansheer commented Dec 20, 2024

Merged as part of #1286.

@gansheer gansheer closed this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio: High State: Review If pull-request has been opened an is ready/in review Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants