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 ¶
- func CertificateExists(domain string) bool
- func ContainerHTTPGet(containerName string, port int) (int, string, error)
- func GenerateCertForDomain(domain string) error
- func GenerateTestName(prefix string) string
- func GetNginxHTTPSURL(domain string) string
- func GetNginxHTTPURL(domain string) string
- func HTTPGet(url string) (int, string, error)
- func HTTPGetWithHost(url, host string) (int, string, error)
- func NginxConfigExists(deploymentName string) bool
- func ReadNginxConfig(deploymentName string) (string, error)
- func ReloadNginx() error
- func WaitForContainerHTTP(containerName string, port int, timeout time.Duration) error
- func WaitForHTTP(url string, timeout time.Duration) error
- func WaitForHTTPWithHost(url, host string, timeout time.Duration) error
- func WaitForNginxProxy(containerName string, domain string, timeout time.Duration) error
- type APIClient
- func (c *APIClient) CreateDeployment(req CreateDeploymentRequest) (*DeploymentResponse, error)
- func (c *APIClient) Delete(path string) (*http.Response, error)
- func (c *APIClient) DeleteDeployment(name string) error
- func (c *APIClient) Get(path string) (*http.Response, error)
- func (c *APIClient) GetTemplates() (*TemplatesResponse, error)
- func (c *APIClient) Post(path string, body interface{}) (*http.Response, error)
- func (c *APIClient) RefreshTemplates() error
- func (c *APIClient) StartDeployment(name string) error
- func (c *APIClient) StopDeployment(name string) error
- type CreateDeploymentRequest
- type DeploymentResponse
- type EnvVar
- type HealthCheckConfig
- type NetworkingConfig
- type ProxyResult
- type SSLConfig
- type ServiceMetadata
- type Template
- type TemplatesResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CertificateExists ¶
func GenerateCertForDomain ¶
func GenerateTestName ¶
func GetNginxHTTPSURL ¶
func GetNginxHTTPURL ¶
func NginxConfigExists ¶
func ReadNginxConfig ¶
func ReloadNginx ¶
func ReloadNginx() error
func WaitForContainerHTTP ¶
Types ¶
type APIClient ¶
func NewAPIClient ¶
func NewAPIClient() *APIClient
func (*APIClient) CreateDeployment ¶
func (c *APIClient) CreateDeployment(req CreateDeploymentRequest) (*DeploymentResponse, error)
func (*APIClient) DeleteDeployment ¶
func (*APIClient) GetTemplates ¶
func (c *APIClient) GetTemplates() (*TemplatesResponse, error)
func (*APIClient) RefreshTemplates ¶
func (*APIClient) StartDeployment ¶
func (*APIClient) StopDeployment ¶
type CreateDeploymentRequest ¶
type DeploymentResponse ¶
type HealthCheckConfig ¶
type NetworkingConfig ¶
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 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 TemplatesResponse ¶
type TemplatesResponse struct {
Templates []Template `json:"templates"`
}