Skip to content

Commit

Permalink
Prevent conflict errors in load tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timebertt committed Aug 7, 2023
1 parent ad7d7e9 commit dad6071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion webhosting-operator/pkg/experiment/generator/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ func CreateTheme(ctx context.Context, c client.Client, labels map[string]string)

// MutateTheme mutates the given theme using the given client and labels.
func MutateTheme(ctx context.Context, c client.Client, theme *webhostingv1alpha1.Theme) error {
patch := client.MergeFrom(theme.DeepCopy())

theme.Spec.Color = utils.PickRandom(themeColors)
theme.Spec.FontFamily = utils.PickRandom(themeFonts)

if err := c.Update(ctx, theme); err != nil {
if err := c.Patch(ctx, theme, patch); err != nil {
return err
}

Expand Down
4 changes: 3 additions & 1 deletion webhosting-operator/pkg/experiment/generator/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ func MutateWebsite(ctx context.Context, c client.Client, website *webhostingv1al
return err
}

patch := client.MergeFrom(website.DeepCopy())

website.Spec.Theme = utils.PickRandom(themeList.Items).Name

if err := c.Update(ctx, website); err != nil {
if err := c.Patch(ctx, website, patch); err != nil {
return err
}

Expand Down

0 comments on commit dad6071

Please sign in to comment.