diff --git a/integrationtest/integration_test.go b/integrationtest/integration_test.go index 9328d91..d8433a5 100644 --- a/integrationtest/integration_test.go +++ b/integrationtest/integration_test.go @@ -30,6 +30,11 @@ const ( tail -f /dev/null ` clientEntryPointTemplate = ` + echo "HOSTNAME_OF_AGENT_ON_CLIENT=agent" + echo Ready + sleep 1000000 + ` + clientEntryPointTemplatex = ` curl -v http://converge:8000/downloads/wsproxy > wsproxy chmod 755 wsproxy echo "{{.privateKey}}" > id_rsa @@ -81,7 +86,7 @@ type IntegrationTestSuite struct { cancelFunc context.CancelFunc } -func Test_IntergrationTestSuite(t *testing.T) { +func Test_IntegrationTestSuite(t *testing.T) { suite.Run(t, &IntegrationTestSuite{}) } @@ -92,7 +97,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { } func (s *IntegrationTestSuite) SetupTest() { - ctx, cancelFunc := testsupport.CreateTestContext(context.Background(), 10*time.Second) + ctx, cancelFunc := testsupport.CreateTestContext(context.Background(), 60*time.Second) s.ctx = ctx s.cancelFunc = cancelFunc } @@ -144,17 +149,22 @@ func (s *IntegrationTestSuite) runCmdFailOnError(container testcontainers.Contai func (s *IntegrationTestSuite) defineContainer(net *testcontainers.DockerNetwork, hostname string, image string, - waitForLog string, + logLine string, ports []string) testcontainers.GenericContainerRequest { log.Printf("PORTS %v", ports) + waitStrategies := []wait.Strategy{wait.ForLog(logLine)} + if len(ports) > 0 { + waitStrategies = append(waitStrategies, wait.ForExposedPort()) + } + request := testcontainers.GenericContainerRequest{ ContainerRequest: testcontainers.ContainerRequest{ Image: image, ExposedPorts: ports, Hostname: hostname, - WaitingFor: wait.ForLog(waitForLog).WithStartupTimeout(10 * time.Second), + WaitingFor: wait.ForAll(waitStrategies...).WithStartupTimeoutDefault(30 * time.Second), LogConsumerCfg: createLogConsumerConfig(hostname), Networks: []string{net.Name}, //NetworkAliases: map[string][]string{ @@ -169,7 +179,8 @@ func (s *IntegrationTestSuite) defineContainer(net *testcontainers.DockerNetwork func (s *IntegrationTestSuite) Test_SingleAgentAndClient() { net, err := network.New(s.ctx) - s.Nil(err) + s.Require().Nil(err) + defer net.Remove(s.ctx) // SSH key to use privateKey, publicKey, err := sshsupport.GeneratePrivatePublicKey(2048) @@ -177,6 +188,7 @@ func (s *IntegrationTestSuite) Test_SingleAgentAndClient() { // The server + log.Println("Starting converge server") converge, err := testcontainers.GenericContainer(s.ctx, s.defineContainer(net, "converge", convergeImage, @@ -185,12 +197,14 @@ func (s *IntegrationTestSuite) Test_SingleAgentAndClient() { s.Require().Nil(err) err = converge.Start(s.ctx) s.Require().Nil(err) + defer converge.Terminate(s.ctx) + port, err := converge.MappedPort(s.ctx, "8000/tcp") s.Require().Nil(err) log.Printf("External port %v", port) // The agent - + log.Println("Starting agent") agentEntrypoint := testsupport.Template(agentEntryPointTemplate, map[string]string{"publicKey": publicKey}) @@ -200,10 +214,14 @@ func (s *IntegrationTestSuite) Test_SingleAgentAndClient() { "sh", "-c", agentEntrypoint} agent, err := testcontainers.GenericContainer(s.ctx, agentRequest) s.Require().Nil(err) - s.Require().Nil(agent.Start(s.ctx)) + err = agent.Start(s.ctx) + log.Printf("Error from starting agent %+v", err) + s.Require().Nil(err) + defer agent.Terminate(s.ctx) // The client + log.Println("Starting client") clientEntrypoint := testsupport.Template(clientEntryPointTemplate, map[string]string{"privateKey": privateKey}) clientRequest := s.defineContainer(net, "client", clientImage, @@ -212,13 +230,14 @@ func (s *IntegrationTestSuite) Test_SingleAgentAndClient() { "sh", "-c", clientEntrypoint} client, err := testcontainers.GenericContainer(s.ctx, clientRequest) s.Require().Nil(err) - s.Require().Nil(client.Start(s.ctx)) + err = client.Start(s.ctx) + log.Printf("Error from starting client %+v", err) + s.Require().Nil(err) + defer client.Terminate(s.ctx) input, err := client.Logs(s.ctx) s.Require().Nil(err) inputBytes, err := io.ReadAll(input) s.Require().Nil(err) s.True(strings.Contains(string(inputBytes), "HOSTNAME_OF_AGENT_ON_CLIENT=agent")) - - log.Printf("Found registry: %v", getRegistry()) } diff --git a/pkg/server/ui/basepage.templ b/pkg/server/ui/basepage.templ index f150486..4489abe 100644 --- a/pkg/server/ui/basepage.templ +++ b/pkg/server/ui/basepage.templ @@ -18,7 +18,7 @@ templ BasePage(tab int) { crossorigin="anonymous"> - + @@ -30,14 +30,13 @@ templ BasePage(tab int) {
diff --git a/static/images/wamblee_logo_go.25.png b/static/images/wamblee_logo_go.25.png new file mode 100644 index 0000000..84b92cf Binary files /dev/null and b/static/images/wamblee_logo_go.25.png differ