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

Include Test case for Limits #83

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

nitishkumar71
Copy link
Member

Signed-off-by: Nitishkumar Singh [email protected]

Certifier should support validation of memory limit in faasd and openfaas

Description

Motivation and Context

  • I have raised an issue to propose this change this is required

Closes #81

How Has This Been Tested?

  1. New test case has been included to test memory limit

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Commits:

  • I've read the CONTRIBUTION guide
  • My commit message has a body and describes how this was tested and why it is required.
  • I have signed-off my commits with git commit -s for the Developer Certificate of Origin (DCO)

Code:

  • My code follows the code style of this project.
  • I have added tests to cover my changes.

Docs:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@nitishkumar71 nitishkumar71 force-pushed the memory_support branch 4 times, most recently from 0e55657 to 60bd9d0 Compare November 5, 2021 07:27
@nitishkumar71 nitishkumar71 changed the title Include Test case for Limits [WIP] Include Test case for Limits Nov 5, 2021
@nitishkumar71 nitishkumar71 force-pushed the memory_support branch 3 times, most recently from 7e43851 to 3dbb296 Compare November 5, 2021 09:03
@nitishkumar71 nitishkumar71 changed the title [WIP] Include Test case for Limits Include Test case for Limits Nov 5, 2021
@nitishkumar71
Copy link
Member Author

