fake_platform_server

package
v0.0.0-...-b74f83a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const AgentsContainerUrl = "/_apis/distributedtask/pools/{pool-id:[0-9]+}/agents"
View Source
const AssignJobUrl = "/fake-api/assign-job/{job-id:[0-9]+}"
View Source
const DefaultPort = 8181
View Source
const FinishJobUrl = "/fake-api/finish-job/{job-id:[0-9]+}"
View Source
const JobsListUrl = "/_apis/distributedtask/pools/{pool-id:[0-9]+}/jobrequests"
View Source
const ListPoolsUrl = "/_apis/distributedtask/pools"
View Source
const SpecificAgentUrl = "/_apis/distributedtask/pools/{pool-id:[0-9]+}/agents/{agent-id:[0-9]+}"

Variables

This section is empty.

Functions

func MainTest

func MainTest()

Types

type Agent

type Agent struct {
	Name         string
	ID           int
	Capabilities map[string]string
	Status       string
	CreatedOn    time.Time
}

type FakeAzurePipelinesPlatformServer

type FakeAzurePipelinesPlatformServer struct {
	Jobs     []Job
	Agents   []Agent
	Requests []Request
	PoolId   int
	PoolName string
	// contains filtered or unexported fields
}

func NewFakeAzurePipelinesPlatformServer

func NewFakeAzurePipelinesPlatformServer() *FakeAzurePipelinesPlatformServer

func (*FakeAzurePipelinesPlatformServer) AddJob

func (f *FakeAzurePipelinesPlatformServer) AddJob(jobId int, poolId int, duration, startDelay, finishDelay int64, demands map[string]string) error

AddJob advertises a new job. It is called from the test code.

func (*FakeAzurePipelinesPlatformServer) CancelJob

func (f *FakeAzurePipelinesPlatformServer) CancelJob(jobId int) error

CancelJob cancels the job with the given jobId, by deleting it from the list of jobs. It is called from the test code.

func (*FakeAzurePipelinesPlatformServer) CreatePool

func (f *FakeAzurePipelinesPlatformServer) CreatePool(poolId int, poolName string)

CreatePool initializes the pool with the given poolId and poolName. It is called from the test code.

func (*FakeAzurePipelinesPlatformServer) Reset

Reset resets the fake platform server. It is called from the test code.

func (*FakeAzurePipelinesPlatformServer) Start

Start starts the fake platform server on the given port, using DefaultPort by default. The server runs in the background, meaning that Start does not block for long (only half a second to check for port-binding errors).

func (*FakeAzurePipelinesPlatformServer) Stop

Stop stops the fake platform server. After stopping it, it cannot be started again.

type Job

type Job struct {
	ID          int
	PoolID      int
	State       JobState
	Duration    int64
	StartDelay  int64
	FinishDelay int64
	Demands     []string
}

type JobState

type JobState string
const (
	Pending    JobState = "Pending"
	InProgress JobState = "InProgress"
	Finished   JobState = "Finished"
)

type Request

type Request struct {
	Type              RequestType
	AgentName         string
	AgentCapabilities map[string]string
	PoolID            int
	JobID             int
}

type RequestType

type RequestType string
const (
	ListJob      RequestType = "ListJob"
	ListAgent    RequestType = "ListAgent"
	CreateAgent  RequestType = "CreateAgent"
	ReplaceAgent RequestType = "ReplaceAgent"
	DeleteAgent  RequestType = "DeleteAgent"
	GetPoolId    RequestType = "GetPoolId"
	AssignJob    RequestType = "AssignJob"
	FinishJob    RequestType = "FinishJob"
)

Jump to

Keyboard shortcuts

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