e2eTesting

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

End-to-End Testing

The file e2e_test.go contains an end-to-end test of the Elastic APM AWS Lambda extension. This test is built on top of the AWS SAM CLI, which allows running Lambda functions and their associated layers locally.

Setup

Since this test is sensibly longer than the other unit tests, it is disabled by default. To enable it, go to .e2e_test_config and set the environment variable RUN_E2E_TESTS to true. In order to run the Lambda functions locally, the following dependencies must be installed :

  • Install the SAM CLI. Creating an AWS account is actually not required.
  • Install Docker
  • Install a Go Runtime

Run

cd apm-lambda-extension/e2e-testing
go test
Command line arguments

The command line arguments are presented with their default value.

-rebuild=false          # Rebuilds the Lambda function images
-lang=nodejs            # Selects the language of the Lambda function. node, java and python are supported.
-timer=20               # The timeout (in seconds) used to stop the execution of the Lambda function.
                        # Recommended values : NodeJS : 20, Python : 30, Java : 40
-java-agent-ver=1.28.4  # The version of the Java agent used when Java is selected.

Example :

go test -rebuild=false -lang=java -timer=40 -java-agent-ver=1.28.4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FolderExists

func FolderExists(path string) bool

FolderExists returns true if the specified folder exists, and false else.

func GetDecompressedBytesFromRequest

func GetDecompressedBytesFromRequest(req *http.Request) ([]byte, error)

GetDecompressedBytesFromRequest takes a HTTP request in argument and return the raw (decompressed) bytes of the body. The byte array can then be converted into a string for debugging / testing purposes.

func GetEnvVarValueOrSetDefault

func GetEnvVarValueOrSetDefault(envVarName string, defaultVal string) string

GetEnvVarValueOrSetDefault retrieves the environment variable envVarName. If the desired variable is not defined, defaultVal is returned.

func GetFreePort

func GetFreePort() (int, error)

GetFreePort is a function that queries the kernel and obtains an unused port.

func IsStringInSlice

func IsStringInSlice(a string, list []string) bool

IsStringInSlice is a utility function that checks if a slice of strings contains a specific string.

func ProcessError

func ProcessError(l *zap.SugaredLogger, err error)

ProcessError is a shorthand function to handle fatal errors, the idiomatic Go way. This should only be used for showstopping errors.

func RunCommandInDir

func RunCommandInDir(l *zap.SugaredLogger, command string, args []string, dir string)

RunCommandInDir runs a shell command with a given set of args in a specified folder. The stderr and stdout can be enabled or disabled.

func Unzip

func Unzip(l *zap.SugaredLogger, archivePath string, destinationFolderPath string)

Unzip is a utility function that unzips a specified zip archive to a specified destination.

Types

This section is empty.

Jump to

Keyboard shortcuts

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