Skip to content

Commit

Permalink
systemtest: ensure unique package policy names (#6599)
Browse files Browse the repository at this point in the history
(cherry picked from commit b060ae6)
  • Loading branch information
axw authored and mergify-bot committed Nov 14, 2021
1 parent 85705a0 commit d9a1890
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions systemtest/kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func InitFleet() error {
// This should typically be used by tests instead of directly calling the
// fleettest.Client.CreateAgentPolicy method.
func CreateAgentPolicy(t testing.TB, name, namespace string, vars map[string]interface{}) (*fleettest.AgentPolicy, *fleettest.EnrollmentAPIKey) {

agentPolicy, key, err := Fleet.CreateAgentPolicy(name, namespace, agentPolicyDescription)
require.NoError(t, err)
t.Cleanup(func() {
Expand Down Expand Up @@ -178,7 +177,10 @@ func DestroyAgentPolicy(id ...string) error {
//
// The returned package policy is suitable for passing to Fleet.CreatePackagePolicy.
func NewPackagePolicy(agentPolicy *fleettest.AgentPolicy, varValues map[string]interface{}) *fleettest.PackagePolicy {
packagePolicy := fleettest.NewPackagePolicy(IntegrationPackage, "apm", agentPolicy.Namespace, agentPolicy.ID)
// Package policy names must be globally unique. We generate unique agent
// policy names, so just append the package name to that.
packagePolicyName := agentPolicy.Name + "-apm"
packagePolicy := fleettest.NewPackagePolicy(IntegrationPackage, packagePolicyName, agentPolicy.Namespace, agentPolicy.ID)
packagePolicy.Package.Name = IntegrationPackage.Name
packagePolicy.Package.Version = IntegrationPackage.Version
packagePolicy.Package.Title = IntegrationPackage.Title
Expand Down

0 comments on commit d9a1890

Please sign in to comment.