-
Notifications
You must be signed in to change notification settings - Fork 42
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
Can't unit test own usage of InClusterFactory #103
Comments
Very similar to #50 |
The purpose of the PR (#58) that introduced the InClusterFactory is that you could substitute that out in your tests and use a separate implementation of |
I did try that earlier but found that So am not sure how that would help. My interface would have to return a If it would help my code is located here: |
Yeah However, I don't think we want to change anything about the functionality of the |
* When operator is installed via OLM, a separate OperatorCondition CR is created which can be updated with an "upgradeable" condition flagging whether the OLM can upgrade the operator * Turn off upgradeable state when * operator is initializing * operator is upgrading * Turn on upgradeable state when * operator has started * operator has completed an upgrade * Finds the OperatorCondition using the deployment name, deployment owner (CSV) and the CSV name (OperatorCondition has same name as the CSV). * Adds conditions tests but cannot completely implement due to operator-framework/operator-lib#103
* When operator is installed via OLM, a separate OperatorCondition CR is created which can be updated with an "upgradeable" condition flagging whether the OLM can upgrade the operator * Turn off upgradeable state when * operator is initializing * operator is upgrading * Turn on upgradeable state when * operator has started * operator has completed an upgrade * Finds the OperatorCondition using the deployment name, deployment owner (CSV) and the CSV name (OperatorCondition has same name as the CSV). * Adds conditions tests but cannot completely implement due to operator-framework/operator-lib#103
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/lifecycle frozen
We'd be happy to accept a PR that adds |
Bug Report
What did you do?
Created a wrapper function in our operator code that finds the name of the associated OLM OperatorCondition and then uses the InClusterFactory API to set the upgradeable condition. Then we started writing tests to test this function.
What did you expect to see?
Tests to pass or fail depending on the correct writing of the wrapper function and calling the correct InClusterFactory and Condition code.
What did you see instead? Under which circumstances?
The error:
get operator condition namespace: namespace not found for current environment
.Since the unit tests are using a fake runtime client and running locally, this was to be expected since
InClusterFactory.GetNamespacedName()
callsutils.GetOperatorNamespace()
. However, what was unexpected was in our tests there is no way to override this since:readNamespace
.Environment
Possible Solutions
readNamespace
publicGetNamespacedName
to be overriddenrequest.namespace
, it might be a nice alternative?)Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: