http

package
v0.134.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RDCSource = "rdc"
	VDCSource = "vdc"
	APISource = "api"
)
View Source
const AutomaticRunMode = "automatic"

AutomaticRunMode indicates the job is automated

Variables

View Source
var (
	// ErrServerError is returned when the server was not able to correctly handle our request (status code >= 500).
	ErrServerError = errors.New(msg.InternalServerError)
	// ErrJobNotFound is returned when the requested job was not found.
	ErrJobNotFound = errors.New(msg.JobNotFound)
	// ErrAssetNotFound is returned when the requested asset was not found.
	ErrAssetNotFound = errors.New(msg.AssetNotFound)
	// ErrTunnelNotFound is returned when the requested tunnel was not found.
	ErrTunnelNotFound = errors.New(msg.TunnelNotFound)
)
View Source
var DefaultGitHub = GitHub{
	HTTPClient: &http.Client{
		Timeout:   4 * time.Second,
		Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
	},
	URL: "https://api.github.com",
}

DefaultGitHub is a preconfigured instance of GitHub.

View Source
var LaunchOptions = map[config.LaunchOrder]string{
	config.LaunchOrderFailRate: "fail_rate",
}

Functions

func CheckProxy added in v0.134.0

func CheckProxy() error

CheckProxy checks that the HTTP_PROXY is valid if it exists.

func NewRequestWithContext added in v0.125.0

func NewRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequestWithContext is a wrapper around http.NewRequestWithContext that modifies the request by adding additional headers.

func NewRetryableClient added in v0.126.0

func NewRetryableClient(timeout time.Duration) *retryablehttp.Client

NewRetryableClient returns a new pre-configured instance of retryablehttp.Client.

func NewRetryableRequestWithContext added in v0.126.0

func NewRetryableRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*retryablehttp.Request, error)

NewRetryableRequestWithContext is a wrapper around retryablehttp.NewRequestWithContext that modifies the request by adding additional headers.

Types

type APITester added in v0.124.1

type APITester struct {
	HTTPClient *http.Client
	URL        string
	Username   string
	AccessKey  string
}

APITester describes an interface to the api-testing rest endpoints.

func NewAPITester added in v0.124.1

func NewAPITester(url string, username string, accessKey string, timeout time.Duration) APITester

NewAPITester a new instance of APITester.

func (*APITester) GetEventResult added in v0.124.1

func (c *APITester) GetEventResult(ctx context.Context, hookID string, eventID string) (apitest.TestResult, error)

func (*APITester) GetHooks added in v0.124.1

func (c *APITester) GetHooks(ctx context.Context, projectID string) ([]apitest.Hook, error)

GetHooks returns the list of hooks available.

func (*APITester) GetProject added in v0.124.1

func (c *APITester) GetProject(ctx context.Context, hookID string) (apitest.ProjectMeta, error)

GetProject returns Project metadata for a given hookID.

func (*APITester) GetProjects added in v0.124.1

func (c *APITester) GetProjects(ctx context.Context) ([]apitest.ProjectMeta, error)

GetProjects returns the list of Project available.

func (*APITester) GetTest added in v0.124.1

func (c *APITester) GetTest(ctx context.Context, hookID string, testID string) (apitest.Test, error)

func (*APITester) RunAllAsync added in v0.124.1

func (c *APITester) RunAllAsync(ctx context.Context, hookID string, buildID string, tunnel config.Tunnel, test apitest.TestRequest) (apitest.AsyncResponse, error)

RunAllAsync runs all the tests for the project described by hookID and returns without waiting for their results.

func (*APITester) RunEphemeralAsync added in v0.124.1

func (c *APITester) RunEphemeralAsync(ctx context.Context, hookID string, buildID string, tunnel config.Tunnel, taskID string, test apitest.TestRequest) (apitest.AsyncResponse, error)

RunEphemeralAsync runs the tests for the project described by hookID and returns without waiting for their results.

func (*APITester) RunTagAsync added in v0.124.1

func (c *APITester) RunTagAsync(ctx context.Context, hookID string, testTag string, buildID string, tunnel config.Tunnel, test apitest.TestRequest) (apitest.AsyncResponse, error)

RunTagAsync runs all the tests for a testTag for a project described by hookID and returns without waiting for results.

func (*APITester) RunTestAsync added in v0.124.1

func (c *APITester) RunTestAsync(ctx context.Context, hookID string, testID string, buildID string, tunnel config.Tunnel, test apitest.TestRequest) (apitest.AsyncResponse, error)

