-
Notifications
You must be signed in to change notification settings - Fork 22
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
Hap Diff Test #1814
base: main
Are you sure you want to change the base?
Hap Diff Test #1814
Conversation
Add one of following labels |
"us-west1", | ||
"us-east4", | ||
"europe-west4", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come:
INPUT: PlanID: 4deee563-e5ec-4731-b9b1-53b42d855f0c, PlatformRegion: cf-ap21, ClusterRegion: centralus, Provider: AWS
!dirty,!euAccess,hyperscalerType=aws,tenantName=e8f7ec0a-0cd6-41f0-905d-5d1efa9fb6c4
INPUT: PlanID: 4deee563-e5ec-4731-b9b1-53b42d855f0c, PlatformRegion: cf-ap21, ClusterRegion: centralus, Provider: Azure
!dirty,!euAccess,hyperscalerType=azure,tenantName=e8f7ec0a-0cd6-41f0-905d-5d1efa9fb6c4
INPUT: PlanID: 4deee563-e5ec-4731-b9b1-53b42d855f0c, PlatformRegion: cf-ap21, ClusterRegion: centralus, Provider: GCP
!dirty,!euAccess,hyperscalerType=gcp,tenantName=e8f7ec0a-0cd6-41f0-905d-5d1efa9fb6c4
centralus
is only valid for azure
provider (and related plans).
So we test not allowed combinations of plan and cluster region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not issue but could be.
If we have difference for not allowed combinations, we report failure of comparison however it is not necessarily a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here we generate over 50k cases instead of around 3k.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was easier for just to go through all combinations. Test will be removed with removal of old resolve_creds steps.
var newImplementationLog *bufio.Writer | ||
|
||
if writeFiles { | ||
oldLog, err := os.OpenFile("./hap-old-implementation.log", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executable? I think we need to reconsider permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
oldImplementationLog = bufio.NewWriter(oldLog) | ||
|
||
newLog, err := os.OpenFile("./hap-new-implementation.log", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executable? Is this really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Zero(t, when) | ||
|
||
for label, count := range queriesCountMap { | ||
require.NotZero(t, count, "first invocation produced wrong number of queries for label: %s, count: %d", label, count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If count > 0 regardless of the actual value we are fine?
What if count > 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if implementation wrongly requests twice the same (or different) secret bindings?
Should we detect it?
internal/process/provisioning/resolve_creds_hap_selection_migration_test.go
Outdated
Show resolved
Hide resolved
internal/process/provisioning/resolve_creds_hap_selection_migration_test.go
Outdated
Show resolved
Hide resolved
) | ||
|
||
// To generate output hap-old-implementation files (used to compare results by hand) switch writeFiles to true | ||
func TestResolveCredentials_IntegrationAzure2(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you consider changing the name of function?
increase := true | ||
|
||
gc.PrependReactor("list", gardener.SecretBindingResource.Resource, func(action k8sTesting.Action) (bool, runtime.Object, error) { | ||
originalLabel := action.(k8sTesting.ListActionImpl).GetListRestrictions().Labels.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are labels (as GetListRestrictions().Labels
suggests).
|
||
// first run | ||
increase = true | ||
_, when, err := step.Run(op, fixLogger()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we have reactor called and queriesCountMap filled.
Comparison is based on assumption that map key will be the same (GetListRestrictions().Labels.String()
).
What if order is not stable?
What if there is irrelevant label added?
Shouldn't we compare explicitely shared, euaccess, hyperscalertype labels?
What if tenant change?
// for example !dirty selects a secret without dirty label | ||
filteredSplit := []string{} | ||
split := strings.Split(originalLabel, ",") | ||
for _, label := range split { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is needed only to fix appropriate SecretBinding.
So could be extracted as it has different responsibility.
split := strings.Split(originalLabel, ",") | ||
for _, label := range split { | ||
label = strings.Trim(label, " ") | ||
if label != "" && label != " " && label != "!dirty" && label != "!euAccess" && label != "shared!=true" && label != "!tenantName" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we omit "!euAccess".
split := strings.Split(originalLabel, ",") | ||
for _, label := range split { | ||
label = strings.Trim(label, " ") | ||
if label != "" && label != " " && label != "!dirty" && label != "!euAccess" && label != "shared!=true" && label != "!tenantName" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could "shared!=true" actually happen?
internal/process/provisioning/resolve_creds_hap_selection_migration_test.go
Show resolved
Hide resolved
…ation_test.go Co-authored-by: Jarosław Pieszka <[email protected]>
…ation_test.go Co-authored-by: Jarosław Pieszka <[email protected]>
Description
Changes proposed in this pull request:
Related issue(s)
#1520