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 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) GenerateCLDF() (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) GenerateGitIgnore() (string, error)
- func (g *EnvCodegen) GenerateGoMod() (string, error)
- func (g *EnvCodegen) GenerateGrafanaDashboard(uuid string) (string, error)
- func (g *EnvCodegen) GenerateJustfile() (string, error)
- func (g *EnvCodegen) GenerateLoadTests() (string, error)
- func (g *EnvCodegen) GenerateReadme() (string, error)
- func (g *EnvCodegen) GenerateSingleNetworkProductConfiguration() (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
- type EnvParams
- type GitIgnoreParams
- type GoModParams
- type GrafanaClient
- type GrafanaDashboardParams
- type JSONStrDuration
- type JustfileParams
- type LoadTestParams
- type LogEntry
- type LokiClient
- type PostAnnotationResponse
- type ProductConfigurationSimple
- 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" 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 */ )
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 ` // 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 = `` /* 782-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 = `` /* 4841-byte string literal not displayed */ // CLITmpl is a Cobra library CLI template with basic devenv commands CLITmpl = `` /* 8201-byte string literal not displayed */ // LoadTestTmpl is a load/chaos test template LoadTestTmpl = `` /* 2958-byte string literal not displayed */ // SmokeTestTmpl is a smoke test template SmokeTestTmpl = `` /* 2085-byte string literal not displayed */ // CLDFTmpl is a Chainlink Deployments Framework template CLDFTmpl = `` /* 13403-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 = `` /* 4534-byte string literal not displayed */ // EnvironmentTmpl is an environment.go template - main file for environment composition EnvironmentTmpl = `package {{ .PackageName }} import ( "fmt" "github.com/smartcontractkit/chainlink-testing-framework/framework" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/jd" ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set" ) type Cfg struct { OnChain *OnChain ` + "`" + `toml:"on_chain"` + "`" + ` Blockchains []*blockchain.Input ` + "`" + `toml:"blockchains" validate:"required"` + "`" + ` NodeSets []*ns.Input ` + "`" + `toml:"nodesets" validate:"required"` + "`" + ` JD *jd.Input ` + "`" + `toml:"jd"` + "`" + ` } func NewEnvironment() (*Cfg, error) { endTracing := tracing() defer endTracing() if err := framework.DefaultNetwork(nil); err != nil { return nil, err } in, err := Load[Cfg]() if err != nil { return nil, fmt.Errorf("failed to load configuration: %w", err) } _, err = blockchain.NewBlockchainNetwork(in.Blockchains[0]) if err != nil { return nil, fmt.Errorf("failed to create blockchain network 1337: %w", err) } if err := DefaultProductConfiguration(in, ConfigureNodesNetwork); err != nil { return nil, fmt.Errorf("failed to setup default CLDF orchestration: %w", err) } _, err = ns.NewSharedDBNodeSet(in.NodeSets[0], nil) if err != nil { return nil, fmt.Errorf("failed to create new shared db node set: %w", err) } if err := DefaultProductConfiguration(in, ConfigureProductContractsJobs); err != nil { return nil, fmt.Errorf("failed to setup default CLDF orchestration: %w", err) } return in, Store[Cfg](in) } ` // SingleNetworkProductConfigurationTmpl is an single-network EVM product configuration template SingleNetworkEVMProductConfigurationTmpl = `package {{ .PackageName }} import ( "context" "fmt" "math/big" "os" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/link_token" "github.com/smartcontractkit/chainlink-testing-framework/framework/clclient" ) const ( ConfigureNodesNetwork ConfigPhase = iota ConfigureProductContractsJobs ) var Plog = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.DebugLevel).With().Fields(map[string]any{"component": "on_chain"}).Logger() type OnChain struct { LinkContractAddress string ` + "`" + `toml:"link_contract_address"` + "`" + ` CLNodesFundingETH float64 ` + "`" + `toml:"cl_nodes_funding_eth"` + "`" + ` CLNodesFundingLink float64 ` + "`" + `toml:"cl_nodes_funding_link"` + "`" + ` VerificationTimeoutSec time.Duration ` + "`" + `toml:"verification_timeout_sec"` + "`" + ` ContractsConfigurationTimeoutSec time.Duration ` + "`" + `toml:"contracts_configuration_timeout_sec"` + "`" + ` GasSettings *GasSettings ` + "`" + `toml:"gas_settings"` + "`" + ` Verify bool ` + "`" + `toml:"verify"` + "`" + ` DeployedContracts *DeployedContracts ` + "`" + `toml:"deployed_contracts"` + "`" + ` } type DeployedContracts struct { SomeContractAddr string ` + "`" + `toml:"some_contract_addr"` + "`" + ` } type GasSettings struct { FeeCapMultiplier int64 ` + "`" + `toml:"fee_cap_multiplier"` + "`" + ` TipCapMultiplier int64 ` + "`" + `toml:"tip_cap_multiplier"` + "`" + ` } type Jobs struct { ConfigPollIntervalSeconds time.Duration ` + "`" + `toml:"config_poll_interval_sec"` + "`" + ` MaxTaskDurationSec time.Duration ` + "`" + `toml:"max_task_duration_sec"` + "`" + ` } type ConfigPhase int // deployLinkAndMint is a universal action that deploys link token and mints required amount of LINK token for all the nodes. func deployLinkAndMint(ctx context.Context, in *Cfg, c *ethclient.Client, auth *bind.TransactOpts, rootAddr string, transmitters []common.Address) (*link_token.LinkToken, error) { addr, tx, lt, err := link_token.DeployLinkToken(auth, c) if err != nil { return nil, fmt.Errorf("could not create link token contract: %w", err) } _, err = bind.WaitDeployed(ctx, c, tx) if err != nil { return nil, err } Plog.Info().Str("Address", addr.Hex()).Msg("Deployed link token contract") tx, err = lt.GrantMintRole(auth, common.HexToAddress(rootAddr)) if err != nil { return nil, fmt.Errorf("could not grant mint role: %w", err) } _, err = bind.WaitMined(ctx, c, tx) if err != nil { return nil, err } // mint for public keys of nodes directly instead of transferring for _, transmitter := range transmitters { amount := new(big.Float).Mul(big.NewFloat(in.OnChain.CLNodesFundingLink), big.NewFloat(1e18)) amountWei, _ := amount.Int(nil) Plog.Info().Msgf("Minting LINK for transmitter address: %s", transmitter.Hex()) tx, err = lt.Mint(auth, transmitter, amountWei) if err != nil { return nil, fmt.Errorf("could not transfer link token contract: %w", err) } _, err = bind.WaitMined(ctx, c, tx) if err != nil { return nil, err } } return lt, nil } func configureContracts(in *Cfg, c *ethclient.Client, auth *bind.TransactOpts, cl []*clclient.ChainlinkClient, rootAddr string, transmitters []common.Address) (*DeployedContracts, error) { ctx, cancel := context.WithTimeout(context.Background(), in.OnChain.ContractsConfigurationTimeoutSec*time.Second) defer cancel() Plog.Info().Msg("Deploying LINK token contract") _, err := deployLinkAndMint(ctx, in, c, auth, rootAddr, transmitters) if err != nil { return nil, fmt.Errorf("could not create link token contract and mint: %w", err) } // TODO: use client and deploy your contracts return &DeployedContracts{ SomeContractAddr: "", }, nil } func configureJobs(in *Cfg, clNodes []*clclient.ChainlinkClient, contracts *DeployedContracts) error { bootstrapNode := clNodes[0] workerNodes := clNodes[1:] // TODO: define your jobs job := "" _, _, err := bootstrapNode.CreateJobRaw(job) if err != nil { return fmt.Errorf("creating bootstrap job have failed: %w", err) } for _, chainlinkNode := range workerNodes { // TODO: define your job for nodes here job := "" _, _, err = chainlinkNode.CreateJobRaw(job) if err != nil { return fmt.Errorf("creating job on node have failed: %w", err) } } return nil } // DefaultProductConfiguration is default product configuration that includes: // - Deploying required prerequisites (LINK token, shared contracts) // - Applying product-specific changesets // - Creating cldf.Environment, connecting to components, see *Cfg fields // - Generating CL nodes configs // All the data can be added *Cfg struct like and is synced between local machine and remote environment // so later both local and remote tests can use it. func DefaultProductConfiguration(in *Cfg, phase ConfigPhase) error { pkey := GetNetworkPrivateKey() if pkey == "" { return fmt.Errorf("PRIVATE_KEY environment variable not set") } switch phase { case ConfigureNodesNetwork: Plog.Info().Msg("Applying default CL nodes configuration") node := in.Blockchains[0].Out.Nodes[0] chainID := in.Blockchains[0].ChainID // configure node set and generate CL nodes configs netConfig := fmt.Sprintf(` + "`" + ` [[EVM]] LogPollInterval = '1s' BlockBackfillDepth = 100 LinkContractAddress = '%s' ChainID = '%s' MinIncomingConfirmations = 1 MinContractPayment = '0.0000001 link' FinalityDepth = %d [[EVM.Nodes]] Name = 'default' WsUrl = '%s' HttpUrl = '%s' [Feature] FeedsManager = true LogPoller = true UICSAKeys = true [OCR2] Enabled = true SimulateTransactions = false DefaultTransactionQueueDepth = 1 [P2P.V2] Enabled = true ListenAddresses = ['0.0.0.0:6690'] [Log] JSONConsole = true Level = 'debug' [Pyroscope] ServerAddress = 'http://host.docker.internal:4040' Environment = 'local' [WebServer] SessionTimeout = '999h0m0s' HTTPWriteTimeout = '3m' SecureCookies = false HTTPPort = 6688 [WebServer.TLS] HTTPSPort = 0 [WebServer.RateLimit] Authenticated = 5000 Unauthenticated = 5000 [JobPipeline] [JobPipeline.HTTPRequest] DefaultTimeout = '1m' [Log.File] MaxSize = '0b' ` + "`" + `, in.OnChain.LinkContractAddress, chainID, 5, node.InternalWSUrl, node.InternalHTTPUrl) for _, nodeSpec := range in.NodeSets[0].NodeSpecs { nodeSpec.Node.TestConfigOverrides = netConfig } Plog.Info().Msg("Nodes network configuration is finished") case ConfigureProductContractsJobs: Plog.Info().Msg("Connecting to CL nodes") nodeClients, err := clclient.New(in.NodeSets[0].Out.CLNodes) if err != nil { return err } transmitters := make([]common.Address, 0) ethKeyAddresses := make([]string, 0) for i, nc := range nodeClients { addr, err := nc.ReadPrimaryETHKey(in.Blockchains[0].ChainID) if err != nil { return err } ethKeyAddresses = append(ethKeyAddresses, addr.Attributes.Address) transmitters = append(transmitters, common.HexToAddress(addr.Attributes.Address)) Plog.Info(). Int("Idx", i). Str("ETH", addr.Attributes.Address). Msg("Node info") } // ETH examples c, auth, rootAddr, err := ETHClient(in) if err != nil { return fmt.Errorf("could not create basic eth client: %w", err) } for _, addr := range ethKeyAddresses { if err := FundNodeEIP1559(c, pkey, addr, in.OnChain.CLNodesFundingETH); err != nil { return err } } contracts, err := configureContracts(in, c, auth, nodeClients, rootAddr, transmitters) if err != nil { return err } if err := configureJobs(in, nodeClients, contracts); err != nil { return err } Plog.Info().Str("BootstrapNode", in.NodeSets[0].Out.CLNodes[0].Node.ExternalURL).Send() for _, n := range in.NodeSets[0].Out.CLNodes[1:] { Plog.Info().Str("Node", n.Node.ExternalURL).Send() } in.OnChain.DeployedContracts = contracts } return nil } ` // JustFileTmpl is a Justfile template used for building and publishing Docker images JustFileTmpl = `` /* 311-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 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, productType string, 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) GenerateCLDF ¶ added in v0.12.0
func (g *EnvCodegen) GenerateCLDF() (string, error)
GenerateCLDF generate CLDF helpers
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) 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) 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) GenerateReadme ¶ added in v0.12.0
func (g *EnvCodegen) GenerateReadme() (string, error)
GenerateReadme generates a readme file
func (*EnvCodegen) GenerateSingleNetworkProductConfiguration ¶ added in v0.12.0
func (g *EnvCodegen) GenerateSingleNetworkProductConfiguration() (string, error)
GenerateSingleNetworkProductConfiguration generate a single-network EVM product configuration
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 boilerplate, can be multiple files
type EnvParams ¶ added in v0.12.0
type EnvParams struct {
PackageName string
}
EnvParams environment.go file params
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
type LoadTestParams struct {
GoModName string
}
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 ProductConfigurationSimple ¶ added in v0.12.0
type ProductConfigurationSimple struct {
PackageName string
}
ProductConfigurationSimple product_configuration.go file params
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 struct {
ResultType string `json:"resultType"`
Result []struct {
Metric map[string]string `json:"metric"`
Value []interface{} `json:"value"`
} `json:"result"`
} `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
type SmokeTestParams struct {
GoModName string
}
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