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

Ability to Delete Mocks #303

Open
joshua-temple opened this issue Mar 19, 2024 · 2 comments
Open

Ability to Delete Mocks #303

joshua-temple opened this issue Mar 19, 2024 · 2 comments

Comments

@joshua-temple
Copy link

joshua-temple commented Mar 19, 2024

Howdy!

TLDR; Smocker appears to be increasing in CPU utilization as my integration suite grows. Having the ability to remove orphaned mocks may alleviate this.

First off, I saw this other issue that brought up edit/deletion of mocks, and the response therein.

However, my use case is different and wanted to at least plant the seed of hope.

I'm leveraging your wonderful service as a go-between for my integration suite.

The suite spins up all the necessary infra, including smocker, and then runs tests against those services.

Smocker acts as the dependency gap coverage, so each service in the infra points to smocker in place of an actual API dependency.

So when a single test initiates, the mocks it requires are posted to smocker and then the test runs.

As the suite grows (~150 tests), so does the amount of mocks smocker ingests and thus increases CPU utilization.

This is where my need to remove mocks comes into play, but I may be making an erroneous assumption that more mocks == more CPU util.

When a test completes, I'd like to dump those mocks to reduce overhead.

If this were a synchronous test suite, it'd be a non-issue, simply reset between tests. However, that would make test execution likely run for hours so that is not an option.

Worst comes to worse, I can roll my own delete endpoint into it, but obviously not an encouraged practice for several reasons.

Thoughts?

@gwleclerc
Copy link
Collaborator

Hi,
I have some questions:

  • Do you use sessions ?
  • How many mocks are load per session during your 150 tests ?
  • Do you have any memory issue ?
  • How many calls does it receive at the same time?

Currently Smocker is not necessarily optimized. It loads everything in memory and simply loops over each mock of the current session every time it receives a call. You can see it here: https://github.com/smocker-dev/smocker/blob/main/server/handlers/mocks.go#L53

This can be optimized using go routines to retrieve matched mocks faster but I'm not sure it will reduce the CPU usage.

@joshua-temple
Copy link
Author

joshua-temple commented Mar 20, 2024

@gwleclerc thank you for the reply!

Do you use sessions ?

Currently not using sessions, as to my understanding, you can only use a single session at a time.

How many mocks are load per session during your 150 tests ?

I'd guesstimate somewhere around ~20 mocks per test, each being unique mocks.

While there are varying degrees of overlap between mocks, between tests, they are ultimately unique in smocker's eyes.

Do you have any memory issue ?

We did at first, but set a static retention value as we aren't currently interested in validating the mock payload was as expected, because we're inherently validating that with downstream changes in the logic. If the mock didn't return as expected, the data after the fact wouldn't be shaped as expected.

How many calls does it receive at the same time?

Thats a tough gauge but I will look into how I can assert that for you and get back to you asap.

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

No branches or pull requests

2 participants