(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestComponentStatus(t *testing.T) { |
| 21 | t.Log("E2E: Component Status") |
| 22 | tmpDir := t.TempDir() |
| 23 | _, _, err := e2e.Zarf(t, "package", "create", "src/test/packages/37-component-status", "-o", tmpDir, "--confirm") |
| 24 | require.NoError(t, err) |
| 25 | packageName := fmt.Sprintf("zarf-package-component-status-%s.tar.zst", e2e.Arch) |
| 26 | path := filepath.Join(tmpDir, packageName) |
| 27 | // Stop channel getting the zarf state |
| 28 | stop := make(chan bool) |
| 29 | // Error channel to return any errors from the goroutine. Testify doesn't like require in a goroutine |
| 30 | errCh := make(chan error, 1) |
| 31 | var wg sync.WaitGroup |
| 32 | wg.Add(1) |
| 33 | // Goroutine to wait for the package to show "deploying" status |
| 34 | go func() { |
| 35 | defer wg.Done() |
| 36 | // Give extra time to build and push the package |
| 37 | ticker := time.NewTicker(30 * time.Second) |
| 38 | for { |
| 39 | select { |
| 40 | case <-ticker.C: |
| 41 | t.Log("Timed out waiting for package to deploy") |
| 42 | errCh <- fmt.Errorf("timed out waiting for package to deploy") |
| 43 | return |
| 44 | case <-stop: |
| 45 | return |
| 46 | default: |
| 47 | stdOut, _, err := e2e.Kubectl(t, "get", "secret", "zarf-package-component-status", "-n", "zarf", "-o", "jsonpath={.data.data}") |
| 48 | if err != nil { |
| 49 | // Wait for the secret to be created and try again |
| 50 | time.Sleep(2 * time.Second) |
| 51 | continue |
| 52 | } |
| 53 | deployedPackage, err := getDeployedPackage(stdOut) |
| 54 | if err != nil { |
| 55 | errCh <- err |
| 56 | return |
| 57 | } |
| 58 | if len(deployedPackage.DeployedComponents) != 1 { |
| 59 | errCh <- fmt.Errorf("expected 1 component got %d", len(deployedPackage.DeployedComponents)) |
| 60 | return |
| 61 | } |
| 62 | status := deployedPackage.DeployedComponents[0].Status |
| 63 | if status != state.ComponentStatusDeploying { |
| 64 | errCh <- fmt.Errorf("expected %s got %s", state.ComponentStatusDeploying, status) |
| 65 | return |
| 66 | } |
| 67 | time.Sleep(2 * time.Second) |
| 68 | return |
| 69 | } |
| 70 | } |
| 71 | }() |
| 72 | stdOut, stdErr, err := e2e.Zarf(t, "package", "deploy", path, "--confirm") |
| 73 | require.NoError(t, err, stdOut, stdErr) |
| 74 | close(stop) |
| 75 | wg.Wait() |
| 76 | select { |
| 77 | case err := <-errCh: |
nothing calls this directly
no test coverage detected