util

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManagerServerName    = "manager"
	SchedulerServerName  = "scheduler"
	SeedClientServerName = "seed-client"
	ClientServerName     = "client"
)
View Source
const (
	DragonflyNamespace = "dragonfly-system"
)

Variables

View Source
var Servers = map[string]server{
	ManagerServerName: {
		Name:       ManagerServerName,
		Namespace:  DragonflyNamespace,
		LogDirName: ManagerServerName,
		Replicas:   1,
	},
	SchedulerServerName: {
		Name:       SchedulerServerName,
		Namespace:  DragonflyNamespace,
		LogDirName: SchedulerServerName,
		Replicas:   3,
	},
	SeedClientServerName: {
		Name:       SeedClientServerName,
		Namespace:  DragonflyNamespace,
		LogDirName: "dfdaemon",
		Replicas:   3,
	},
	ClientServerName: {
		Name:       ClientServerName,
		Namespace:  DragonflyNamespace,
		LogDirName: "dfdaemon",
		Replicas:   2,
	},
}

Functions

func CalculateSha256ByOutput added in v2.2.4

func CalculateSha256ByOutput(pods []*PodExec, output string) (string, error)

func CalculateSha256ByPersistentCacheTaskID added in v2.2.4

func CalculateSha256ByPersistentCacheTaskID(pods []*PodExec, taskID string) (string, error)

func CalculateSha256ByTaskID added in v2.2.4

func CalculateSha256ByTaskID(pods []*PodExec, taskID string) (string, error)

func CheckFilesExist added in v2.2.4

func CheckFilesExist(pods []*PodExec, taskID string) bool

Check files is exist or not.

func CriCtlCommand

func CriCtlCommand(arg ...string) *exec.Cmd

func DockerCommand

func DockerCommand(arg ...string) *exec.Cmd

func DockerCopy

func DockerCopy(dst, src string) *exec.Cmd

func GetClientPodNameInMaster added in v2.2.4

func GetClientPodNameInMaster() (string, error)

func GetClientPodNameInWorker added in v2.2.4

func GetClientPodNameInWorker() (string, error)

func GetManagerPodName added in v2.2.4

func GetManagerPodName(n int) (string, error)

func GetPersonalAccessToken added in v2.4.1

func GetPersonalAccessToken() string

GetPersonalAccessToken gets the personal access token from the environment variable.

func GetSeedClientPodName added in v2.2.4

func GetSeedClientPodName(n int) (string, error)

func GitCommand

func GitCommand(arg ...string) *exec.Cmd

func KubeCtlCommand

func KubeCtlCommand(arg ...string) *exec.Cmd

func KubeCtlCopyCommand

func KubeCtlCopyCommand(ns, pod, source, target string) *exec.Cmd

func UploadArtifactPrevStdout

func UploadArtifactPrevStdout(namespace, podName, logDirName, logPrefix string) error

func UploadArtifactStdout

func UploadArtifactStdout(namespace, podName, logDirName, logPrefix string) error

Types

type File added in v2.2.4

type File struct {
	// contains filtered or unexported fields
}

File represents a file.

func (*File) GetDownloadURL added in v2.2.4

func (f *File) GetDownloadURL() string

GetDownloadURL returns the download URL of the file from remote file server.

func (*File) GetInfo added in v2.2.4

func (f *File) GetInfo() os.FileInfo

GetInfo returns the file info.

func (*File) GetOutputPath added in v2.2.4

func (f *File) GetOutputPath() string

GetOutputPath returns the output path of the file.

func (*File) GetRangeSha256 added in v2.2.4

func (f *File) GetRangeSha256(r string, fileSize int64) string

GetRangeSha256 returns the sha256 of the range part of the file content.

func (*File) GetSha256 added in v2.2.4

func (f *File) GetSha256() string

GetSha256 returns the sha256 of the file content.

func (*File) GetTaskID added in v2.2.4

func (f *File) GetTaskID(opts ...TaskIDOption) string

GetTaskID returns the task id of the file.

type FileServer added in v2.2.4

type FileServer interface {
	// GenerateFile generates a file by random data with the specified size.
	GenerateFile(size FileSize) (*File, error)

	// DeleteFile deletes the file by the file info.
	DeleteFile(info os.FileInfo) error

	// Purge deletes all files generated by the file server, it should be called after all tests.
	Purge() error
}

FileServer is the interface of file server for testing.

func GetFileServer added in v2.2.4

func GetFileServer() FileServer

GetFileServer returns the global file server instance.

func NewFileServer added in v2.2.4

func NewFileServer() (FileServer, error)

NewFileServer creates a new file server which using the singleton pattern.

type FileServerOption added in v2.2.4

type FileServerOption func(*fileServer)

FileServerOption is the type of the options of the file server.

func WithFileServerEndpoint added in v2.2.4

func WithFileServerEndpoint(endpoint string) FileServerOption

WithFileServerEndpoint sets the endpoint of the file server.

func WithFileServerLocalDir added in v2.2.4

func WithFileServerLocalDir(localDir string) FileServerOption

WithFileServerLocalDir sets the local temporary directory of the file server.

type FileSize added in v2.2.4

type FileSize = uint64
const (
	// FileSize1MiB represents the size of 1MiB.
	FileSize1MiB FileSize = 1024 * 1024

	// FileSize10MiB represents the size of 10MiB.
	FileSize10MiB FileSize = 10 * FileSize1MiB

	// FileSize100MiB represents the size of 100MiB.
	FileSize100MiB FileSize = 100 * FileSize1MiB

	// FileSize500MiB represents the size of 500MiB.
	FileSize500MiB FileSize = 500 * FileSize1MiB

	// FileSize1GiB represents the size of 1GiB.
	FileSize1GiB FileSize = 1024 * FileSize1MiB
)

type PodExec

type PodExec struct {
	// contains filtered or unexported fields
}

func ClientExec added in v2.2.4

func ClientExec() (*PodExec, error)

func ManagerExec added in v2.2.4

func ManagerExec(n int) (*PodExec, error)

func NewPodExec

func NewPodExec(namespace string, name string, container string) *PodExec

func SeedClientExec added in v2.2.4

func SeedClientExec(n int) (*PodExec, error)

func (*PodExec) Command

func (p *PodExec) Command(arg ...string) *exec.Cmd

func (*PodExec) CurlCommand

func (p *PodExec) CurlCommand(method string, header map[string]string, data map[string]any, target string) *exec.Cmd

type TaskIDOption added in v2.2.4

type TaskIDOption func(*taskID)

TaskIDOption is the type of the options of the task id.

func WithTaskIDApplication added in v2.2.4

func WithTaskIDApplication(application string) TaskIDOption

WithTaskIDApplication sets the application of the download task.

func WithTaskIDFilteredQueryParams added in v2.2.4

func WithTaskIDFilteredQueryParams(filteredQueryParams []string) TaskIDOption

WithTaskIDFilteredQueryParams sets the filtered query params of the download task.

func WithTaskIDPieceLength added in v2.2.4

func WithTaskIDPieceLength(pieceLength uint64) TaskIDOption

WithTaskIDPieceLength sets the piece length of the download task.

func WithTaskIDTag added in v2.2.4

func WithTaskIDTag(tag string) TaskIDOption

WithTaskIDTag sets the tag of the download task.

func WithTaskIDURL added in v2.2.4

func WithTaskIDURL(url string) TaskIDOption

WithTaskIDURL sets the url of the download task.

type TaskMetadata added in v2.2.4

type TaskMetadata struct {
	ID     string
	Sha256 string
}

Jump to

Keyboard shortcuts

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