RunTestAsync runs a single test described by testID for the project described by hookID and returns without waiting for results.

type AppStore added in v0.124.1

type AppStore struct {
	HTTPClient *http.Client
	URL        string
	Username   string
	AccessKey  string
}

AppStore implements a remote file storage for storage.AppService. See https://wiki.saucelabs.com/display/DOCS/Application+Storage for more details.

func NewAppStore added in v0.124.1

func NewAppStore(url, username, accessKey string, timeout time.Duration) *AppStore

NewAppStore returns an implementation for AppStore

func (*AppStore) Download added in v0.124.1

func (s *AppStore) Download(id string) (io.ReadCloser, int64, error)

Download downloads a file with the given id. It's the caller's responsibility to close the reader.

func (*AppStore) DownloadURL added in v0.124.1

func (s *AppStore) DownloadURL(url string) (io.ReadCloser, int64, error)

DownloadURL downloads a file from the url. It's the caller's responsibility to close the reader.

func (*AppStore) List added in v0.124.1

func (s *AppStore) List(opts storage.ListOptions) (storage.List, error)

List returns a list of items stored in the Sauce app storage that match the search criteria specified by opts.

func (*AppStore) UploadStream added in v0.124.1

func (s *AppStore) UploadStream(filename, description string, reader io.Reader) (storage.Item, error)

UploadStream uploads the contents of reader and stores them under the given filename.

type Batch added in v0.124.1

type Batch struct {
	Framework        string              `json:"framework,omitempty"`
	FrameworkVersion string              `json:"frameworkVersion,omitempty"`
	RunnerVersion    string              `json:"runnerVersion,omitempty"`
	TestFile         string              `json:"testFile,omitempty"`
	Args             []map[string]string `json:"args"`
	VideoFPS         int                 `json:"video_fps"`
}

Batch represents capabilities for batch frameworks.

type Capabilities added in v0.124.1

type Capabilities struct {
	AlwaysMatch MatchingCaps `json:"alwaysMatch,omitempty"`
}

Capabilities represents the webdriver capabilities. https://www.w3.org/TR/webdriver/

type DeviceQuery added in v0.124.1

type DeviceQuery struct {
	Type                         string `json:"type"`
	DeviceDescriptorID           string `json:"device_descriptor_id,omitempty"`
	PrivateDevicesOnly           bool   `json:"private_devices_only,omitempty"`
	CarrierConnectivityRequested bool   `json:"carrier_connectivity_requested,omitempty"`
	RequestedDeviceType          string `json:"requested_device_type,omitempty"`
	DeviceName                   string `json:"device_name,omitempty"`
	PlatformVersion              string `json:"platform_version,omitempty"`
}

DeviceQuery represents the device selection query for RDC.

type FrameworkResponse added in v0.124.1

type FrameworkResponse struct {
	Name        string    `json:"name"`
	Version     string    `json:"version"`
	EOLDate     time.Time `json:"eolDate"`
	RemovalDate time.Time `json:"removalDate"`
	Runner      runner    `json:"runner"`
	Platforms   []struct {
		Name     string
		Browsers []string
	} `json:"platforms"`
	BrowserDefaults map[string]string `json:"browserDefaults"`
}

FrameworkResponse represents the response body for framework information.

type GitHub added in v0.124.1

type GitHub struct {
	HTTPClient *http.Client
	URL        string
}

GitHub represents the GitHub HTTP API client.

func (*GitHub) IsUpdateAvailable added in v0.124.1

func (c *GitHub) IsUpdateAvailable(version string) (string, error)

IsUpdateAvailable returns the latest version if it's semantically higher than the given one.

type ImageRunner

type ImageRunner struct {
	Client *retryablehttp.Client
	URL    string
	Creds  iam.Credentials
}

func NewImageRunner

func NewImageRunner(url string, creds iam.Credentials, timeout time.Duration) ImageRunner

func (*ImageRunner) DownloadArtifacts added in v0.131.0

func (c *ImageRunner) DownloadArtifacts(ctx context.Context, id string) (io.ReadCloser, error)

func (*ImageRunner) GetLogs

func (c *ImageRunner) GetLogs(ctx context.Context, id string) (string, error)

func (*ImageRunner) GetStatus

func (c *ImageRunner) GetStatus(ctx context.Context, id string) (imagerunner.Runner, error)

func (*ImageRunner) StopRun

func (c *ImageRunner) StopRun(ctx context.Context, runID string) error

func (*ImageRunner) TriggerRun

type InsightsService added in v0.124.1

