testreporters

package
v0.0.0-...-ec710b4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testreporters holds all the tools necessary to report on tests that are run utilizing the testsetups package

Index

Constants

View Source
const (
	// DefaultArtifactsDir default artifacts dir
	DefaultArtifactsDir string = "logs"
)

Variables

View Source
var (
	SlackAPIKey  = os.Getenv(config.EnvVarSlackKey)
	SlackChannel = os.Getenv(config.EnvVarSlackChannel)
	SlackUserID  = os.Getenv(config.EnvVarSlackUser)
)

Values for reporters to use slack to notify user of test end

Functions

func CommonSlackNotificationBlocks

func CommonSlackNotificationBlocks(
	headerText, namespace,
	reportCsvLocation string,
) []slack.Block

func MkdirIfNotExists

func MkdirIfNotExists(dirName string) error

creates a directory if it doesn't already exist

func SendReport

func SendReport(t *testing.T, namespace string, logsPath string, optionalTestReporter TestReporter, grafanaUrlProvider GrafanaURLProvider) error

SendReport writes a test report and sends a Slack notification if the test provides one

func SendSlackMessage

func SendSlackMessage(slackClient *slack.Client, msgOptions ...slack.MsgOption) (string, error)

Sends a slack message, and returns an error and the message timestamp

func SlackNotifyBlocks

func SlackNotifyBlocks(headerText, namespace string, msgtext []string) []slack.Block

SlackNotifyBlocks creates a slack payload and writes into the specified json

func UploadSlackFile

func UploadSlackFile(slackClient *slack.Client, uploadParams slack.FileUploadParameters) error

Uploads a slack file to the designated channel using the API key

func WriteTeardownLogs

func WriteTeardownLogs(
	t *testing.T,
	env *environment.Environment,
	optionalTestReporter TestReporter,
	failingLogLevel zapcore.Level,
	grafanaUrlProvider GrafanaURLProvider,
) error

WriteTeardownLogs attempts to download the logs of all ephemeral test deployments onto the test runner, also writing a test report if one is provided. A failing log level also enables you to fail a test based on what level logs the Chainlink nodes have thrown during their test.

Types

type GrafanaURLProvider

type GrafanaURLProvider interface {
	GetGrafanaBaseURL() (string, error)
	GetGrafanaDashboardURL() (string, error)
}

type TestReporter

type TestReporter interface {
	WriteReport(folderLocation string) error
	SendSlackNotification(t *testing.T, slackClient *slack.Client, grafanaUrlProvider GrafanaURLProvider) error
	SetNamespace(namespace string)
}

TestReporter is a general interface for all test reporters

Jump to

Keyboard shortcuts

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