-
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.
#208. ADD e2e_composability_test: set up basic tests to ensure that t…
…he composed packages flux and games are properly deployed together. UPDATE examples/Makefile with the package-example-composability command and added that command to the package-examples command. RENAME examples/composable-example -> examples/composable-packages
- Loading branch information
1 parent
c5943ee
commit a0cd189
Showing
3 changed files
with
68 additions
and
1 deletion.
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
File renamed without changes.
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,63 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
teststructure "github.com/gruntwork-io/terratest/modules/test-structure" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestE2eExampleComposability(t *testing.T) { | ||
|
||
e2e := NewE2ETest(t) | ||
|
||
// 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) | ||
|
||
// 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") | ||
}) | ||
|
||
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) | ||
|
||
// 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) | ||
|
||
// 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, "flux-baseline", output) | ||
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) | ||
|
||
// Validate that the flux composed component was deployed by describing the flux helm controller and validating availibility | ||
output, err = e2e.runSSHCommand(`sudo bash -c '/usr/sbin/kubectl describe deployment helm-controller -n flux-system'`) | ||
require.NoError(e2e.testing, err, output) | ||
require.Contains(e2e.testing, "1 desired | 1 updated | 1 total | 1 available | 0 unavailable", 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) | ||
}) | ||
|
||
} |