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 tests for controller with mock #344

Merged

Conversation

priyakumarank
Copy link
Collaborator

@priyakumarank priyakumarank commented Oct 11, 2019

#99

What this PR does / why we need it:

  • Add tests for SQL Server Controller and SQL Database Controller
  • Update sqlclient_gosdk.go to be mockable
  • Update SQLFirewallRule Controller and SQLAction Controller to support changes in sqlclient_gosdk
  • Had to remove // +kubebuilder:subresource:status from sqlserver and sqldatabase type, as the tests were crashing(with and without mock) similar to what was happening in eventhubs until we removed it. this needs more investigation, and can possibly be done as a separate spike.
  • Sql Server and SQL Database Controller tests with run with mock always. Running it with Azure results in entire suite timing out. And the Azure end to end tests cover this scenario anyways. We should consider running all the controller tests using mock only. i.e. change the flag in test-existing.
  • Disable parallel tests in controller as it seems to lead to intermittent test failures

Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains tests

@priyakumarank priyakumarank marked this pull request as ready for review October 15, 2019 03:42
Copy link
Contributor

@frodopwns frodopwns left a comment

Choose a reason for hiding this comment

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

Status should remain a sub-resource. Any reason why you chose to remove it?

api/v1alpha1/azuresqldatabase_types.go Outdated Show resolved Hide resolved
api/v1alpha1/azuresqlserver_types.go Outdated Show resolved Hide resolved
@frodopwns
Copy link
Contributor

frodopwns commented Oct 15, 2019

Just saw your explanation for removing the sub-resource. I understand why you might want to do that but I'd rather we didn't. The tests failing before were reasonable and there was a fix but we just didn't implement it.

This is pretty important for the functionality the operators. We will probably update eventhub with it again eventually.

@priyakumarank
Copy link
Collaborator Author

Just saw your explanation for removing the sub-resource. I understand why you might want to do that but I'd rather we didn't. The tests failing before were reasonable and there was a fix but we just didn't implement it.
This is pretty important for the functionality the operators. We will probably update eventhub with it again eventually.

Just saw your explanation for removing the sub-resource. I understand why you might want to do that but I'd rather we didn't. The tests failing before were reasonable and there was a fix but we just didn't implement it.
This is pretty important for the functionality the operators. We will probably update eventhub with it again eventually.

Fair enough. Investigating why the status subresource breaks the tests was going to be my next to do. I wanted to get this in as the first cut. I understand your concerns, so will split this PR into two, where the first one would get the mock client and the changes to the client to support mock in, so that it enables other team members to work on sql firewall and other sql tests. And the second PR would have the tests with the status subresource fix.

Copy link
Contributor

@frodopwns frodopwns left a comment

Choose a reason for hiding this comment

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

couple comments, I will test this tomorrow

pkg/resourcemanager/mock/sqlclient/sqlclient_gosdk.go Outdated Show resolved Hide resolved
Copy link
Contributor

@frodopwns frodopwns left a comment

Choose a reason for hiding this comment

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

Looks good for the most part. You should put the sdkClient in the MockSQLManager instead of passing it as an argument though.

@priyakumarank
Copy link
Collaborator Author

Looks good for the most part. You should put the sdkClient in the MockSQLManager instead of passing it as an argument though.

I have updated the gosdkclient as discussed.

}
r.Recorder.Event(instance, "Normal", "Updated", fmt.Sprintf("finalizer %s added", AzureSQLDatabaseFinalizerName))
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

for future reference...we have some generic functions to replace these in the helper lib.

@frodopwns frodopwns dismissed their stale review October 28, 2019 20:25

issues were addressed

Copy link
Contributor

@frodopwns frodopwns left a comment

Choose a reason for hiding this comment

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

looks good, thanks @priyakumarank !

@priyakumarank priyakumarank merged commit a0dad08 into Azure:master Oct 29, 2019
Porges added a commit that referenced this pull request May 11, 2021
If we panic when writing a file we end up with an empty (or worse) file. The empty file makes `header-check` fail and then you have to manually remove it to re-run any tests you’re doing. So: let’s remove it.
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.

2 participants