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

Test/chaos experiments: Tests for handlers and services #4137

Merged
merged 26 commits into from Oct 26, 2023

Conversation

SohamRatnaparkhi
Copy link
Contributor

@SohamRatnaparkhi SohamRatnaparkhi commented Aug 18, 2023

Proposed changes

Closes #4050
This PR consists tests for handlers and services in choas_experiment package

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

Special notes for your reviewer:

This PR is related to LFX Mentorship-Term2

Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: Soham Ratnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Copy link
Member

@namkyu1999 namkyu1999 left a comment

Choose a reason for hiding this comment

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

Hello @SohamRatnaparkhi, Can you rename choas to chaos and check that all the test cases work, please?

@SohamRatnaparkhi
Copy link
Contributor Author

Hello @SohamRatnaparkhi, Can you rename choas to chaos and check that all the test cases work, please?

Hey @namkyu1999
Just noticed that there are 2 packages named chaos_experiment_runs and choas_experiment_runs.
But, the chaos_experiment_runs, doesn't have the model/mocks and test files.

So, in this PR itself, should I add them to the chaos_experiment_runs folder?

There are failing testcases, but the reason they are failing is because the chaos_experiment_runs package doesn't have any mocks.

@namkyu1999
Copy link
Member

Hello @SohamRatnaparkhi, Can you rename choas to chaos and check that all the test cases work, please?

Hey @namkyu1999 Just noticed that there are 2 packages named chaos_experiment_runs and choas_experiment_runs. But, the chaos_experiment_runs, doesn't have the model/mocks and test files.

So, in this PR itself, should I add them to the chaos_experiment_runs folder?

There are failing testcases, but the reason they are failing is because the chaos_experiment_runs package doesn't have any mocks.

Hey @SohamRatnaparkhi ,
What's different between chaos_experiment_runs and choas_experiment_runs?
IMO, It would be better if you move all the files in choas_experiment_runs to chaos_experiment_runs

@SohamRatnaparkhi
Copy link
Contributor Author

Okay cool!
So I will do it in this PR itself.
Right?

@namkyu1999
Copy link
Member

Okay cool! So I will do it in this PR itself. Right?

Right 😊

Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
@SohamRatnaparkhi
Copy link
Contributor Author

Okay cool! So I will do it in this PR itself. Right?

Right 😊

Hey @namkyu1999
I have made the respective changes.
I fell, we can add the service test files and stuff in a separate PR as those changes are not pretty much not linked with the changes in this PR. This PR just required the mocks and I added those in this PR.

In a separate PR, we can do 2 things

  • add service test files from choas_exp_runs to chaos
  • delete the old directory

What's your opinion on this?

@namkyu1999
Copy link
Member

Hi @SohamRatnaparkhi ,

Since there aren't many changes in the current PR, and no one has started a review, it would be a good idea to include all the changes in this PR. This is just my opinion, feel free to make your own choices.

Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
@SohamRatnaparkhi
Copy link
Contributor Author

Hi @SohamRatnaparkhi ,

Since there aren't many changes in the current PR, and no one has started a review, it would be a good idea to include all the changes in this PR. This is just my opinion, feel free to make your own choices.

Hey @namkyu1999
Sorry for being this late :)
Done with the required changes.

}
}

func TestChaosExperimentHandler_UpdateChaosExperiment(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

This testcase is failed because new operations added since last commit.

UpdateChaosExperiment use this function below

experimentCount, err := c.chaosExperimentOperator.CountChaosExperiments(ctx, filterQuery)
if err != nil {
return nil, err
}

and this operator use a global variable

res, err := mongodb.Operator.CountDocuments(ctx, mongodb.ChaosExperimentCollection, query)

Can you change this one to local variable and update testcase?

Other than that, LGTM 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the changes in latest commit!

Signed-off-by: SohamRatnaparkhi <soham.ratnaparkhi@gmail.com>
Signed-off-by: Saranya Jena <saranya.jena@harness.io>
Signed-off-by: Saranya Jena <saranya.jena@harness.io>
@Saranya-jena Saranya-jena merged commit 727ee8a into litmuschaos:master Oct 26, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testcases for choas_experiment handler
6 participants