Skip to content

Conversation

@pierrechristinimsa
Copy link
Contributor

@pierrechristinimsa pierrechristinimsa commented Dec 23, 2024

Description

  • Proposition of implementation for issue Add a method to MicrocksContainer class to get invocations count of a service SOAP #91
  • It mainly consist, at library consumer side, of two methods:
    • one called "verify", that allows to simply know if a service mock has been invoked.
    • another one called "getServiceInvocationsCount", that allows to know the invocations' count for a given service
  • README.MD have been updated to mentions these methods.
  • There are also other methods exposed to be able to pass the invocation day, as the Metrics REST API makes it possible. But it shouldn't be really useful. That's why I haven't mentioned them in the README.MD.
  • Under the hood :
    • As I said before, I'm calling the Microcks Metrics REST API to obtain this data.
    • I had to do a Thread.sleep(...) to avoid race condition issue with the Metrics REST API.

It still lacks of more detailed results.
For instance, for SOAP Mock: it is still impossible to know exactly the count of invocations for a given Operation of the mocked Service. But that doesn't seem to be managed by the microcks server itself, or at least not exposed by the Metrics REST API.

I would also have liked to make the sleep time possibly configurable, but didn't manage to do this simply.

Please feel free to bring feedbacks, thanks by advance.

Related issue(s)

See also #91

@github-actions
Copy link

👋 @pierrechristinimsa

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@pierrechristinimsa
Copy link
Contributor Author

pierrechristinimsa commented Dec 24, 2024

Hello
It seems like I'm facing a race condition issue.

If the unit test code calls the Microcks Metrics REST API too quickly after the desired service have been invoked, randomly (about 1 time out of 2) the API responds as if the service wasn't invoked.
As a first workaround, I added a Thread.sleep(100) and I haven't encountered this race condition issue anymore, but I'm not pleased doing so.

@lbroudoux and Microcks community : have you ever heard of this kind of issue with Microcks Metrics REST API ?
Do you have an idea on how this could be handled in a more elegant and robust way ?

You will find this code, calling Thread.sleep(...) in last changes I just pushed.

@lbroudoux
Copy link
Member

Hi @pierrechristinimsa
Thanks for contributing to this! I'll have a review of the PR asap - probably on Thursday.

Regarding the race condition you're facing: this is expected as the processing of invocation metrics (association to correct day/time and increment of the counter in the database) is done in an asynchronous way vs. the mock controller. I think that adding a timer cannot be avoided to fix the race condition... I just wonder if it wouldn't be better to put this directly in the library method to avoid the consumer worrying about this... 🤔

@pierrechristinimsa
Copy link
Contributor Author

Hi @pierrechristinimsa Thanks for contributing to this! I'll have a review of the PR asap - probably on Thursday.

Regarding the race condition you're facing: this is expected as the processing of invocation metrics (association to correct day/time and increment of the counter in the database) is done in an asynchronous way vs. the mock controller. I think that adding a timer cannot be avoided to fix the race condition... I just wonder if it wouldn't be better to put this directly in the library method to avoid the consumer worrying about this... 🤔

Thank you for your reactive answer and explanations @lbroudoux.

I think that's what I've done : the sleep is hard-coded inside the library method, so the consumer shouldn't be aware of this.

I would have liked to make this sleep time possibly configurable, but as I'm not used to do this, I didn't manage to do this simply.

By the way, I remove the "Draft" state of this PR and I remain available to make some changes if needed.

@pierrechristinimsa pierrechristinimsa marked this pull request as ready for review December 24, 2024 16:21
Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Hey @pierrechristinimsa!
This looks very good - I just suggested a few changes to stick to coding style or governance issues. Nice job!

@lbroudoux lbroudoux added this to the 0.2.11 milestone Dec 24, 2024
@lbroudoux lbroudoux added component/documentation Improvements or additions to documentation kind/feature New feature component/settings Relates to API/settings availables labels Dec 24, 2024
Signed-off-by: Pierre CHRISTIN <christin.pierre@imsa.msa.fr>
Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Look all good to me! I will double-check the question of encoding. Thanks again!

@lbroudoux lbroudoux merged commit 4d8152c into microcks:main Dec 30, 2024
4 of 5 checks passed
@github-actions
Copy link

🎉 @pierrechristinimsa

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

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

Labels

component/documentation Improvements or additions to documentation component/settings Relates to API/settings availables kind/feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants