e2e

package
v0.1.55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package e2e contains end-to-end tests for the FlatRun agent.

Prerequisites

Before running E2E tests, ensure: 1. FlatRun agent is running 2. Docker is available 3. Required environment variables are set

Environment Variables

FLATRUN_API_URL          - Agent API URL (default: http://localhost:8080/api)
FLATRUN_AUTH_TOKEN       - API authentication token (if auth enabled)
FLATRUN_DEPLOYMENTS_PATH - Path where deployments are stored (default: /tmp/flatrun-test-deployments)

Running Tests

Run all E2E tests:

go test -v ./test/e2e/...

Run specific test:

go test -v ./test/e2e/... -run TestStaticDeployment

Run without long-running tests:

go test -v -short ./test/e2e/...

Test Categories

## Unit Tests (templates/templates_test.go) Tests for the embedded templates package: - Template listing - Metadata parsing - Compose content validation - Priority values

## Template API Tests (test/e2e/templates_test.go) Tests for the /templates API endpoints: - GET /templates returns sorted templates - POST /templates/refresh updates templates - Template content validation

## Static Deployment Tests (test/e2e/static_test.go) Tests for static site deployments: - HTML file creation with template hooks - ${NAME} placeholder replacement - Compose file structure - Domain serving (requires proxy)

## WordPress Deployment Tests (test/e2e/wordpress_test.go) Tests for WordPress deployments: - Compose file creation - Database environment variables - Shared database integration - Domain serving (requires proxy + database)

Notes

- Some tests require the nginx proxy to be configured for *.localhost domains - WordPress tests may require a running MySQL/MariaDB container - Tests clean up after themselves but may leave artifacts on failure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertificateExists

func CertificateExists(domain string) bool

func ContainerHTTPGet

func ContainerHTTPGet(containerName string, port int) (int, string, error)

func GenerateCertForDomain

func GenerateCertForDomain(domain string) error

func GenerateTestName

func GenerateTestName(prefix string) string

func GetNginxHTTPSURL

func GetNginxHTTPSURL(domain string) string

func GetNginxHTTPURL

func GetNginxHTTPURL(domain string) string

func HTTPGet

func HTTPGet(url string) (int, string, error)

func HTTPGetWithHost

func HTTPGetWithHost(url, host string) (int, string, error)

func NginxConfigExists

func NginxConfigExists(deploymentName string) bool

func ReadNginxConfig

func ReadNginxConfig(deploymentName string) (string, error)

func ReloadNginx

func ReloadNginx() error

func WaitForContainerHTTP

func WaitForContainerHTTP(containerName string, port int, timeout time.Duration) error

func WaitForHTTP

func WaitForHTTP(url string, timeout time.Duration) error

func WaitForHTTPWithHost

func WaitForHTTPWithHost(url, host string, timeout time.Duration) error

func WaitForNginxProxy

func WaitForNginxProxy(containerName string, domain string, timeout time.Duration) error

Types

type APIClient

type APIClient struct {
	BaseURL    string
	AuthToken  string
	HTTPClient *http.Client
}

func NewAPIClient

func NewAPIClient() *APIClient

func (*APIClient) CreateDeployment

func (c *APIClient) CreateDeployment(req CreateDeploymentRequest) (*DeploymentResponse, error)

func (*APIClient) Delete

func (c *APIClient) Delete(path string) (*http.Response, error)

func (*APIClient) DeleteDeployment

func (c *APIClient) DeleteDeployment(name string) error

func (*APIClient) Get

func (c *APIClient) Get(path string) (*http.Response, error)

func (*APIClient) GetTemplates

func (c *APIClient) GetTemplates() (*TemplatesResponse, error)

func (*APIClient) Post

func (c *APIClient) Post(path string, body interface{}) (*http.Response, error)

func (*APIClient) RefreshTemplates

func (c *APIClient) RefreshTemplates() error

func (*APIClient) StartDeployment

func (c *APIClient) StartDeployment(name string) error

func (*APIClient) StopDeployment

func (c *APIClient) StopDeployment(name string) error

type CreateDeploymentRequest

type CreateDeploymentRequest struct {
	Name              string           `json:"name"`
	ComposeContent    string           `json:"compose_content"`
	TemplateID        string           `json:"template_id,omitempty"`
	Metadata          *ServiceMetadata `json:"metadata,omitempty"`
	EnvVars           []EnvVar         `json:"env_vars,omitempty"`
	AutoStart         bool             `json:"auto_start"`
	UseSharedDatabase bool             `json:"use_shared_database"`
}

type DeploymentResponse

type DeploymentResponse struct {
	Message     string       `json:"message"`
	Name        string       `json:"name"`
	ProxyResult *ProxyResult `json:"proxy_result,omitempty"`
	AutoStarted bool         `json:"auto_started"`
	StartOutput string       `json:"start_output,omitempty"`
	StartError  string       `json:"start_error,omitempty"`
}

type EnvVar

type EnvVar struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type HealthCheckConfig

type HealthCheckConfig struct {
	Path     string `json:"path,omitempty"`
	Interval string `json:"interval,omitempty"`
	Timeout  string `json:"timeout,omitempty"`
}

type NetworkingConfig

type NetworkingConfig struct {
	Expose        bool   `json:"expose"`
	Domain        string `json:"domain"`
	ContainerPort int    `json:"container_port"`
	Protocol      string `json:"protocol"`
	ProxyType     string `json:"proxy_type,omitempty"`
}

type ProxyResult

type ProxyResult struct {
	DeploymentName       string `json:"deployment_name"`
	Domain               string `json:"domain,omitempty"`
	Success              bool   `json:"success"`
	Skipped              bool   `json:"skipped"`
	Message              string `json:"message,omitempty"`
	VirtualHostCreated   bool   `json:"virtual_host_created"`
	NginxReloaded        bool   `json:"nginx_reloaded"`
	CertificateRequested bool   `json:"certificate_requested"`
	CertificateExists    bool   `json:"certificate_exists"`
	SSLMessage           string `json:"ssl_message,omitempty"`
	SSLError             string `json:"ssl_error,omitempty"`
}

type SSLConfig

type SSLConfig struct {
	Enabled  bool `json:"enabled"`
	AutoCert bool `json:"auto_cert"`
}

type ServiceMetadata

type ServiceMetadata struct {
	Name        string            `json:"name"`
	Type        string            `json:"type"`
	Networking  NetworkingConfig  `json:"networking"`
	SSL         SSLConfig         `json:"ssl"`
	HealthCheck HealthCheckConfig `json:"healthcheck,omitempty"`
}

type Template

type Template struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Priority    int    `json:"priority"`
	Content     string `json:"content"`
}

type TemplatesResponse

type TemplatesResponse struct {
	Templates []Template `json:"templates"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL