Skip to content

Commit

Permalink
add loop check for data injected after pod comes up
Browse files Browse the repository at this point in the history
  • Loading branch information
YrrepNoj committed Mar 30, 2022
1 parent 3ddc741 commit 9b73df8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/internal/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func handleDataInjection(wg *sync.WaitGroup, data types.ZarfDataInjection, compo
destination = "/"
}

// Inject into all the pods that
// Inject into all the pods
for _, pod := range pods {
cpPodExecArgs := []string{"-n", data.Target.Namespace, "cp", sourceFile, pod + ":" + destination}

Expand Down
9 changes: 8 additions & 1 deletion test/e2e/e2e_data_injection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -35,8 +36,14 @@ func TestDataInjection(t *testing.T) {
assert.Contains(t, execStdOut, "subdirectory-test")

// Test to confirm the subdirectory file was placed
// NOTE: This data gets injected after pod comes up as 'healthy' so we need to retry the check until it is able to populate
execStdOut = ""
execStdOut, _, err = e2e.execCommandInPod(podname, namespace, []string{"ls", "/test/subdirectory-test"})
attempt := 0
for attempt < 10 && execStdOut == "" {
execStdOut, _, err = e2e.execCommandInPod(podname, namespace, []string{"ls", "/test/subdirectory-test"})
attempt++
time.Sleep(2 * time.Second)
}
assert.NoError(t, err)
assert.Contains(t, execStdOut, "this-is-an-example-file.txt")
}

0 comments on commit 9b73df8

Please sign in to comment.