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

Introduce generic OpenAPI entity cleanup for tests #348

Merged
merged 8 commits into from
Jan 19, 2021

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Dec 18, 2020

I was going to introduce these changes with Org VDC network PRs but because this touches many points I have split this before going with Org VDC network PR.

OpenAPI has a standartized working approach which allows to improve on current entity cleanup operations in tests.

Because delete endpoints for OpenAPI are constructed in the same fashion - all items can be deleted using low level OpenAPI function OpenApiDeleteItem provided endpoint (together with ID) are known. And these are easy to know once object is created.

This PR sets up code for generic openapi entity cleanup (by adding two new cleanup functions AddToCleanupListOpenApi and PrependToCleanupListOpenApi)and also uses it in external network V2

	// Use generic "OpenApiEntity" resource cleanup type
	openApiEndpoint := endpoint + createdNet.ExternalNetwork.ID
	AddToCleanupListOpenApi(createdNet.ExternalNetwork.Name, "OpenApiEntity",  check.TestName(), openApiEndpoint)

The above code generates such entry in cleanup list:

  "EntityList": [
   {
    "Name": "testNet",
    "EntityType": "OpenApiEntity",
    "Parent": "",
    "CreatedBy": "TestVCD.Test_CreateExternalNetworkV2Nsxt",
    "OpenApiEndpoint": "1.0.0/externalNetworks/urn:vcloud:network:0d2d7953-1277-427e-b9b0-47710771286d"
   }
  ]

Also fix test Test_OpenApiInlineStructCRUDRoles by using smarter time parsing library

@Didainius Didainius self-assigned this Jan 5, 2021
@Didainius Didainius marked this pull request as ready for review January 5, 2021 09:49
@Didainius Didainius requested a review from dataclouder January 5, 2021 09:49
CHANGELOG.md Show resolved Hide resolved
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

I have only one more comment while looking at forty files changed :)

Maybe a separate function for the new functionality? Something like this:

func AddToCleanupList(name, entityType, parent, createdBy)
func AddToCleanupListURL(name, entityType, parent, createdBy, openApiEndpoint string)

AddToCleanupList - would only call with the last parameter empty AddToCleanupListURL(..., "")

This is just a thought. I don't mind changing forty files if you and @dataclouder think code is easier to manage with a single function long-term.

@Didainius
Copy link
Collaborator Author

I have only one more comment while looking at forty files changed :)

Maybe a separate function for the new functionality? Something like this:

func AddToCleanupList(name, entityType, parent, createdBy)
func AddToCleanupListURL(name, entityType, parent, createdBy, openApiEndpoint string)

AddToCleanupList - would only call with the last parameter empty AddToCleanupListURL(..., "")

This is just a thought. I don't mind changing forty files if you and @dataclouder think code is easier to manage with a single function long-term.

I was on the edge between this solution and the other. I guess one more thought like that weighs id down. Let me change it.

@Didainius Didainius merged commit 2cc242a into vmware:master Jan 19, 2021
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.

4 participants