-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…s. Update .github/workflows/test*: add package-compose-example to make packages stage. UPDATE packager/compose: rename GetComposedAssets to GetComposedComponents UPDATE reference in packager/create. refactored and rename hasValidSubPackage to validateOrBail. Rename shouldAddImportedPackage to shouldComposePackage. Extracted component required logic to componentConfirmedForInclusion. UPDATE e2e/e2e_composability_test: to work with new testing strategy.
- Loading branch information
1 parent
2c19cfa
commit f27d0f2
Showing
7 changed files
with
91 additions
and
90 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
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
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 |
---|---|---|
@@ -1,57 +1,41 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
teststructure "github.com/gruntwork-io/terratest/modules/test-structure" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestE2eExampleComposability(t *testing.T) { | ||
//run `zarf init` | ||
output, err := e2e.execZarfCommand("init", "--confirm") | ||
require.NoError(t, err, output) | ||
|
||
e2e := NewE2ETest(t) | ||
// Deploy the composable game package | ||
output, err = e2e.execZarfCommand("package", "deploy", "../../build/zarf-package-compose-example.tar.zst", "--confirm") | ||
require.NoError(t, err, output) | ||
|
||
// At the end of the test, run `terraform destroy` to clean up any resources that were created | ||
defer teststructure.RunTestStage(e2e.testing, "TEARDOWN", e2e.teardown) | ||
// Validate that the composed sub packages exist | ||
require.Contains(t, output, "appliance-demo-multi-games-baseline") | ||
|
||
// Upload the Zarf artifacts | ||
teststructure.RunTestStage(e2e.testing, "UPLOAD", func() { | ||
e2e.syncFileToRemoteServer("../../build/zarf", fmt.Sprintf("/home/%s/build/zarf", e2e.username), "0700") | ||
e2e.syncFileToRemoteServer("../../build/zarf-init.tar.zst", fmt.Sprintf("/home/%s/build/zarf-init.tar.zst", e2e.username), "0600") | ||
e2e.syncFileToRemoteServer("../../build/zarf-package-compose-example.tar.zst", fmt.Sprintf("/home/%s/build/zarf-package-compose-example.tar.zst", e2e.username), "0600") | ||
}) | ||
// Establish the port-forward into the game service | ||
err = e2e.execZarfBackgroundCommand("connect", "doom", "--local-port=22333") | ||
require.NoError(t, err, "unable to connect to the doom port-forward") | ||
|
||
teststructure.RunTestStage(e2e.testing, "TEST", func() { | ||
// Make sure `zarf --help` doesn't error | ||
output, err := e2e.runSSHCommand("sudo /home/%s/build/zarf --help", e2e.username) | ||
require.NoError(e2e.testing, err, output) | ||
// Right now we're just checking that `curl` returns 0. It can be enhanced by scraping the HTML that gets returned or something. | ||
resp, err := http.Get("http://127.0.0.1:22333?doom") | ||
assert.NoError(t, err, resp) | ||
|
||
// run `zarf init` | ||
output, err = e2e.runSSHCommand("sudo bash -c 'cd /home/%s/build && ./zarf init --confirm --components k3s'", e2e.username) | ||
require.NoError(e2e.testing, err, output) | ||
// Read the body into string | ||
body, err := io.ReadAll(resp.Body) | ||
assert.NoError(t, err, body) | ||
|
||
// Deploy the composable package | ||
output, err = e2e.runSSHCommand("sudo bash -c 'cd /home/%s/build && ./zarf package deploy zarf-package-composable-example.tar.zst --confirm'", e2e.username) | ||
require.NoError(e2e.testing, err, output) | ||
|
||
// Validate that the composed sub packages exist | ||
require.Contains(e2e.testing, "appliance-demo-multi-games-baseline", output) | ||
|
||
// Establish the port-forward into the game service; give the service a few seconds to come up since this is not a command we can retry | ||
time.Sleep(5 * time.Second) | ||
output, err = e2e.runSSHCommand("sudo bash -c '(/home/%s/build/zarf connect doom --local-port 22333 &> /dev/nul &)'", e2e.username) | ||
require.NoError(e2e.testing, err, output) | ||
|
||
// Right now we're just checking that `curl` returns 0. It can be enhanced by scraping the HTML that gets returned or something. | ||
output, err = e2e.runSSHCommand("bash -c '[[ $(curl -sfSL --retry 15 --retry-connrefused --retry-delay 5 http://127.0.0.1:22333?doom') ]]'") | ||
require.NoError(e2e.testing, err, output) | ||
require.Contains(e2e.testing, "Zarf needs games too", output) | ||
|
||
// Run `zarf destroy` to make sure that works correctly | ||
output, err = e2e.runSSHCommand("sudo bash -c 'cd /home/%s/build && ./zarf destroy --confirm'", e2e.username) | ||
require.NoError(e2e.testing, err, output) | ||
}) | ||
// Validate the doom title in body. | ||
assert.Contains(t, string(body), "Zarf needs games too") | ||
assert.Equal(t, 200, resp.StatusCode) | ||
|
||
e2e.cleanupAfterTest(t) | ||
} |