type InsightsService struct {
	HTTPClient  *http.Client
	URL         string
	Credentials iam.Credentials
}

func NewInsightsService added in v0.124.1

func NewInsightsService(url string, creds iam.Credentials, timeout time.Duration) InsightsService

func (*InsightsService) GetHistory added in v0.124.1

func (c *InsightsService) GetHistory(ctx context.Context, user iam.User, launchOrder config.LaunchOrder) (insights.JobHistory, error)

GetHistory returns job history from insights

func (*InsightsService) ListJobs added in v0.124.1

func (c *InsightsService) ListJobs(ctx context.Context, userID, jobSource string, queryOpts job.QueryOption) (job.List, error)

ListJobs returns job list

func (*InsightsService) PostTestRun added in v0.124.1

func (c *InsightsService) PostTestRun(ctx context.Context, runs []insights.TestRun) error

PostTestRun publish test-run results to insights API.

func (*InsightsService) ReadJob added in v0.124.1

func (c *InsightsService) ReadJob(ctx context.Context, jobID string) (job.Job, error)

type Item added in v0.124.1

type Item struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Size            int    `json:"size"`
	UploadTimestamp int64  `json:"upload_timestamp"`
}

Item represents the metadata about the uploaded file.

type JobResp added in v0.124.1

type JobResp struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Status      string `json:"status"`
	Error       string `json:"error"`
	Framework   string `json:"automation_backend"`
	Device      string `json:"device"`
	BrowserName string `json:"browser_name"`
	OS          string `json:"os"`
	OSVersion   string `json:"os_version"`
	Source      string `json:"source"`
}

JobResp represents job response structure

type Links struct {
	Self string `json:"self"`
	Prev string `json:"prev"`
	Next string `json:"next"`
}

Links represents the pagination information returned by the app store.

type ListJobResp added in v0.124.1

type ListJobResp struct {
	Jobs  []JobResp `json:"jobs"`
	Total int       `json:"total"`
}

ListJobResp represents list job response structure

type ListResponse added in v0.124.1

type ListResponse struct {
	Items      []Item `json:"items"`
	Links      Links  `json:"links"`
	Page       int    `json:"page"`
	PerPage    int    `json:"per_page"`
	TotalItems int    `json:"total_items"`
}

ListResponse represents the response as is returned by the app store.

type MatchingCaps added in v0.124.1

type MatchingCaps struct {
	App               string    `json:"app,omitempty"`
	OtherApps         []string  `json:"otherApps,omitempty"`
	BrowserName       string    `json:"browserName,omitempty"`
	BrowserVersion    string    `json:"browserVersion,omitempty"`
	PlatformName      string    `json:"platformName,omitempty"`
	SauceOptions      SauceOpts `json:"sauce:options,omitempty"`
	PlatformVersion   string    `json:"platformVersion,omitempty"`
	DeviceName        string    `json:"deviceName,omitempty"`
	DeviceOrientation string    `json:"deviceOrientation,omitempty"`
}

MatchingCaps are specific attributes that together form the capabilities that are used to match a session.

type PublishedTest added in v0.124.1

type PublishedTest struct {
	Published apitest.Test
}

PublishedTest describes a published test.

type RDCJob added in v0.124.1

type RDCJob struct {
	ID                string
	AutomationBackend string `json:"automation_backend,omitempty"`
	FrameworkLogURL   string `json:"framework_log_url,omitempty"`
	DeviceLogURL      string `json:"device_log_url,omitempty"`
	TestCasesURL      string `json:"test_cases_url,omitempty"`
	VideoURL          string `json:"video_url,omitempty"`
	Screenshots       []struct {
		ID string
	} `json:"screenshots,omitempty"`
	Status             string `json:"status,omitempty"`
	Passed             bool
	ConsolidatedStatus string `json:"consolidated_status,omitempty"`
	Error              string `json:"error,omitempty"`
}

type RDCService added in v0.124.1

type RDCService struct {
	Client         *retryablehttp.Client
	URL            string
	Username       string
	AccessKey      string
	ArtifactConfig config.ArtifactDownload
}

RDCService http client.

func NewRDCService added in v0.124.1

func NewRDCService(url, username, accessKey string, timeout time.Duration, artifactConfig config.ArtifactDownload) RDCService

NewRDCService creates a new client.

func (*RDCService) DownloadArtifact added in v0.124.1

func (c *RDCService) DownloadArtifact(jobID, suiteName string, realDevice bool) []string

DownloadArtifact downloads artifacts and returns a list of downloaded files.

func (*RDCService) GetDevices added in v0.124.1