Can we run the workflow again? The issue is same as #82 where mostly failure happens for logs.

} else if config.ProviderName == faasdProviderName && deploy.Limits != nil && status.Limits != nil {
deployLimits := *deploy.Limits
statusLimits := *status.Limits
if deployLimits.Memory != statusLimits.Memory {
Copy link
Member

Choose a reason for hiding this comment

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

I would like to see this fail for the current version of faasd which has no memory limit support in its status endpoint.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changes are done. Since faasd does not support cpu, special handling is required for faasd.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changes are done to allow current stable faasd version to fail for Limits

@alexellis
Copy link
Member

You can run this locally with go test -run "^NameOfTest$" and then see the individual test fail for faasd to show that the memory limit wasn't detected. Then we'll cut a new release of faasd we can re-run the tests and see it pass.

@alexellis
Copy link
Member

2021-12-05T17:50:48.3391383Z --- FAIL: Test_Deploy_MetaData/test_listing_functions (0.02s)
2021-12-05T17:50:48.3392022Z deploy_test.go:162: got nil, expected Limits &{5M 100m}

Perfect!

@alexellis
Copy link
Member

We now have a new release which populates the memory value in the API, so let's run these tests again once the binaries are ready.

After that, if the faasd tests pass, I'll merge this PR.

https://github.com/openfaas/faasd/releases/tag/0.14.4

@nitishkumar71
Copy link
Member Author

We now have a new release which populates the memory value in the API, so let's run these tests again once the binaries are ready.

After that, if the faasd tests pass, I'll merge this PR.

https://github.com/openfaas/faasd/releases/tag/0.14.4

Can we run it now? I don't have permission for same.

@nitishkumar71
Copy link
Member Author

nitishkumar71 commented Dec 24, 2021

@alexellis @LucasRoesler I have removed faasd memory test for now and have kept it just for faas-netes. Will work on it once we have resolved openfaas/faasd#228

Labels: &map[string]string{},
Namespace: config.DefaultNamespace,
Limits: &types.FunctionResources{
Memory: "5M",
Copy link
Member

@alexellis alexellis Jan 5, 2022

Choose a reason for hiding this comment

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

Could you try this with 5Mi?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changes are done and it works for both faas-netes and faasd.

Copy link
Member

@LucasRoesler LucasRoesler left a comment

Choose a reason for hiding this comment

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

@nitishkumar71 i added a comment about improving the readability of the test by using a new config flag instead of the provider name.

Another approach could be to have a function SupportsCPULimits(name string) bool that takes the provider name and returns true if it is in the supported list. But either way, using the provider name in the control flow is going to be a bit fragile in the long term.

Comment on lines 234 to 253
if config.ProviderName != faasdProviderName && !reflect.DeepEqual(deploy.Limits, status.Limits) {
return fmt.Errorf("got %v, expected Limits %v", status.Limits, deploy.Limits)
} else if config.ProviderName == faasdProviderName && deploy.Limits != nil {
if status.Limits == nil {
return fmt.Errorf("got nil, expected Limits %v", deploy.Limits)
}
if deploy.Limits.Memory != status.Limits.Memory {
return fmt.Errorf("got %s, expected Requested Limit %s", status.Limits.Memory, deploy.Limits.Memory)
}
Copy link
Member

Choose a reason for hiding this comment

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

If i am reading this correctly, this implies that faasd does not record and therfore can not return the CPU limits from the original function deployment, is that correct?

I think we can make this semantically clearer and easier to maintain by adding a new boolean value to the config config.SupportCPULimits. When the test starts, we can set config.SupportCPULimits = config.ProviderName != faasdProviderName in the main_test.go

I would then split this into two tests, one for memory and one for CPU

Suggested change
if config.ProviderName != faasdProviderName && !reflect.DeepEqual(deploy.Limits, status.Limits) {
return fmt.Errorf("got %v, expected Limits %v", status.Limits, deploy.Limits)
} else if config.ProviderName == faasdProviderName && deploy.Limits != nil {
if status.Limits == nil {
return fmt.Errorf("got nil, expected Limits %v", deploy.Limits)
}
if deploy.Limits.Memory != status.Limits.Memory {
return fmt.Errorf("got %s, expected Requested Limit %s", status.Limits.Memory, deploy.Limits.Memory)
}
if deploy.Limits != nil {
if status.Limits == nil {
return fmt.Errorf("got nil, expected Limits %v", deploy.Limits)
}
if deploy.Limits.Memory != status.Limits.Memory {
return fmt.Errorf("got %s, expected Requested Limit %s", status.Limits.Memory, deploy.Limits.Memory)
}
if config.SupportCPULimits && deploy.Limits.CPU != status.Limits.CPU {
return fmt.Errorf("got %s, expected Requested Limit %s", status.Limits.CPU, deploy.Limits.CPU)
}
}
if deploy.Limits == nil && status.Limits != nil {
return fmt.Errorf("got %s, expected nil", status.Limits)
}

I think using a config flag here makes the intent of the test much clearer and generic.

In general, I prefer the tests to mention features not providers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for suggestion. No doubt this is the best way to write the code. There is an issue in faasd due to which below lines will not work for functions for which no memory limit is explicitly set.

if deploy.Limits == nil && status.Limits != nil {
      return fmt.Errorf("got %s, expected nil", status.Limits)
}

Copy link
Member Author

@nitishkumar71 nitishkumar71 Jan 24, 2022

Choose a reason for hiding this comment

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

These changes will work only after merge and release of openfaas/faasd#232. I have validated these changes in my local.

Copy link
Member

Choose a reason for hiding this comment

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

@nitishkumar71 now that openfaas/faasd#232 is merged, what do we need to do to merge this?

Copy link
Member

Choose a reason for hiding this comment

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

I think you need to force push again to trigger the actions to re-run the tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@nitishkumar71 nitishkumar71 force-pushed the memory_support branch 2 times, most recently from f02b179 to 573afad Compare January 25, 2022 18:18
@nitishkumar71 nitishkumar71 force-pushed the memory_support branch 2 times, most recently from 00a0232 to daf52e0 Compare March 26, 2022 14:54
Signed-off-by: Nitishkumar Singh <[email protected]>

Test case changed to binary SI from decimal SI

Signed-off-by: Nitishkumar Singh <[email protected]>

Included Suggestions

Signed-off-by: Nitishkumar Singh <[email protected]>

Prefixed Docker registery path

Signed-off-by: Nitishkumar Singh <[email protected]>

revrted wait part

Signed-off-by: Nitishkumar Singh <[email protected]>
@LucasRoesler
Copy link
Member

I am going to merge this because the test that is failing is the scaling test, which has been flaky and we are still investigating. The new limits test is fine

@LucasRoesler LucasRoesler merged commit 2e39d05 into openfaas:master Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add memory limits as a test
3 participants