Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

ref(tests): randomize k8s resource names in tests #4087

Merged
merged 1 commit into from
Sep 14, 2021

Conversation

michelleN
Copy link
Contributor

  • Adds a RandomName() func to e2e test framework to
    more easily generate a random resource name
  • Modifies helper functions that create resource defs to use
    random resource names if resource names are not specifically
    supplied to helpers
  • includes some cleanup of tests although more is needed in
    follow up

resolves #2953

Signed-off-by: Michelle Noorali [email protected]

Description:

Testing done:

Affected area:

Functional Area
New Functionality [ ]
CI System [ ]
CLI Tool [ ]
Certificate Management [ ]
Control Plane [ ]
Demo [ ]
Documentation [ ]
Egress [ ]
Ingress [ ]
Install [ ]
Networking [ ]
Observability [ ]
Performance [ ]
SMI Policy [ ]
Security [ ]
Sidecar Injection [ ]
Tests [ ]
Upgrade [ ]
Other [ ]

Please answer the following questions with yes/no.

  1. Does this change contain code from or inspired by another project?

    • Did you notify the maintainers and provide attribution?
  2. Is this a breaking change?

@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2021

Codecov Report

Merging #4087 (bfbe9e9) into main (6e9464d) will decrease coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4087      +/-   ##
==========================================
- Coverage   69.17%   69.11%   -0.07%     
==========================================
  Files         205      205              
  Lines       11240    11240              
==========================================
- Hits         7775     7768       -7     
- Misses       3413     3420       +7     
  Partials       52       52              
Flag Coverage Δ
unittests 69.11% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/crdconversion/crdconversion.go 69.56% <0.00%> (-5.44%) ⬇️
pkg/k8s/announcement_handlers.go 72.97% <0.00%> (-5.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e9464d...bfbe9e9. Read the comment docs.

@michelleN michelleN force-pushed the randomnames branch 29 times, most recently from be1d6cf to ad47dba Compare September 14, 2021 15:38
@michelleN michelleN force-pushed the randomnames branch 3 times, most recently from 1bdd152 to b5d300e Compare September 14, 2021 16:47
@michelleN michelleN marked this pull request as ready for review September 14, 2021 16:56
@michelleN michelleN requested a review from a team as a code owner September 14, 2021 16:56
var ns []string = []string{sourceNs, destNs}
var (
clientNamespace = framework.RandomName()
serverNamespace = framework.RandomName()
Copy link
Contributor

Choose a reason for hiding this comment

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

This could make troubleshooting and investigating a failing test more difficult. Instead of knowing which namespace has which component, the namespaces now will be random strings. Should we perhaps prefix this so that we should be able to distinguish between source/client and destination/server namespaces?

const destNs = "server"
var ns []string = []string{sourceNs, destNs}
var (
clientNamespace = framework.RandomName()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking have a function RandomNameWithPrefix() to allowing setting a prefix to the name. The purpose is that, sometimes we can debug on failed tests, and have a way to identify what's each ns for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely went back and forth on that but this is a great idea. Thanks @allenlsy I'll update. cc/ @trstringer

Namespace: destName,
Image: "kennethreitz/httpbin",
Ports: []int{80},
OS: Td.ClusterOS,
})
Expect(err).NotTo(HaveOccurred())

// destNamespace = destName
Copy link
Member

Choose a reason for hiding this comment

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

Remove this?

Comment on lines +218 to +219
ServiceName string
ServiceAccountName string
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, much needed to avoid setting the same name for namespace, service, and service accounts.

+ Adds a RandomNameWithPrefix(string) func to e2e test framework to
more easily generate a random resource name
+ Modifies helper functions that create resource defs to use
random resource names if resource names are not specifically
supplied to helpers
+ includes some cleanup of tests although more is needed in
follow up

resolves openservicemesh#2953

Signed-off-by: Michelle Noorali <[email protected]>
@michelleN michelleN merged commit 5e9a349 into openservicemesh:main Sep 14, 2021
@michelleN michelleN deleted the randomnames branch September 14, 2021 18:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Randomize k8s resource names in tests
5 participants