-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #602 from jetstack/VC-35738/feature
[VC-35738] Feature Branch
- Loading branch information
Showing
19 changed files
with
955 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"os" | ||
"os/exec" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestAgentRunOneShot runs the agent in `--one-shot` mode and verifies that it exits | ||
// after the first data gathering iteration. | ||
func TestAgentRunOneShot(t *testing.T) { | ||
if _, found := os.LookupEnv("GO_CHILD"); found { | ||
// Silence the warning about missing pod name for event generation | ||
// TODO(wallrj): This should not be required when an `--input-file` has been supplied. | ||
t.Setenv("POD_NAME", "venafi-kubernetes-e2e") | ||
// Silence the error about missing kubeconfig. | ||
// TODO(wallrj): This should not be required when an `--input-file` has been supplied. | ||
t.Setenv("KUBECONFIG", "testdata/agent/one-shot/success/kubeconfig.yaml") | ||
|
||
os.Args = []string{ | ||
"preflight", | ||
"agent", | ||
"--one-shot", | ||
// TODO(wallrj): This should not be required when an `--input-file` has been supplied. | ||
"--api-token=should-not-be-required", | ||
// TODO(wallrj): This should not be required when an `--input-file` has been supplied. | ||
"--install-namespace=default", | ||
"--agent-config-file=testdata/agent/one-shot/success/config.yaml", | ||
"--input-path=testdata/agent/one-shot/success/input.json", | ||
"--output-path=/dev/null", | ||
"-v=1", | ||
} | ||
Execute() | ||
return | ||
} | ||
t.Log("Running child process") | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) | ||
defer cancel() | ||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestAgentRunOneShot$") | ||
var ( | ||
stdout bytes.Buffer | ||
stderr bytes.Buffer | ||
) | ||
cmd.Stdout = &stdout | ||
cmd.Stderr = &stderr | ||
cmd.Env = append( | ||
os.Environ(), | ||
"GO_CHILD=true", | ||
) | ||
err := cmd.Run() | ||
|
||
stdoutStr := stdout.String() | ||
stderrStr := stderr.String() | ||
t.Logf("STDOUT\n%s\n", stdoutStr) | ||
t.Logf("STDERR\n%s\n", stderrStr) | ||
require.NoError(t, err, context.Cause(ctx)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Just enough venafi-kubernetes-agent config to allow it to run with an input | ||
# file in one-shot mode. | ||
cluster_id: "venafi-kubernetes-agent-e2e" | ||
organization_id: "venafi-kubernetes-agent-e2e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Just enough kubeconfig to satisfy client-go | ||
apiVersion: v1 | ||
kind: Config | ||
current-context: cluster-1 | ||
contexts: | ||
- name: cluster-1 | ||
context: | ||
cluster: cluster-1 | ||
user: user-1 | ||
clusters: | ||
- name: cluster-1 | ||
cluster: | ||
server: https://192.0.2.1:8443 | ||
preferences: {} | ||
users: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ config: | |
authentication: | ||
venafiConnection: | ||
enabled: true | ||
|
||
extraArgs: | ||
- --logging-format=json |
Oops, something went wrong.