func (c *RDCService) GetDevices(ctx context.Context, OS string) ([]devices.Device, error)

GetDevices returns the list of available devices using a specific operating system.

func (*RDCService) GetJobAssetFileContent added in v0.124.1

func (c *RDCService) GetJobAssetFileContent(ctx context.Context, jobID, fileName string, realDevice bool) ([]byte, error)

GetJobAssetFileContent returns the job asset file content.

func (*RDCService) GetJobAssetFileNames added in v0.124.1

func (c *RDCService) GetJobAssetFileNames(ctx context.Context, jobID string, realDevice bool) ([]string, error)

GetJobAssetFileNames returns all assets files available.

func (*RDCService) PollJob added in v0.124.1

func (c *RDCService) PollJob(ctx context.Context, id string, interval, timeout time.Duration, realDevice bool) (job.Job, error)

PollJob polls job details at an interval, until timeout has been reached or until the job has ended, whether successfully or due to an error.

func (*RDCService) ReadJob added in v0.124.1

func (c *RDCService) ReadJob(ctx context.Context, id string, realDevice bool) (job.Job, error)

ReadJob returns the job details.

func (*RDCService) StartJob added in v0.124.1

func (c *RDCService) StartJob(ctx context.Context, opts job.StartOptions) (jobID string, isRDC bool, err error)

StartJob creates a new job in Sauce Labs.

type RDCSessionRequest added in v0.124.1

type RDCSessionRequest struct {
	TestFramework       string            `json:"test_framework,omitempty"`
	AppID               string            `json:"app_id,omitempty"`
	TestAppID           string            `json:"test_app_id,omitempty"`
	OtherApps           []string          `json:"other_apps,omitempty"`
	DeviceQuery         DeviceQuery       `json:"device_query,omitempty"`
	TestOptions         map[string]string `json:"test_options,omitempty"`
	TestsToRun          []string          `json:"tests_to_run,omitempty"`
	TestsToSkip         []string          `json:"tests_to_skip,omitempty"`
	TestName            string            `json:"test_name,omitempty"`
	TunnelName          string            `json:"tunnel_name,omitempty"`
	TunnelOwner         string            `json:"tunnel_owner,omitempty"`
	UseTestOrchestrator bool              `json:"use_test_orchestrator,omitempty"`
	Tags                []string          `json:"tags,omitempty"`
	Build               string            `json:"build,omitempty"`
	AppSettings         job.AppSettings   `json:"settings,omitempty"`
	RealDeviceKind      string            `json:"kind,omitempty"`
}

RDCSessionRequest represents the RDC session request.

type Resto added in v0.124.1

type Resto struct {
	Client         *retryablehttp.Client
	URL            string
	Username       string
	AccessKey      string
	ArtifactConfig config.ArtifactDownload
}

Resto http client.

func NewResto added in v0.124.1

func NewResto(url, username, accessKey string, timeout time.Duration) Resto

NewResto creates a new client.

func (*Resto) DownloadArtifact added in v0.124.1

func (c *Resto) DownloadArtifact(jobID, suiteName string, realDevice bool) []string

DownloadArtifact downloads artifacts and returns a list of what was downloaded.

func (*Resto) GetBuildID added in v0.124.1

func (c *Resto) GetBuildID(ctx context.Context, jobID string, buildSource build.Source) (string, error)

func (*Resto) GetJobAssetFileContent added in v0.124.1

func (c *Resto) GetJobAssetFileContent(ctx context.Context, jobID, fileName string, realDevice bool) ([]byte, error)

GetJobAssetFileContent returns the job asset file content.

func (*Resto) GetJobAssetFileNames added in v0.124.1

func (c *Resto) GetJobAssetFileNames(ctx context.Context, jobID string, realDevice bool) ([]string, error)

GetJobAssetFileNames return the job assets list.

func (*Resto) GetVirtualDevices added in v0.124.1

func (c *Resto) GetVirtualDevices(ctx context.Context, kind string) ([]vmd.VirtualDevice, error)

GetVirtualDevices returns the list of available virtual devices.

func (*Resto) IsTunnelRunning added in v0.124.1

func (c *Resto) IsTunnelRunning(ctx context.Context, id, owner string, filter tunnels.Filter, wait time.Duration) error

IsTunnelRunning checks whether tunnelID is running. If not, it will wait for the tunnel to become available or timeout. Whichever comes first.

func (*Resto) PollJob added in v0.124.1

func (c *Resto) PollJob(ctx context.Context, id string, interval, timeout time.Duration, realDevice bool) (job.Job, error)

