Skip to content

Commit

Permalink
generate unique container names
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenolivia committed Jul 22, 2022
1 parent b1b8e16 commit 8786524
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,25 @@ func createAgent(t *testing.T, client *Client, org *Organization, agentPool *Age
agentPoolToken, agentPoolTokenCleanup = createAgentToken(t, client, agentPool)
}

containerName := "container-test-agent"
s := "abcdefghijklmnopqrstuvwxyz0123456789"
containerName := base64.StdEncoding.EncodeToString([]byte(s))
t.Log("containerName: ", containerName)

// containerName := "container-name-test"
ctx := context.Background()
cmd := exec.Command("docker",
"run", "-d", "--name", containerName,
"--env", "TFC_AGENT_TOKEN="+agentPoolToken.Token,
"--env", "TFC_AGENT_NAME="+"this-is-a-test-agent",
"--env", "TFC_ADDRESS="+"https://tfe-zone-royalty-casing-stare-huntress-ipq7xcp29ohfo5b.ngrok.io",
"--env", "TFC_ADDRESS="+"https://tfcdev-2c13224a.ngrok.io",
"docker.mirror.hashicorp.services/hashicorp/tfc-agent:latest")

go func() {
output, err := cmd.CombinedOutput()
if err != nil {
t.Logf("Could not run container: %s", err)
}
// t.Log("cmd", cmd)
t.Log("Logging container output: ", (string)(output))
t.Log("log agent inside container output: ", agent)
}()
Expand Down Expand Up @@ -156,15 +161,18 @@ func createAgent(t *testing.T, client *Client, org *Organization, agentPool *Age

return agent, func() {
if agentPoolTokenCleanup != nil {
agentPoolTokenCleanup()
// agentPoolTokenCleanup()
t.Log("agentPoolTooken not nil inside helper fn")
}

if agentPoolCleanup != nil {
agentPoolCleanup()
// agentPoolCleanup()
t.Log("agentPool not nil")
}

if orgCleanup != nil {
orgCleanup()
// orgCleanup()
t.Log("org not nil")
}
}
}
Expand Down

0 comments on commit 8786524

Please sign in to comment.