Documentation ¶
Index ¶
- Constants
- Variables
- func AddPrometheusMetricsToResults(promMetric PrometheusMetrics, testResult proto.TestResult) error
- func ComputeAgentId(podName string, namespace string) string
- func ComputePluginId(testName string, namespace string, agentId string) string
- func ComputeSynTestConfigId(testName string, testNamespace string) string
- func FailedTestResult() proto.TestResult
- func GetPluginIdComponents(pluginId string) (testName, testNs, podName, podNs string, err error)
- func IsAgentValidForSynTest(agentConfig AgentConfig, agentId, testName, testNs, testNodeSelector string, ...) (bool, error)
- func ParseYMLConfig(configStr string, o interface{}) error
- type AgentConfig
- type AgentInfo
- type AgentStatus
- type ChronySource
- type PluginDiscoveryConfig
- type PluginRestartPolicy
- type PluginState
- type PrintPluginLogOption
- type PrometheusConfig
- type PrometheusGauge
- type PrometheusMetrics
- type RoutineStatus
- type StorageConfig
- type SynTestGRPCPlugin
- type SynTestPlugin
- type SynTestPluginGRPCClient
- type SynTestPluginGRPCServer
- func (s *SynTestPluginGRPCServer) Finish(context.Context, *proto.Empty) (*proto.Empty, error)
- func (s *SynTestPluginGRPCServer) Initialise(ctx context.Context, config *proto.SynTestConfig) (*proto.Empty, error)
- func (s *SynTestPluginGRPCServer) PerformTest(ctx context.Context, trigger *proto.Trigger) (*proto.TestResult, error)
- type SyntestConfigStatus
- type SyntestConfigSummary
- type TestDetailsLogger
Constants ¶
const ( TimeFormat = "2006-01-02T15:04:05.999999999Z07:00" BroadcasterPublishChannelSize = 1000 DefaultSynTestSubChannelSize = 1000 DefaultChannelSize = 1000 MaxSynTestTimerJitter = 10000 // milliseconds MaxConfigTimerJitter = 5000 // milliseconds DefaultInitTimeout = 10 * time.Second DefaultRunTimeout = 10 * time.Second DefaultFinishTimeout = 10 * time.Second DefaultLogWaitTime = 15 * time.Millisecond DefaultRestartPolicy = RestartAlways )
Time constants
const ( TriggerTypeTimer = "timer" TriggerTypeTest = "test" )
Trigger Type Values
const ( ImportanceCritical = "critical" ImportanceHigh = "high" ImportanceMedium = "medium" ImportanceLow = "low" )
Importance Values
const ( ErrorKey = "_error" // special key for error details LogKey = "_log" // special key for logs PrometheusKey = "_prometheus" // special key for prometheus metrics )
Special Keys in Details of TestDetailsMap
const ( K8sDiscoverLabel string = "synheart.infra.webex.com/discover" K8sDiscoverLabelVal string = "true" SpecialKeyNodeName string = "$nodeName" SpecialKeyAgentId string = "$agentId" SpecialKeyPodName string = "$podName" SpecialKeyAgentNs string = "$agentNamespace" )
Other constants
const ActiveClusterStatus = 1
const (
DroppedTestResults = "dropped_test_results" // How many test results the broadcaster has dropped because the listener wasn't ready
)
Synthetic Heart Metric Names
Variables ¶
var DefaultBackoff = wait.Backoff{ Steps: 20, Duration: 10 * time.Millisecond, Factor: 3.0, Jitter: 0.1, Cap: 15 * time.Second, }
var DefaultTestPluginHandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "SYNTEST_PLUGIN",
MagicCookieValue: "synthetic-heart",
}
Handshake config for Hashicorp plugins to talk to syntest plugins
Functions ¶
func AddPrometheusMetricsToResults ¶
func AddPrometheusMetricsToResults(promMetric PrometheusMetrics, testResult proto.TestResult) error
AddPrometheusMetricsToResults Adds a prometheus metric to a test result
func ComputeAgentId ¶
ComputeAgentId Computes agent id: it's just a string representing the pod name & namespace
func ComputePluginId ¶
ComputePluginId Computes plugin id, which represents a unique syntest plugin in the cluster
func ComputeSynTestConfigId ¶
ComputeSynTestConfigId Computes config id, which is a unique identifier for a syntest config using name and namespace
func FailedTestResult ¶
func FailedTestResult() proto.TestResult
FailedTestResult Gets an empty failed test result
func GetPluginIdComponents ¶
GetPluginIdComponents Splits the plugin Id into all its different compoenents
func IsAgentValidForSynTest ¶
func IsAgentValidForSynTest(agentConfig AgentConfig, agentId, testName, testNs, testNodeSelector string, testPodLabelSelector, testLabels map[string]string, logger hclog.Logger) (bool, error)
IsAgentValidForSynTest checks if the agent matches the selectors in the SynTest
func ParseYMLConfig ¶
ParseYMLConfig Parses and prints a yaml config
Types ¶
type AgentConfig ¶
type AgentConfig struct { MatchTestNamespaces []string `yaml:"matchTestNamespaces" json:"matchTestNamespaces"` MatchTestLabels map[string]string `yaml:"matchTestLabels" json:"matchTestLabels"` LabelFileLocation string `yaml:"labelFileLocation" json:"labelFileLocation"` SyncFrequency time.Duration `yaml:"syncFrequency" json:"syncFrequency"` GracePeriod time.Duration `yaml:"gracePeriod" json:"gracePeriod"` PrometheusConfig PrometheusConfig `yaml:"prometheus" json:"prometheusConfig"` StoreConfig StorageConfig `yaml:"storage" json:"storeConfig"` PrintPluginLogs PrintPluginLogOption `yaml:"printPluginLogs" json:"printPluginLogs"` EnabledPlugins []PluginDiscoveryConfig `yaml:"enabledPlugins" json:"enabledPlugins"` DebugMode bool `yaml:"debugMode" json:"debugMode"` // Populated at run time DiscoveredPlugins map[string][]string `json:"discoveredPlugins"` RunTimeInfo AgentInfo `json:"runTimeInfo"` MatchNamespaceSet map[string]bool `json:"matchNamespaceSet"` // so we can check if a namespace is being watched in O(1) }
type AgentInfo ¶
type AgentInfo struct { NodeName string `json:"nodeName"` // derived from Downward api PodName string `json:"podName"` // derived from Downward api PodLabels map[string]string `json:"podLabels"` // derived from Downward api AgentNamespace string `json:"agentNamespace"` // derived from Downward api }
type AgentStatus ¶
type AgentStatus struct { SynTests []string `json:"syntests"` StatusTime string `json:"statusTime"` AgentConfig AgentConfig `json:"agentConfig"` }
type ChronySource ¶
type PluginDiscoveryConfig ¶
type PluginRestartPolicy ¶
type PluginRestartPolicy string
PluginRestartPolicy Values
const ( RestartAlways PluginRestartPolicy = "always" RestartNever PluginRestartPolicy = "never" RestartOnError PluginRestartPolicy = "onError" )
type PluginState ¶
type PluginState struct { Status RoutineStatus `json:"status" yaml:"status"` StatusMsg string `json:"statusMsg" yaml:"statusMsg"` Config interface{} `json:"config" yaml:"config"` Restarts int `json:"restarts" yaml:"restarts"` RestartBackOff string `json:"restartBackOff" yaml:"restartBackOff"` TotalRestarts int `json:"totalRestarts" yaml:"totalRestarts"` RunningSince time.Time `json:"runningSince" yaml:"runningSince"` LastUpdated time.Time `json:"lastUpdated" yaml:"lastUpdated"` }
type PrintPluginLogOption ¶
type PrintPluginLogOption string
const ( LogOnFail PrintPluginLogOption = "onFail" LogNever PrintPluginLogOption = "never" LogAlways PrintPluginLogOption = "always" )
type PrometheusConfig ¶
type PrometheusGauge ¶
type PrometheusMetrics ¶
type PrometheusMetrics struct {
Gauges []PrometheusGauge `yaml:"gauges"`
}
type RoutineStatus ¶
type RoutineStatus string
const ( NotRunning RoutineStatus = "notRunning" Running RoutineStatus = "running" Error RoutineStatus = "error" Restarting RoutineStatus = "restarting" StatusUnknown RoutineStatus = "unknown" )
type StorageConfig ¶
type SynTestGRPCPlugin ¶
type SynTestGRPCPlugin struct { plugin.Plugin // Implement the plugin.Plugin Interface even tho its a GRPC interface (necessary) Impl SynTestPlugin // The real implementation is injected into this variable }
func (SynTestGRPCPlugin) GRPCClient ¶
func (SynTestGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
func (*SynTestGRPCPlugin) GRPCServer ¶
func (p *SynTestGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type SynTestPlugin ¶
type SynTestPlugin interface { // Called once at the start when plugin is run Initialise(config proto.SynTestConfig) error // Called when the test needs to be performed. PerformTest(info proto.Trigger) (proto.TestResult, error) // Called once at the end, before the plugin is killed Finish() error }
INTERFACES
The interface all test plugins must implement
type SynTestPluginGRPCClient ¶
type SynTestPluginGRPCClient struct {
// contains filtered or unexported fields
}
func (*SynTestPluginGRPCClient) Finish ¶
func (t *SynTestPluginGRPCClient) Finish() error
func (*SynTestPluginGRPCClient) Initialise ¶
func (t *SynTestPluginGRPCClient) Initialise(config proto.SynTestConfig) error
func (*SynTestPluginGRPCClient) PerformTest ¶
func (t *SynTestPluginGRPCClient) PerformTest(trigger proto.Trigger) (proto.TestResult, error)
type SynTestPluginGRPCServer ¶
type SynTestPluginGRPCServer struct { Impl SynTestPlugin proto.UnimplementedSynTestPluginServer }
func (*SynTestPluginGRPCServer) Initialise ¶
func (s *SynTestPluginGRPCServer) Initialise(ctx context.Context, config *proto.SynTestConfig) (*proto.Empty, error)
func (*SynTestPluginGRPCServer) PerformTest ¶
func (s *SynTestPluginGRPCServer) PerformTest(ctx context.Context, trigger *proto.Trigger) (*proto.TestResult, error)
type SyntestConfigStatus ¶
type SyntestConfigSummary ¶
type SyntestConfigSummary struct { Name string `json:"name"` Namespace string `json:"namespace"` ConfigId string `json:"configId"` Version string `json:"version"` DisplayName string `json:"displayName"` Description string `json:"description"` Plugin string `json:"plugin"` Repeat string `json:"repeat"` }
type TestDetailsLogger ¶
type TestDetailsLogger struct { Res proto.TestResult // contains filtered or unexported fields }
TestDetailsLogger is a simple helper struct to output logs in the test result details
func (*TestDetailsLogger) Log ¶
func (l *TestDetailsLogger) Log(msg string)