PollJob polls job details at an interval, until timeout has been reached or until the job has ended, whether successfully or due to an error.

func (*Resto) ReadJob added in v0.124.1

func (c *Resto) ReadJob(ctx context.Context, id string, realDevice bool) (job.Job, error)

ReadJob returns the job details.

func (*Resto) StopJob added in v0.124.1

func (c *Resto) StopJob(ctx context.Context, jobID string, realDevice bool) (job.Job, error)

StopJob stops the job on the Sauce Cloud.

type SauceOpts added in v0.124.1

type SauceOpts struct {
	DevX             bool     `json:"devX,omitempty"`
	TestName         string   `json:"name,omitempty"`
	Tags             []string `json:"tags,omitempty"`
	BuildName        string   `json:"build,omitempty"`
	Batch            Batch    `json:"_batch,omitempty"`
	IdleTimeout      int      `json:"idleTimeout,omitempty"`
	MaxDuration      int      `json:"maxDuration,omitempty"`
	TunnelIdentifier string   `json:"tunnelIdentifier,omitempty"`
	TunnelParent     string   `json:"parentTunnel,omitempty"` // note that 'parentTunnel` is backwards, because that's the way sauce likes it
	ScreenResolution string   `json:"screen_resolution,omitempty"`
	SauceCloudNode   string   `json:"_sauceCloudNode,omitempty"`
	UserAgent        string   `json:"user_agent,omitempty"`
	TimeZone         string   `json:"timeZone,omitempty"`
	Visibility       string   `json:"public,omitempty"`
}

SauceOpts represents the Sauce Labs specific capabilities.

type SessionRequest added in v0.124.1

type SessionRequest struct {
	Capabilities        Capabilities `json:"capabilities,omitempty"`
	DesiredCapabilities MatchingCaps `json:"desiredCapabilities,omitempty"`
}

SessionRequest represents the webdriver session request.

type TestComposer added in v0.124.1

type TestComposer struct {
	HTTPClient  *http.Client
	URL         string // e.g.) https://api.<region>.saucelabs.net
	Credentials iam.Credentials
}

TestComposer service

func NewTestComposer added in v0.124.1

func NewTestComposer(url string, creds iam.Credentials, timeout time.Duration) TestComposer

func (*TestComposer) Frameworks added in v0.124.1

func (c *TestComposer) Frameworks(ctx context.Context) ([]framework.Framework, error)

Frameworks returns the list of available frameworks.

func (*TestComposer) GetSlackToken added in v0.124.1

func (c *TestComposer) GetSlackToken(ctx context.Context) (string, error)

GetSlackToken gets slack token.

func (*TestComposer) UploadAsset added in v0.124.1

func (c *TestComposer) UploadAsset(jobID string, realDevice bool, fileName string, contentType string, content []byte) error

UploadAsset uploads an asset to the specified jobID.

func (*TestComposer) Versions added in v0.124.1

func (c *TestComposer) Versions(ctx context.Context, frameworkName string) ([]framework.Metadata, error)

Versions return the list of available versions for a specific framework and region.

type TokenResponse added in v0.124.1

type TokenResponse struct {
	Token string `json:"token"`
}

TokenResponse represents the response body for slack token.

type UploadResponse added in v0.124.1

type UploadResponse struct {
	Item Item `json:"item"`
}

UploadResponse represents the response as is returned by the app store.

type UserService added in v0.124.1

type UserService struct {
	HTTPClient  *http.Client
	URL         string
	Credentials iam.Credentials
}

func NewUserService added in v0.124.1

func NewUserService(url string, creds iam.Credentials, timeout time.Duration) UserService

func (*UserService) Concurrency added in v0.126.0

func (c *UserService) Concurrency(ctx context.Context) (iam.Concurrency, error)

Concurrency returns the concurrency settings for the current account.

func (*UserService) User added in v0.126.0

func (c *UserService) User(ctx context.Context) (iam.User, error)

type Webdriver added in v0.124.1

type Webdriver struct {
	HTTPClient  *http.Client
	URL         string
	Credentials iam.Credentials
}

Webdriver service

func NewWebdriver added in v0.124.1

func NewWebdriver(url string, creds iam.Credentials, timeout time.Duration) Webdriver

func (*Webdriver) StartJob added in v0.124.1

func (c *Webdriver) StartJob(ctx context.Context, opts job.StartOptions) (jobID string, isRDC bool, err error)

StartJob creates a new job in Sauce Labs.

Jump to

Keyboard shortcuts

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