testfixtures

package
v0.3.54 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobIdString                  = "01f3j0g1md4qx7z5qb148qnh4r"
	RunIdString                  = "123e4567-e89b-12d3-a456-426614174000"
	PartitionMarkerGroupIdString = "223e4567-e89b-12d3-a456-426614174000"
)

Standard Set of events for common tests

View Source
const (
	JobSetName                 = "testJobset"
	ExecutorId                 = "testCluster"
	NodeName                   = "testNode"
	PodName                    = "test-pod"
	Queue                      = "test-Queue"
	UserId                     = "testUser"
	Namespace                  = "test-ns"
	Priority                   = 3
	NewPriority                = 4
	PodNumber                  = 6
	ExitCode                   = 322
	ErrMsg                     = "sample error message"
	LeaseReturnedMsg           = "lease returned error message"
	TerminatedMsg              = "test pod terminated message"
	UnschedulableMsg           = "test pod is unschedulable"
	PartitionMarkerPartitionId = 456
)

Variables

View Source
var (
	JobIdProto, _               = armadaevents.ProtoUuidFromUlidString(JobIdString)
	RunIdProto                  = armadaevents.ProtoUuidFromUuid(uuid.MustParse(RunIdString))
	PartitionMarkerGroupIdProto = armadaevents.ProtoUuidFromUuid(uuid.MustParse(PartitionMarkerGroupIdString))
	JobIdUuid                   = armadaevents.UuidFromProtoUuid(JobIdProto)
	RunIdUuid                   = armadaevents.UuidFromProtoUuid(RunIdProto)
	PartitionMarkerGroupIdUuid  = armadaevents.UuidFromProtoUuid(PartitionMarkerGroupIdProto)
	PriorityClassName           = "test-priority"
	PriorityClassValue          = int32(100)
	PriorityClasses             = map[string]configuration.PriorityClass{PriorityClassName: {Priority: PriorityClassValue}}
	Groups                      = []string{"group1", "group2"}
	NodeSelector                = map[string]string{"foo": "bar"}
	Tolerations                 = []v1.Toleration{{
		Key:      "fish",
		Operator: "exists",
	}}
	BaseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z")
)
View Source
var JobCancelRequested = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_CancelJob{
		CancelJob: &armadaevents.CancelJob{
			JobId: JobIdProto,
		},
	},
}
View Source
var JobFailed = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobErrors{
		JobErrors: &armadaevents.JobErrors{
			JobId: JobIdProto,
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodError{
						PodError: &armadaevents.PodError{
							Message:  ErrMsg,
							NodeName: NodeName,
							ContainerErrors: []*armadaevents.ContainerError{
								{ExitCode: ExitCode},
							},
						},
					},
				},
			},
		},
	},
}
View Source
var JobLeaseReturned = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunErrors{
		JobRunErrors: &armadaevents.JobRunErrors{
			JobId: JobIdProto,
			RunId: eventutil.LegacyJobRunId(),
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodLeaseReturned{
						PodLeaseReturned: &armadaevents.PodLeaseReturned{
							ObjectMeta: &armadaevents.ObjectMeta{
								ExecutorId: ExecutorId,
							},
							Message: LeaseReturnedMsg,
						},
					},
				},
			},
		},
	},
}
View Source
var JobPreempted = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunPreempted{
		JobRunPreempted: &armadaevents.JobRunPreempted{
			PreemptedJobId: JobIdProto,
			PreemptedRunId: RunIdProto,
		},
	},
}
View Source
var JobReprioritiseRequested = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_ReprioritiseJob{
		ReprioritiseJob: &armadaevents.ReprioritiseJob{
			JobId:    JobIdProto,
			Priority: NewPriority,
		},
	},
}
View Source
var JobRunFailed = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunErrors{
		JobRunErrors: &armadaevents.JobRunErrors{
			JobId: JobIdProto,
			RunId: RunIdProto,
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodError{
						PodError: &armadaevents.PodError{
							Message:  ErrMsg,
							NodeName: NodeName,
							ContainerErrors: []*armadaevents.ContainerError{
								{ExitCode: ExitCode},
							},
						},
					},
				},
			},
		},
	},
}
View Source
var JobRunSucceeded = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunSucceeded{
		JobRunSucceeded: &armadaevents.JobRunSucceeded{
			RunId: RunIdProto,
			JobId: JobIdProto,
		},
	},
}
View Source
var JobRunTerminated = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunErrors{
		JobRunErrors: &armadaevents.JobRunErrors{
			JobId: JobIdProto,
			RunId: RunIdProto,
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodTerminated{
						PodTerminated: &armadaevents.PodTerminated{
							NodeName: NodeName,
							ObjectMeta: &armadaevents.ObjectMeta{
								ExecutorId: ExecutorId,
							},
							Message: TerminatedMsg,
						},
					},
				},
			},
		},
	},
}
View Source
var JobRunUnschedulable = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunErrors{
		JobRunErrors: &armadaevents.JobRunErrors{
			JobId: JobIdProto,
			RunId: RunIdProto,
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodUnschedulable{
						PodUnschedulable: &armadaevents.PodUnschedulable{
							NodeName: NodeName,
							ObjectMeta: &armadaevents.ObjectMeta{
								ExecutorId: ExecutorId,
							},
							Message: UnschedulableMsg,
						},
					},
				},
			},
		},
	},
}
View Source
var JobSetCancelRequested = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_CancelJobSet{
		CancelJobSet: &armadaevents.CancelJobSet{},
	},
}
View Source
var LeaseReturned = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_JobRunErrors{
		JobRunErrors: &armadaevents.JobRunErrors{
			JobId: JobIdProto,
			RunId: RunIdProto,
			Errors: []*armadaevents.Error{
				{
					Terminal: true,
					Reason: &armadaevents.Error_PodLeaseReturned{
						PodLeaseReturned: &armadaevents.PodLeaseReturned{
							Message: LeaseReturnedMsg,
						},
					},
				},
			},
		},
	},
}
View Source
var Submit = &armadaevents.EventSequence_Event{
	Created: &BaseTime,
	Event: &armadaevents.EventSequence_Event_SubmitJob{
		SubmitJob: &armadaevents.SubmitJob{
			JobId:           JobIdProto,
			Priority:        Priority,
			AtMostOnce:      true,
			Preemptible:     true,
			ConcurrencySafe: true,
			ObjectMeta: &armadaevents.ObjectMeta{
				Namespace: Namespace,
				Name:      "test-job",
			},
			MainObject: &armadaevents.KubernetesMainObject{
				Object: &armadaevents.KubernetesMainObject_PodSpec{
					PodSpec: &armadaevents.PodSpecWithAvoidList{
						PodSpec: &v1.PodSpec{
							NodeSelector:      NodeSelector,
							Tolerations:       Tolerations,
							PriorityClassName: PriorityClassName,
							Containers: []v1.Container{
								{
									Name:    "container1",
									Image:   "alpine:latest",
									Command: []string{"myprogram.sh"},
									Args:    []string{"foo", "bar"},
									Resources: v1.ResourceRequirements{
										Limits: map[v1.ResourceName]resource.Quantity{
											"memory": resource.MustParse("64Mi"),
											"cpu":    resource.MustParse("150m"),
										},
										Requests: map[v1.ResourceName]resource.Quantity{
											"memory": resource.MustParse("64Mi"),
											"cpu":    resource.MustParse("150m"),
										},
									},
								},
							},
						},
					},
				},
			},
		},
	},
}

Functions

Types

This section is empty.

Jump to

Keyboard shortcuts

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