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

Add a method to MicrocksContainer class to get invocations count of a service SOAP #91

Closed
pierrechristinimsa opened this issue Oct 9, 2024 · 16 comments
Labels
component/documentation Improvements or additions to documentation component/settings Relates to API/settings availables kind/feature New feature
Milestone

Comments

@pierrechristinimsa
Copy link
Contributor

pierrechristinimsa commented Oct 9, 2024

Reason/Context

Hello,
We use microcks-testcontainers-java to mock SOAP web services, importing SoapUI projects.
It works well, but we lack of methods on MicrocksContainer class that could return the invocations count of a service SOAP.
We saw this data is available in admin console, and is accessible via Metrics resource in REST API.
So we would like to have this data easily available, we think it could be benefit for many.
And why do we need to check this invocation count ?

To be sure the mock as been invoked by the application we are covering with integration tests.
Indeed, sometimes we have SOAP WS that just return empty body. For instance : WS that just does an update.
Without having this invocations count, we are not able to know whether our application had the correct behaviour or not.

In summary : it would be like what we do when we call the "verify" method of "Mockito".

Description

Add methods to MicrocksContainer class that could return the invocations count of a service SOAP.

Implementation ideas

This is a draft, using project microcks-java-client to have MetricsApi class :

    private static @NotNull BigDecimal getServiceInvocationsCount(String serviceName,
                                                        String serviceVersion,
                                                        @Nullable Date invocationDate) {
        ApiClient apiClient = new ApiClient();
        apiClient.updateBaseUri(getHttpEndpoint() + "/api");

        MetricsApi metricsApi = new MetricsApi(apiClient);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        final String stringifiedDate = (invocationDate != null) ? simpleDateFormat.format(invocationDate) : null;

        BigDecimal count = null;

        try {
            DailyInvocationStatistic dailyInvocationStatistic =
                    metricsApi.getInvocationStatsByService(serviceName, serviceVersion, stringifiedDate);

            count = dailyInvocationStatistic.getDailyCount();
        } catch (ApiException e) {
            throw new RuntimeException(e); // TODO Better exception handling
        }
        
        return count;
    }

We have already done the code and would like to create branch to push commit but it seems I am not allow to do it.
@lbroudoux (or someone else) : could you please, give me the ability to push a commit on a new branch to submit a PR ?

We are opened to any suggestion, and we give thanks to the community for what you've done so far.

Copy link

github-actions bot commented Oct 9, 2024

👋 @pierrechristinimsa

Welcome to the Microcks community! 💖

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

📢 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 🙌"

Hope you have a great time there!

🌟 ~~~~~~~~~ 🌟

📢 If you like Microcks, please ⭐ star ⭐ our repo to support it!

🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

@lbroudoux
Copy link
Member

This looks super cool! Thanks for the detailed explanation, I think it makes sense to add this kind of feature.

I'm surprised you're not allowed to create a PR on this one. Some other people have done it in the past. You can directly target the main branch as the base of this PR from your cloned repository branch.

Let me know,

@lbroudoux lbroudoux added component/documentation Improvements or additions to documentation kind/feature New feature component/settings Relates to API/settings availables labels Oct 9, 2024
@pierrechristinimsa
Copy link
Contributor Author

Thank you for your feedback @lbroudoux .

I tried by many ways with many computers and from different networks, it seems I have no write access to projects in microcks group. (I have tried to push a new branch to this project and to 'microcks' project, the same behaviour occurs.)
image
image

May you help me to have write access to this project, please ?

@lbroudoux
Copy link
Member

This looks like normal behavior: you don't need to have write access to the repo for one-shot contribution. Have you forked the repository as advised?

The recommended process is as follows:

  1. You fork the repository to your organization or personal account,
  2. You clone this fork on your machine,
  3. You create a branch starting from main to isolate the changes related to this feature,
  4. You commit your changes and push the branch upstream on GitHub,
  5. You finally create a PR to ask the microcks organization to pull the changes from your branch and integrate them into our main branch.

So that's actually us that reads from your fork and propagates those changes into our repo.

Let me know if it helps,

@pierrechristinimsa
Copy link
Contributor Author

ok that's clear, thank you and please excuse me for the inconvenience, you should have news from me in a few days.

@lbroudoux
Copy link
Member

Awesome!

I was thinking: that integrating the Java client may be inconvenient for 2 different reasons:

  1. It may bring a lot of dependencies (I don't have checked this but it would be worth the pain to do so)
  2. It may bring issues as (if I remember correctly), the Java client is compiled with a Java 17 target and Testcontainers Java is compiled with a Java 8 target (this is a recommendation by the Testscontainers team).

Let us know if you have any clue or hints on those 2 points. Maybe, it would be easier to bypass the client and directly use low-level classes (getting the statistics might be a simple GET request ...)

@pierrechristinimsa
Copy link
Contributor Author

You must be right, I was wondering if I should propose you two PRs : one using the java client and another one not using it.
One issue we encounter for now is that the generated classes of the java client are not part of the generated microcks-testcontainers-java jar.
It may not worth to use it, but it would have been interesting because making the code more concise.

@lbroudoux lbroudoux self-assigned this Nov 3, 2024
@lbroudoux lbroudoux added this to the 0.2.10 milestone Nov 3, 2024
@lbroudoux lbroudoux removed their assignment Nov 4, 2024
@lbroudoux
Copy link
Member

Hi @pierrechristinimsa,
I was wondering if you made some progress on this issue?

@lbroudoux lbroudoux modified the milestones: 0.2.10, 0.2.11 Nov 8, 2024
Copy link

github-actions bot commented Dec 9, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale Stale due to inactivity label Dec 9, 2024
@f-lopes
Copy link

f-lopes commented Dec 12, 2024

Adding a way to verify interactions with generated mocks would be very useful.

Are there any updates about this feature?

Thanks.

@github-actions github-actions bot removed the stale Stale due to inactivity label Dec 13, 2024
@lbroudoux
Copy link
Member

lbroudoux commented Dec 18, 2024

Hi @pierrechristinimsa,
I was wondering if you made some progress on this issue and still want to contribute it?
I think I'll jump on this if no answer as I'd like to ship the 0.2.11 this week.

@pierrechristinimsa
Copy link
Contributor Author

Hello @lbroudoux and @f-lopes,
I had some priority changes last month and had no time to spend on it.
Please excuse me for not giving you news about this.
I should have time for this at the beginning of the next week, unless you really would like to have this feature available for 0.2.11 version, don't wait for me.

@lbroudoux
Copy link
Member

Hi @pierrechristinimsa
Thanks for your message and no worries - I know we all have loaded planning 😉
It would be awesome if you found time to push this next week. Then we can target releasing it early next year!
Looking forward to getting news!

@lbroudoux
Copy link
Member

Now available thanks to @pierrechristinimsa !

@pierrechristinimsa
Copy link
Contributor Author

Thank you @lbroudoux, for your help and the attention you accorded.
I just tested the 0.3.0 and it works as expected.

@lbroudoux
Copy link
Member

Awesome! Glad to read this!

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

No branches or pull requests

3 participants