cloudtest

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package cloudtest runs the steps of packs in tests, as a run does: the cloud service packs against local cloud emulators, the web pack against a site the test serves.

Index

Constants

View Source
const HostedEnv = "AXX_TEST_HOSTED"

HostedEnv, when set, gives every harness an axx host: the packs with a side in one (core.HostServer) do there what a run in a sandbox has the host do (web-core: start the browser), in this process, so the packs' tests run that way too.

Variables

This section is empty.

Functions

func AgainHosted added in v0.7.1

func AgainHosted(t *testing.T)

AgainHosted runs the package's tests again with HostedEnv set, in a process of their own: every step of a pack with a side in the host then crosses to the test's host and back. A package calls it from one test, in a file its integration build leaves out (a device's tests run hosted in CI's own parts). It does nothing in that second run, nor with -short.

func Emulator

func Emulator(t *testing.T, image, port, healthPath string, env map[string]string) string

Emulator starts a container and returns its host address for port ("localhost:49153"). It skips the test when Docker is unavailable.

func EmulatorWithDocker

func EmulatorWithDocker(t *testing.T, image, port, healthPath string, env map[string]string) string

EmulatorWithDocker is Emulator for emulators that run parts of a service in containers of their own (a message broker, say): the Docker socket is mounted.

func EmulatorWithSidecar added in v0.2.1

func EmulatorWithSidecar(t *testing.T, image, port, healthPath string, env map[string]string, sidecarImage, sidecarName, sidecarPort string) string

EmulatorWithSidecar is Emulator for an emulator that hands part of its work to a server of its own (floci-gcp its BigQuery SQL, to floci-duck): the two run on a network of their own, where the sidecar is named sidecarName and the emulator "emulator", so env can point each at the other (http://bigquery-sql:3000, http://emulator:4588).

func Server added in v0.1.5

func Server(t *testing.T, image, port string, cmd []string, env map[string]string) string

Server starts a server's container, with the command it runs when cmd is not empty, and returns its host address for port once the port listens. It skips the test when Docker is unavailable.

func ServerPorts added in v0.1.5

func ServerPorts(t *testing.T, image string, ports []string, cmd []string, env map[string]string) map[string]string

ServerPorts is Server for a server that listens on several ports: it returns the host address of each, once all of them listen.

func ValueProblems added in v0.3.0

func ValueProblems(t *testing.T, reg *match.Registry, text string) []string

ValueProblems are the messages of the values axx validate reports in a step.

Types

type Attachment added in v0.1.1

type Attachment struct {
	MediaType, Name string
	Body            []byte
}

Attachment is something a step attached.

type Harness

type Harness struct {
	Suite *core.Suite
	// Dir is the project directory: relative files resolve against it.
	Dir string
	SC  *core.Scenario
	// Sink records what the scenarios log and attach.
	Sink *Sink

	// HostAnswer answers what a pack's side in the test's host asks its
	// person to approve; nil approves.
	HostAnswer func(core.HostApproval) error
	// contains filtered or unexported fields
}

Harness runs step text against a set of packs, one scenario at a time.

func New

func New(t *testing.T, packs ...core.Pack) *Harness

New registers the core pack and packs, in order.

func NewWith added in v0.1.1

func NewWith(t *testing.T, config map[string]any, packs ...core.Pack) *Harness

NewWith is New with the packs' sections of axx.yaml, by pack name.

func NewWithServices added in v0.2.0

func NewWithServices(t *testing.T, services map[string]string, packs ...core.Pack) *Harness

NewWithServices is New with the services axx.yaml declares, as names and folders relative to the harness's project directory.

func (*Harness) End added in v0.1.1

func (h *Harness) End(status string) error

End ends the scenario as the runner does: it records the outcome ("passed", "failed"...) and runs the packs' cleanup.

func (*Harness) Fails

func (h *Harness) Fails(text, want string, arg ...any) error

Fails runs a step that must fail with an error containing want.

func (*Harness) File

func (h *Harness) File(name, content string)

File writes a file into the project directory.

func (*Harness) HostAsked added in v0.7.1

func (h *Harness) HostAsked() []core.HostApproval

HostAsked are what the packs' sides in the test's host asked its person to approve, in order.

func (*Harness) In added in v0.1.1

func (h *Harness) In(sc *core.Scenario) *Harness

In returns a harness that runs steps in another scenario of the same run, for scenarios running side by side. Use Step (not OK or Fails) from other goroutines. It takes only what does not change as h runs steps, so it can be called while h runs one.

func (*Harness) NewScenario

func (h *Harness) NewScenario() *core.Scenario

NewScenario starts the next scenario, at line 1 of features/test.feature; its steps are on the lines after it.

func (*Harness) NewScenarioWithin added in v0.1.5

func (h *Harness) NewScenarioWithin(limit time.Duration) *core.Scenario

NewScenarioWithin starts the next scenario, which may take up to limit: for one on a machine known to be slow, like a simulator on a hosted runner.

func (*Harness) OK

func (h *Harness) OK(text string, arg ...any)

OK runs a step that must pass.

func (*Harness) Plan

func (h *Harness) Plan(steps ...PlannedStep) *core.Plan

Plan is a planned scenario of step texts with their tables, matched the way the engine plans a run.

func (*Harness) Start

func (h *Harness) Start(plan *core.Plan)

Start prepares and initializes the packs for a planned run, as the engine does before the scenarios start.

func (*Harness) Step

func (h *Harness) Step(text string, arg ...any) (err error)

Step runs one step. A table is given as rows; a doc string as a string.

func (*Harness) ValueFails added in v0.3.0

func (h *Harness) ValueFails(text, want string)

ValueFails checks that a value in a step's own text that the rule cannot read (ADR 0014) fails the step with the message want and its code, as it runs, and that axx validate reports just that.

type PlannedStep

type PlannedStep struct {
	Text  string
	Table [][]string
}

PlannedStep is a step of a planned scenario.

type Sink added in v0.1.1

type Sink struct {
	Logs        []string
	Attachments []Attachment
	Announced   []string
	// contains filtered or unexported fields
}

Sink records scenario logs and attachments, and what packs announce to an IDE.

func (*Sink) Attach added in v0.1.1

func (s *Sink) Attach(_ *core.Scenario, mediaType string, body []byte, name string)

func (*Sink) Lines added in v0.1.1

func (s *Sink) Lines() []string

Lines are the lines announced to an IDE so far.

func (*Sink) Log added in v0.1.1

func (s *Sink) Log(_ *core.Scenario, msg string)

func (*Sink) Reset added in v0.1.1

func (s *Sink) Reset()

Reset forgets what was recorded.

Jump to

Keyboard shortcuts

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