Documentation
¶
Index ¶
- Constants
- Variables
- func BaseCacheName() (string, error)
- func BaseConfigName() (string, error)
- func BaseConfigPath() (string, error)
- func BlockScoutDown(url string) error
- func BlockScoutUp(url, chainID string) error
- func BuildImage(dctx, dfile, nameAndTag string, buildArgs map[string]string) error
- func BuildImageOnce(once *sync.Once, dctx, dfile, nameAndTag string, buildArgs map[string]string) error
- func CheckCLNodeContainerErrors() error
- func DefaultNetwork(_ *sync.Once) error
- func DefaultTCLabels() map[string]string
- func DefaultTCName(name string) string
- func GenerateCustomPortsData(portsProvided []string) ([]string, nat.PortMap, error)
- func GetHost(container tc.Container) (string, error)
- func GetHostWithContext(ctx context.Context, container tc.Container) (string, error)
- func HostDockerInternal() string
- func IsDockerRunning() bool
- func Load[X any](t *testing.T) (*X, error)
- func LoadCache[X any](t *testing.T) (*X, error)
- func MapTheSamePort(ports ...string) nat.PortMap
- func MustParseDuration(s string) time.Duration
- func NewPromtail() error
- func NoDNS(noDNS bool, hc *container.HostConfig)
- func ObservabilityDown() error
- func ObservabilityUp() error
- func ObservabilityUpFull() error
- func ObservabilityUpOnlyLoki() error
- func RemoveTestContainers() error
- func RemoveTestStack(name string) error
- func RenderTemplate(tmpl string, data interface{}) (string, error)
- func ResourceLimitsFunc(h *container.HostConfig, resources *ContainerResources)
- func RunCommand(name string, args ...string) error
- func RunCommandDir(dir, name string, args ...string) error
- func SaveAndCheckLogs(t *testing.T) error
- func SaveContainerLogs(dir string) ([]string, error)
- func SearchLogFile(fp string, regex string) ([]string, error)
- func Store[T any](cfg *T) error
- func StreamContainerLogs(listOptions container.ListOptions, logOptions container.LogsOptions) (map[string]io.ReadCloser, error)
- func ToLabelsMap(response *PrometheusQueryResponse) map[string][]interface{}
- type APIError
- type Annotation
- type BasicAuth
- type CILoadChaosParams
- type CISmokeParams
- type CLDFParams
- type CLICompletionParams
- type CLIParams
- type Config
- type ConfigParams
- type ConfigTOMLParams
- type ContainerResources
- type DevEnvInterfaceParams
- type DockerClient
- func (dc *DockerClient) CopyFile(containerName, sourceFile, targetPath string) error
- func (dc *DockerClient) ExecContainer(containerName string, command []string) (string, error)
- func (dc *DockerClient) ExecContainerOptions(containerName string, execConfig container.ExecOptions) (string, error)
- func (dc *DockerClient) ExecContainerOptionsWithContext(ctx context.Context, containerName string, execConfig container.ExecOptions) (string, error)
- func (dc *DockerClient) ExecContainerWithContext(ctx context.Context, containerName string, command []string) (string, error)
- type EnvBuilder
- type EnvCodegen
- func (g *EnvCodegen) GenerateCILoadChaos() (string, error)
- func (g *EnvCodegen) GenerateCISmoke() (string, error)
- func (g *EnvCodegen) GenerateCLI(dashboardUUID string) (string, error)
- func (g *EnvCodegen) GenerateCLICompletion() (string, error)
- func (g *EnvCodegen) GenerateConfig() (string, error)
- func (g *EnvCodegen) GenerateDebugTools() (string, error)
- func (g *EnvCodegen) GenerateDefaultTOMLConfig() (string, error)
- func (g *EnvCodegen) GenerateEnvironment() (string, error)
- func (g *EnvCodegen) GenerateFakesDockerfile() (string, error)
- func (g *EnvCodegen) GenerateFakesGoModule() (string, error)
- func (g *EnvCodegen) GenerateFakesImpl() (string, error)
- func (g *EnvCodegen) GenerateFakesJustfile() (string, error)
- func (g *EnvCodegen) GenerateGitIgnore() (string, error)
- func (g *EnvCodegen) GenerateGoMod() (string, error)
- func (g *EnvCodegen) GenerateGrafanaDashboard(uuid string) (string, error)
- func (g *EnvCodegen) GenerateJD() (string, error)
- func (g *EnvCodegen) GenerateJustfile() (string, error)
- func (g *EnvCodegen) GenerateLoadTests() (string, error)
- func (g *EnvCodegen) GenerateProductBasicConfigParams() (string, error)
- func (g *EnvCodegen) GenerateProductCommon() (string, error)
- func (g *EnvCodegen) GenerateProductImpl() (string, error)
- func (g *EnvCodegen) GenerateProductSoakConfigParams() (string, error)
- func (g *EnvCodegen) GenerateProductsConfig() (string, error)
- func (g *EnvCodegen) GenerateProductsInterface() (string, error)
- func (g *EnvCodegen) GenerateReadme() (string, error)
- func (g *EnvCodegen) GenerateSmokeTests() (string, error)
- func (g *EnvCodegen) GenerateTableTest() (string, error)
- func (g *EnvCodegen) GenerateTestCases() ([]TestCaseParams, error)
- func (g *EnvCodegen) Read() error
- func (g *EnvCodegen) Write() error
- func (g *EnvCodegen) WriteFakes() error
- func (g *EnvCodegen) WriteProducts() error
- type EnvParams
- type GitIgnoreParams
- type GoModParams
- type GrafanaClient
- type GrafanaDashboardParams
- type JSONStrDuration
- type JustfileParams
- type LoadTestParams
- type LogEntry
- type LokiClient
- type PostAnnotationResponse
- type ProductBasicConfigParams
- type ProductCommonParams
- type ProductConfigParams
- type ProductConfigurationSimple
- type ProductFakesDockerfileParams
- type ProductFakesGoModuleParams
- type ProductFakesImplParams
- type ProductFakesJustfileParams
- type ProductImplParams
- type ProductSoakConfigParams
- type PromQueryResponseData
- type PromQueryResponseResult
- type PrometheusQueryClient
- type PrometheusQueryResponse
- type QueryParams
- type QueryRangeParams
- type QueryRangeResponse
- type ReadmeParams
- type Response
- type SmokeTestParams
- type TableTestParams
- type TestCaseParams
- type ToolsParams
- type ValidationError
Constants ¶
const ( EnvVarTestConfigs = "CTF_CONFIGS" //nolint EnvVarAWSSecretsManager = "CTF_AWS_SECRETS_MANAGER" // EnvVarCI this is a default env variable many CI runners use so code can detect we run in CI EnvVarCI = "CI" )
const ( DefaultConfigFilePath = "env.toml" DefaultOverridesFilePath = "overrides.toml" )
const ( LocalGrafanaBaseURL = "http://localhost:3000" LocalLokiBaseURL = "http://localhost:3030" LocalPrometheusBaseURL = "http://localhost:9099" LocalPyroscopeBaseURL = "http://localhost:4040" LocalCLNodeErrorsURL = "http://localhost:3000/d/a7de535b-3e0f-4066-bed7-d505b6ec9ef1/cl-node-errors?orgId=1&refresh=5s" LocalWorkflowEngineURL = "http://localhost:3000/d/ce589a98-b4be-4f80-bed1-bc62f3e4414a/workflow-engine?orgId=1&refresh=5s&from=now-15m&to=now" LocalLogsURL = "" /* 410-byte string literal not displayed */ LocalPrometheusURL = "" /* 350-byte string literal not displayed */ LocalPostgresDebugURL = "" /* 262-byte string literal not displayed */ LocalPyroScopeURL = "" /* 134-byte string literal not displayed */ CTFCacheDir = ".local/share/ctf" )
const ( // ProductDashboardUUID is a default product dashboard uuid, can be static since it's our local environment ProductDashboardUUID = "f8a04cef-653f-46d3-86df-87c532300672" ReadmeTmpl = `## Chainlink Developer Environment This template provides a complete Chainlink development environment with pre-configured infrastructure and observability tools, enabling rapid development while maintaining high quality standards. 🔧 Address all **TODO** comments and implement "product_configuration.go" 💻 Enter the shell: ` + "```" + `bash just cli && {{ .CLIName }} sh ` + "```" + ` 🚀 Spin up the environment ` + "```" + `bash up ↵ ` + "```" + ` 🔍 Implement system-level smoke tests (tests/smoke_test.go) and run them: ` + "```" + `bash test smoke ↵ ` + "```" + ` 📈 Implement load/chaos tests (tests/load_test.go) and run them: ` + "```" + `bash test load ↵ ` + "```" + ` 🔄 **Enforce** quality standards in CI: copy .github/workflows to your CI folder, commit and make them pass ` // ProductsInterfaceTmpl common interface for arbitrary products deployed in devenv ProductsInterfaceTmpl = `` /* 885-byte string literal not displayed */ // GoModTemplate go module template GoModTemplate = `` /* 726-byte string literal not displayed */ // GitIgnoreTmpl default gitignore template GitIgnoreTmpl = `compose/ blockscout/ env-out.toml` // GrafanaDashboardTmpl is a Grafana dashboard template for your product GrafanaDashboardTmpl = `` /* 18430-byte string literal not displayed */ // ConfigTOMLTmpl is a default env.toml template for devenv describind components configuration ConfigTOMLTmpl = `` /* 601-byte string literal not displayed */ // CILoadChaosTemplate is a continuous integration template for end-to-end load/chaos tests CILoadChaosTemplate = `` /* 2408-byte string literal not displayed */ // CISmokeTmpl is a continuous integration template for end-to-end smoke tests CISmokeTmpl = `` /* 2424-byte string literal not displayed */ // CompletionTmpl is a go-prompt library completion template providing interactive prompt CompletionTmpl = `` /* 5175-byte string literal not displayed */ // CLITmpl is a Cobra library CLI template with basic devenv commands CLITmpl = `` /* 8237-byte string literal not displayed */ // LoadTestTmpl is a load/chaos test template LoadTestTmpl = `` /* 3234-byte string literal not displayed */ SmokeTestImplTmpl = `` /* 914-byte string literal not displayed */ // JDTmpl is a JobDistributor client wrappers JDTmpl = `` /* 1998-byte string literal not displayed */ // DebugToolsTmpl is a template for various debug tools, tracing, tx debug, etc DebugToolsTmpl = `` /* 304-byte string literal not displayed */ // ConfigTmpl is a template for reading and writing devenv configuration (env.toml, env-out.toml) ConfigTmpl = `` /* 3672-byte string literal not displayed */ // EnvironmentTmpl is an environment.go template - main file for environment composition EnvironmentTmpl = `package {{ .PackageName }} import ( "context" "errors" "fmt" "os" "strings" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/framework" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/jd" "github.com/smartcontractkit/{{ .ProductName }}/devenv/products/{{ .ProductName }}" ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set" ) var L = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.DebugLevel).With().Fields(map[string]any{"component": "{{ .ProductName }}"}).Logger() type ProductInfo struct { Name string ` + "`" + `toml:"name"` + "`" + ` Instances int ` + "`" + `toml:"instances"` + "`" + ` } type Cfg struct { Products []*ProductInfo ` + "`" + `toml:"products"` + "`" + ` Blockchains []*blockchain.Input ` + "`" + `toml:"blockchains" validate:"required"` + "`" + ` FakeServer *fake.Input ` + "`" + `toml:"fake_server" validate:"required"` + "`" + ` NodeSets []*ns.Input ` + "`" + `toml:"nodesets" validate:"required"` + "`" + ` JD *jd.Input ` + "`" + `toml:"jd"` + "`" + ` } func newProduct(name string) (Product, error) { switch name { case "{{ .ProductName }}": return {{ .ProductName }}.NewConfigurator(), nil default: return nil, fmt.Errorf("unknown product type: %s", name) } } func NewEnvironment(ctx context.Context) error { if err := framework.DefaultNetwork(nil); err != nil { return err } in, err := Load[Cfg]() if err != nil { return fmt.Errorf("failed to load configuration: %w", err) } _, err = blockchain.NewBlockchainNetwork(in.Blockchains[0]) if err != nil { return fmt.Errorf("failed to create blockchain network 1337: %w", err) } if os.Getenv("FAKE_SERVER_IMAGE") != "" { in.FakeServer.Image = os.Getenv("FAKE_SERVER_IMAGE") } _, err = fake.NewDockerFakeDataProvider(in.FakeServer) if err != nil { return fmt.Errorf("failed to create fake data provider: %w", err) } // get all the product orchestrations, generate product specific overrides productConfigurators := make([]Product, 0) nodeConfigs := make([]string, 0) nodeSecrets := make([]string, 0) for _, product := range in.Products { p, err := newProduct(product.Name) if err != nil { return err } if err = p.Load(); err != nil { return fmt.Errorf("failed to load product config: %w", err) } cfg, err := p.GenerateNodesConfig(ctx, in.FakeServer, in.Blockchains[0], in.NodeSets[0]) if err != nil { return fmt.Errorf("failed to generate CL nodes config: %w", err) } nodeConfigs = append(nodeConfigs, cfg) secrets, err := p.GenerateNodesSecrets(ctx, in.FakeServer, in.Blockchains[0], in.NodeSets[0]) if err != nil { return fmt.Errorf("failed to generate CL nodes config: %w", err) } nodeSecrets = append(nodeSecrets, secrets) productConfigurators = append(productConfigurators, p) } // merge overrides, spin up node sets and write infrastructure outputs // infra is always common for all the products, if it can't be we should fail // user should use different infra layout in env.toml then for _, ns := range in.NodeSets[0].NodeSpecs { ns.Node.TestConfigOverrides = strings.Join(nodeConfigs, "\n") ns.Node.TestSecretsOverrides = strings.Join(nodeSecrets, "\n") if os.Getenv("CHAINLINK_IMAGE") != "" { ns.Node.Image = os.Getenv("CHAINLINK_IMAGE") } } _, err = ns.NewSharedDBNodeSet(in.NodeSets[0], nil) if err != nil { return fmt.Errorf("failed to create new shared db node set: %w", err) } if err := Store[Cfg](in); err != nil { return err } // deploy all products and all instances, // product config function controls what to read and how to orchestrate each instance // via their own TOML part, we only deploy N instances of product M for productIdx, productInfo := range in.Products { for productInstance := range productInfo.Instances { err = productConfigurators[productIdx].ConfigureJobsAndContracts( ctx, in.FakeServer, in.Blockchains[0], in.NodeSets[0], ) if err != nil { return fmt.Errorf("failed to setup default product deployment: %w", err) } if err := productConfigurators[productIdx].Store("env-out.toml", productInstance); err != nil { return errors.New("failed to store product config") } } } L.Info().Str("BootstrapNode", in.NodeSets[0].Out.CLNodes[0].Node.ExternalURL).Send() for _, n := range in.NodeSets[0].Out.CLNodes[1:] { L.Info().Str("Node", n.Node.ExternalURL).Send() } return nil } ` // JustFileTmpl is a Justfile template used for building and publishing Docker images JustFileTmpl = `` /* 311-byte string literal not displayed */ )
const ( ProductSoakConfigTmpl = `` /* 272-byte string literal not displayed */ ProductBasicConfigTmpl = `` /* 211-byte string literal not displayed */ ProductsImplTmpl = `package {{ .ProductName }} import ( "context" "fmt" "os" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake" nodeset "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set" "github.com/smartcontractkit/{{ .ProductName }}/devenv/products" ) var L = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.DebugLevel).With().Fields(map[string]any{"component": "{{ .ProductName }}"}).Logger() type ProductConfig struct { Out *ProductConfigOutput ` + "`" + `toml:"out"` + "`" + ` } type ProductConfigOutput struct { ExampleField string ` + "`" + `toml:"example"` + "`" + ` } type Configurator struct { Config []*ProductConfig ` + "`" + `toml:"{{ .ProductName }}"` + "`" + ` } func NewConfigurator() *Configurator { return &Configurator{} } func (m *Configurator) Load() error { cfg, err := products.Load[Configurator]() if err != nil { return fmt.Errorf("failed to load product config: %w", err) } m.Config = cfg.Config return nil } func (m *Configurator) Store(path string, idx int) error { if err := products.Store(".", m); err != nil { return fmt.Errorf("failed to store product config: %w", err) } return nil } func (m *Configurator) GenerateNodesConfig( ctx context.Context, fs *fake.Input, bc *blockchain.Input, ns *nodeset.Input, ) (string, error) { L.Info().Msg("Generating Chainlink node config") // node _ = bc.Out.Nodes[0] // chain ID _ = bc.Out.ChainID return "", nil } func (m *Configurator) GenerateNodesSecrets( ctx context.Context, fs *fake.Input, bc *blockchain.Input, ns *nodeset.Input, ) (string, error) { L.Info().Msg("Generating Chainlink node secrets") // node _ = bc.Out.Nodes[0] // chain ID _ = bc.Out.ChainID return "", nil } func (m *Configurator) ConfigureJobsAndContracts( ctx context.Context, fake *fake.Input, bc *blockchain.Input, ns *nodeset.Input, ) error { // write an example output of your product configuration // contract addresses, URLs, etc // in soak test case it may hold multiple configs and have different outputs // for each instance m.Config[0].Out = &ProductConfigOutput{ExampleField: "my_data"} L.Info().Msg("Configuring product: {{ .ProductName }}") return nil } ` ProductsConfigTmpl = `` /* 2435-byte string literal not displayed */ ProductsCommonTmpl = `` /* 4951-byte string literal not displayed */ )
const ( ProductFakesJustfile = `` /* 708-byte string literal not displayed */ ProductFakesImplTmpl = `` /* 700-byte string literal not displayed */ ProductFakesGoModuleTmpl = `` /* 363-byte string literal not displayed */ ProductFakesDockerfileTmpl = `` /* 314-byte string literal not displayed */ )
const (
DefaultCTFLogsDir = "logs/docker"
)
const (
DefaultConfigDir = "."
)
const (
EnvVarIgnoreCriticalLogs = "CTF_IGNORE_CRITICAL_LOGS"
)
const (
EnvVarLogLevel = "CTF_LOG_LEVEL"
)
Variables ¶
var ( DefaultNetworkName = "ctf" Validator = validator.New(validator.WithRequiredStructEnabled()) ValidatorTranslator ut.Translator )
var EmbeddedObservabilityFiles embed.FS
var ExitedCtfContainersListOpts = container.ListOptions{ All: true, Filters: dfilter.NewArgs(dfilter.KeyValuePair{ Key: "label", Value: "framework=ctf", }, dfilter.KeyValuePair{ Key: "status", Value: "exited"}, dfilter.KeyValuePair{ Key: "status", Value: "dead"}), }
var (
L zerolog.Logger
)
var (
PathRoot = filepath.Join(filepath.Dir(b), ".")
)
Functions ¶
func BaseCacheName ¶ added in v0.1.17
BaseCacheName returns base cache file name, ex.: env.toml -> env-cache.toml
func BaseConfigName ¶ added in v0.1.17
BaseConfigName returns base config name, ex. env.toml -> env
func BaseConfigPath ¶ added in v0.1.17
BaseConfigPath returns base config path, ex. env.toml,overrides.toml -> env.toml
func BlockScoutDown ¶ added in v0.1.17
func BlockScoutUp ¶ added in v0.1.17
func BuildImage ¶ added in v0.1.17
func BuildImageOnce ¶ added in v0.1.17
func CheckCLNodeContainerErrors ¶ added in v0.1.17
func CheckCLNodeContainerErrors() error
CheckCLNodeContainerErrors check if any CL node container logs has errors
func DefaultNetwork ¶ added in v0.1.1
func DefaultTCLabels ¶
func DefaultTCName ¶
func GenerateCustomPortsData ¶ added in v0.1.17
GenerateCustomPortsData generate custom ports data: exposed and forwarded port map
func GetHostWithContext ¶ added in v0.11.6
func HostDockerInternal ¶ added in v0.1.17
func HostDockerInternal() string
HostDockerInternal returns host.docker.internal that works both locally and in GHA
func IsDockerRunning ¶ added in v0.1.6
func IsDockerRunning() bool
func MapTheSamePort ¶
func MustParseDuration ¶ added in v0.1.17
MustParseDuration parses a duration string in Go's format and returns the corresponding time.Duration. It panics if the string cannot be parsed, ensuring that the caller receives a valid duration.
func NewPromtail ¶ added in v0.1.6
func NewPromtail() error
func NoDNS ¶ added in v0.1.17
func NoDNS(noDNS bool, hc *container.HostConfig)
NoDNS removes default DNS server and sets it to localhost
func ObservabilityDown ¶ added in v0.1.17
func ObservabilityDown() error
func ObservabilityUp ¶ added in v0.1.17
func ObservabilityUp() error
ObservabilityUp standard stack with logs/metrics for load testing and observability
func ObservabilityUpFull ¶ added in v0.1.17
func ObservabilityUpFull() error
ObservabilityUpFull full stack for load testing and performance investigations
func ObservabilityUpOnlyLoki ¶ added in v0.11.10
func ObservabilityUpOnlyLoki() error
ObservabilityUpOnlyLoki slim stack with only Loki to verify specific logs of CL nodes or services in tests
func RemoveTestContainers ¶ added in v0.1.17
func RemoveTestContainers() error
RemoveTestContainers removes all test containers, volumes and CTF docker network
func RemoveTestStack ¶ added in v0.1.17
func RenderTemplate ¶
func ResourceLimitsFunc ¶ added in v0.1.17
func ResourceLimitsFunc(h *container.HostConfig, resources *ContainerResources)
ResourceLimitsFunc returns a function to configure container resources based on the human-readable CPUs and memory in Mb
func RunCommand ¶ added in v0.1.17
RunCommand executes a command and prints the output.
func RunCommandDir ¶ added in v0.1.17
RunCommandDir executes a command in some directory and prints the output
func SaveAndCheckLogs ¶ added in v0.1.17
func SaveContainerLogs ¶ added in v0.1.17
SaveContainerLogs writes all Docker container logs to some directory
func SearchLogFile ¶ added in v0.1.17
SearchLogFile searches logfile using regex and return matches or error
func StreamContainerLogs ¶ added in v0.11.1
func StreamContainerLogs(listOptions container.ListOptions, logOptions container.LogsOptions) (map[string]io.ReadCloser, error)
func ToLabelsMap ¶ added in v0.1.17
func ToLabelsMap(response *PrometheusQueryResponse) map[string][]interface{}
ToLabelsMap converts PrometheusQueryResponse.Data.Result into a map where keys are metric labels in "k:v" format and values are slices of all values with that label
Types ¶
type APIError ¶ added in v0.1.17
APIError is a custom error type for handling non-200 responses from the Loki API
type Annotation ¶ added in v0.1.17
type CILoadChaosParams ¶ added in v0.12.0
CILoadChaosParams params for generating CI load&chaos tests file
type CISmokeParams ¶ added in v0.12.0
CISmokeParams params for generating CI smoke tests file
type CLDFParams ¶ added in v0.12.0
type CLDFParams struct {
PackageName string
}
CLDFParams cldf.go file params
type CLICompletionParams ¶ added in v0.12.0
CLICompletionParams cli.go file params
type CLIParams ¶ added in v0.12.0
type CLIParams struct {
PackageName string
CLIName string
DevEnvPkgImport string
ProductName string
DashboardUUID string
}
CLIParams cli.go file params
type ConfigParams ¶ added in v0.12.0
type ConfigParams struct {
PackageName string
}
ConfigParams config.go file params
type ConfigTOMLParams ¶ added in v0.12.0
ConfigTOMLParams default env.toml params
type ContainerResources ¶ added in v0.1.17
type DevEnvInterfaceParams ¶ added in v0.13.4
type DevEnvInterfaceParams struct {
PackageName string
}
DevEnvInterfaceParams interface.go file params
type DockerClient ¶ added in v0.1.17
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient wraps a Docker API client and provides convenience methods
func NewDockerClient ¶ added in v0.1.17
func NewDockerClient() (*DockerClient, error)
NewDockerClient creates a new instance of DockerClient
func (*DockerClient) CopyFile ¶ added in v0.1.17
func (dc *DockerClient) CopyFile(containerName, sourceFile, targetPath string) error
CopyFile copies a file into a container by name
func (*DockerClient) ExecContainer ¶ added in v0.1.17
func (dc *DockerClient) ExecContainer(containerName string, command []string) (string, error)
ExecContainer executes a command inside a running container by name and returns the combined stdout/stderr.
func (*DockerClient) ExecContainerOptions ¶ added in v0.10.36
func (dc *DockerClient) ExecContainerOptions(containerName string, execConfig container.ExecOptions) (string, error)
ExecContainer executes a command inside a running container by name and returns the combined stdout/stderr.
func (*DockerClient) ExecContainerOptionsWithContext ¶ added in v0.11.6
func (dc *DockerClient) ExecContainerOptionsWithContext(ctx context.Context, containerName string, execConfig container.ExecOptions) (string, error)
ExecContainerOptionsWithContext executes a command inside a running container by name and returns the combined stdout/stderr.
func (*DockerClient) ExecContainerWithContext ¶ added in v0.11.6
func (dc *DockerClient) ExecContainerWithContext(ctx context.Context, containerName string, command []string) (string, error)
ExecContainerWithContext executes a command inside a running container by name and returns the combined stdout/stderr.
type EnvBuilder ¶ added in v0.12.0
type EnvBuilder struct {
// contains filtered or unexported fields
}
EnvBuilder builder for load test codegen
func NewEnvBuilder ¶ added in v0.12.0
func NewEnvBuilder(cliName string, nodes int, productName string) *EnvBuilder
NewEnvBuilder creates a new Chainlink Cluster developer environment
func (*EnvBuilder) Build ¶ added in v0.12.0
func (g *EnvBuilder) Build() (*EnvCodegen, error)
Validate validate generation params for now it's empty but for more complex mutually exclusive cases we should add validation here
func (*EnvBuilder) OutputDir ¶ added in v0.12.0
func (g *EnvBuilder) OutputDir(dir string) *EnvBuilder
OutputDir sets the output directory for generated files
type EnvCodegen ¶ added in v0.12.0
type EnvCodegen struct {
// contains filtered or unexported fields
}
EnvCodegen is a load test code generator that creates workload and chaos experiments
func (*EnvCodegen) GenerateCILoadChaos ¶ added in v0.12.0
func (g *EnvCodegen) GenerateCILoadChaos() (string, error)
GenerateCILoadChaos generates a load&chaos test CI workflow
func (*EnvCodegen) GenerateCISmoke ¶ added in v0.12.0
func (g *EnvCodegen) GenerateCISmoke() (string, error)
GenerateCISmoke generates a smoke test CI workflow
func (*EnvCodegen) GenerateCLI ¶ added in v0.12.0
func (g *EnvCodegen) GenerateCLI(dashboardUUID string) (string, error)
GenerateCLI generate Cobra CLI
func (*EnvCodegen) GenerateCLICompletion ¶ added in v0.12.0
func (g *EnvCodegen) GenerateCLICompletion() (string, error)
GenerateCLICompletion generate CLI completion for "go-prompt" library
func (*EnvCodegen) GenerateConfig ¶ added in v0.12.0
func (g *EnvCodegen) GenerateConfig() (string, error)
GenerateConfig generate read/write utilities for TOML configs
func (*EnvCodegen) GenerateDebugTools ¶ added in v0.12.0
func (g *EnvCodegen) GenerateDebugTools() (string, error)
GenerateDebugTools generate debug tools (tracing)
func (*EnvCodegen) GenerateDefaultTOMLConfig ¶ added in v0.12.0
func (g *EnvCodegen) GenerateDefaultTOMLConfig() (string, error)
GenerateDefaultTOMLConfig generate default env.toml config
func (*EnvCodegen) GenerateEnvironment ¶ added in v0.12.0
func (g *EnvCodegen) GenerateEnvironment() (string, error)
GenerateEnvironment generate environment.go, our environment composition function
func (*EnvCodegen) GenerateFakesDockerfile ¶ added in v0.13.4
func (g *EnvCodegen) GenerateFakesDockerfile() (string, error)
func (*EnvCodegen) GenerateFakesGoModule ¶ added in v0.13.4
func (g *EnvCodegen) GenerateFakesGoModule() (string, error)
func (*EnvCodegen) GenerateFakesImpl ¶ added in v0.13.4
func (g *EnvCodegen) GenerateFakesImpl() (string, error)
func (*EnvCodegen) GenerateFakesJustfile ¶ added in v0.13.4
func (g *EnvCodegen) GenerateFakesJustfile() (string, error)
func (*EnvCodegen) GenerateGitIgnore ¶ added in v0.12.0
func (g *EnvCodegen) GenerateGitIgnore() (string, error)
GenerateGitIgnore generate .gitignore file
func (*EnvCodegen) GenerateGoMod ¶ added in v0.12.0
func (g *EnvCodegen) GenerateGoMod() (string, error)
GenerateGoMod generates a go.mod file
func (*EnvCodegen) GenerateGrafanaDashboard ¶ added in v0.12.0
func (g *EnvCodegen) GenerateGrafanaDashboard(uuid string) (string, error)
GenerateGrafanaDashboard generate default Grafana dashboard
func (*EnvCodegen) GenerateJD ¶ added in v0.13.4
func (g *EnvCodegen) GenerateJD() (string, error)
GenerateJD generate JD helpers
func (*EnvCodegen) GenerateJustfile ¶ added in v0.12.0
func (g *EnvCodegen) GenerateJustfile() (string, error)
GenerateJustfile generate Justfile to build and publish Docker images
func (*EnvCodegen) GenerateLoadTests ¶ added in v0.12.0
func (g *EnvCodegen) GenerateLoadTests() (string, error)
GenerateSmokeTests generates a smoke test template
func (*EnvCodegen) GenerateProductBasicConfigParams ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductBasicConfigParams() (string, error)
func (*EnvCodegen) GenerateProductCommon ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductCommon() (string, error)
func (*EnvCodegen) GenerateProductImpl ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductImpl() (string, error)
func (*EnvCodegen) GenerateProductSoakConfigParams ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductSoakConfigParams() (string, error)
func (*EnvCodegen) GenerateProductsConfig ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductsConfig() (string, error)
func (*EnvCodegen) GenerateProductsInterface ¶ added in v0.13.4
func (g *EnvCodegen) GenerateProductsInterface() (string, error)
GenerateProductsInterface generate devenv interface to run arbitrary products
func (*EnvCodegen) GenerateReadme ¶ added in v0.12.0
func (g *EnvCodegen) GenerateReadme() (string, error)
GenerateReadme generates a readme file
func (*EnvCodegen) GenerateSmokeTests ¶ added in v0.12.0
func (g *EnvCodegen) GenerateSmokeTests() (string, error)
GenerateSmokeTests generates a smoke test template
func (*EnvCodegen) GenerateTableTest ¶ added in v0.12.0
func (g *EnvCodegen) GenerateTableTest() (string, error)
GenerateTableTest generates all possible experiments for a namespace first generate all small pieces then insert into a table test template
func (*EnvCodegen) GenerateTestCases ¶ added in v0.12.0
func (g *EnvCodegen) GenerateTestCases() ([]TestCaseParams, error)
GenerateTestCases generates table test cases
func (*EnvCodegen) Read ¶ added in v0.12.0
func (g *EnvCodegen) Read() error
Read read K8s namespace and find all the pods some pods may be crashing but it doesn't matter for code generation
func (*EnvCodegen) Write ¶ added in v0.12.0
func (g *EnvCodegen) Write() error
Write generates a complete devenv boilerplate, can be multiple files
func (*EnvCodegen) WriteFakes ¶ added in v0.13.4
func (g *EnvCodegen) WriteFakes() error
WriteFakes writes all files related to fake services used in testing
func (*EnvCodegen) WriteProducts ¶ added in v0.13.4
func (g *EnvCodegen) WriteProducts() error
WriteProducts generates a complete products boilerplate
type GitIgnoreParams ¶ added in v0.12.0
type GitIgnoreParams struct{}
GitIgnoreParams default .gitignore params
type GoModParams ¶ added in v0.12.0
GoModParams params for generating go.mod file
type GrafanaClient ¶ added in v0.1.17
type GrafanaClient struct {
// contains filtered or unexported fields
}
func NewGrafanaClient ¶ added in v0.1.17
func NewGrafanaClient(url, bearerToken string) *GrafanaClient
NewGrafanaClient initializes a new Grafana client with the specified URL and API key.
func (*GrafanaClient) Annotate ¶ added in v0.1.17
func (c *GrafanaClient) Annotate(annotation Annotation) ([]PostAnnotationResponse, []*resty.Response, error)
Annotate adds annotation to all the dashboards, works for both single point annotation with just StartTime and for ranges with StartTime/EndTime
type GrafanaDashboardParams ¶ added in v0.12.0
GrafanaDashboardParams default Grafana dashboard params
type JSONStrDuration ¶ added in v0.1.1
JSONStrDuration is JSON friendly duration that can be parsed from "1h2m0s" Go format
func (*JSONStrDuration) MarshalJSON ¶ added in v0.1.1
func (d *JSONStrDuration) MarshalJSON() ([]byte, error)
func (*JSONStrDuration) UnmarshalJSON ¶ added in v0.1.1
func (d *JSONStrDuration) UnmarshalJSON(b []byte) error
type JustfileParams ¶ added in v0.12.0
JustfileParams Justfile params
type LoadTestParams ¶ added in v0.12.0
LoadTestParams params for generating end-to-end test template
type LogEntry ¶ added in v0.1.17
LogEntry represents a single log entry with a timestamp and raw log message
type LokiClient ¶ added in v0.1.17
type LokiClient struct {
BaseURL string
TenantID string
BasicAuth BasicAuth
QueryParams QueryParams
RestyClient *resty.Client
}
LokiClient represents a client to interact with Loki for querying logs
func NewLokiQueryClient ¶ added in v0.1.17
func NewLokiQueryClient(baseURL, tenantID string, auth BasicAuth, queryParams QueryParams) *LokiClient
NewLokiQueryClient creates a new Loki client with the given parameters, initializes a logger, and configures Resty with debug mode
func (*LokiClient) QueryRange ¶ added in v0.1.17
func (lc *LokiClient) QueryRange(ctx context.Context) ([]LogEntry, error)
QueryRange queries Loki logs based on the query parameters and returns the raw log entries
type PostAnnotationResponse ¶ added in v0.1.17
type ProductBasicConfigParams ¶ added in v0.13.4
type ProductBasicConfigParams struct {
ProductName string
}
type ProductCommonParams ¶ added in v0.13.4
type ProductCommonParams struct{}
type ProductConfigParams ¶ added in v0.13.4
type ProductConfigParams struct{}
type ProductConfigurationSimple ¶ added in v0.12.0
type ProductConfigurationSimple struct {
PackageName string
}
ProductConfigurationSimple product_configuration.go file params
type ProductFakesDockerfileParams ¶ added in v0.13.4
type ProductFakesDockerfileParams struct{}
type ProductFakesGoModuleParams ¶ added in v0.13.4
type ProductFakesImplParams ¶ added in v0.13.4
type ProductFakesImplParams struct {
ProductName string
}
type ProductFakesJustfileParams ¶ added in v0.13.4
type ProductFakesJustfileParams struct {
ProductName string
}
type ProductImplParams ¶ added in v0.13.4
type ProductImplParams struct {
ProductName string
}
type ProductSoakConfigParams ¶ added in v0.13.4
type ProductSoakConfigParams struct {
ProductName string
}
type PromQueryResponseData ¶ added in v0.13.1
type PromQueryResponseData struct {
ResultType string `json:"resultType"`
Result []PromQueryResponseResult `json:"result"`
}
type PromQueryResponseResult ¶ added in v0.13.1
type PrometheusQueryClient ¶ added in v0.1.17
type PrometheusQueryClient struct {
// contains filtered or unexported fields
}
PrometheusQueryClient is a client for querying Prometheus metrics
func NewPrometheusQueryClient ¶ added in v0.1.17
func NewPrometheusQueryClient(baseURL string) *PrometheusQueryClient
NewPrometheusQueryClient creates a new PrometheusQueryClient
func (*PrometheusQueryClient) Query ¶ added in v0.1.17
func (p *PrometheusQueryClient) Query(query string, timestamp time.Time) (*PrometheusQueryResponse, error)
Query executes an instant query against the Prometheus API
func (*PrometheusQueryClient) QueryRange ¶ added in v0.1.17
func (p *PrometheusQueryClient) QueryRange(params QueryRangeParams) (*QueryRangeResponse, error)
QueryRange executes a range query against the Prometheus API
type PrometheusQueryResponse ¶ added in v0.1.17
type PrometheusQueryResponse struct {
Status string `json:"status"`
Data *PromQueryResponseData `json:"data"`
}
PrometheusQueryResponse represents the response from Prometheus API
type QueryParams ¶ added in v0.1.17
QueryParams holds the parameters required for querying Loki
type QueryRangeParams ¶ added in v0.1.17
QueryRangeParams contains parameters for range queries
type QueryRangeResponse ¶ added in v0.1.17
type QueryRangeResponse struct {
Status string `json:"status"`
Data struct {
ResultType string `json:"resultType"`
Result []struct {
Metric map[string]string `json:"metric"`
Values [][]interface{} `json:"values"`
} `json:"result"`
} `json:"data"`
}
QueryRangeResponse represents the response from Prometheus range query API
type ReadmeParams ¶ added in v0.12.0
type ReadmeParams struct {
CLIName string
}
ReadmeParams params for generating README.md file
type Response ¶ added in v0.1.17
type Response struct {
Data struct {
Result []struct {
Stream map[string]string `json:"stream"`
Values [][]interface{} `json:"values"`
} `json:"result"`
} `json:"data"`
}
Response represents the structure of the response from Loki
type SmokeTestParams ¶ added in v0.12.0
SmokeTestParams params for generating end-to-end test template
type TableTestParams ¶ added in v0.12.0
type TableTestParams struct {
Package string
TableTestName string
TestCases []TestCaseParams
WorkloadCode string
GunCode string
}
TableTestParams params for generating a table test
type TestCaseParams ¶ added in v0.12.0
TestCaseParams params for generating a test case
type ToolsParams ¶ added in v0.12.0
type ToolsParams struct {
PackageName string
}
ToolsParams tools.go file params