gopenqa

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: MIT Imports: 12 Imported by: 2

README

gopenqa

gopenqa is a (very bad name for a) openQA module written in go. The aim of the project is to create easy-to-use go bindings for interacting with openQA.

This project is under development and should probably not be used by anyone yet.

Installation

go get github.com/grisu48/gopenqa		

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyParams

func EmptyParams() map[string]string

Types

type Children

type Children struct {
	Chained         []int `json:"Chained"`
	DirectlyChained []int `json:"Directly chained"`
	Parallel        []int `json:"Parallel"`
}

Children struct is for chained, directly chained and parallel children/parents

type Comment

type Comment struct {
	ID       int      `json:"id"`
	Text     string   `json:"text"`             // Comment text
	Rendered string   `json:"renderedMarkdown"` // HTML of the rendered markdown
	BugRefs  []string `json:"bugrefs"`          // Referenced bugs
	Created  string   `json:"created"`          // bug creation date
	Updated  string   `json:"updated"`          // timestamp for update
	User     string   `json:"userName"`         // Creator
}

type Instance

type Instance struct {
	URL string
	// contains filtered or unexported fields
}

Instance defines a openQA instance

func CreateInstance

func CreateInstance(url string) Instance

Create a openQA instance module

func CreateO3Instance

func CreateO3Instance() Instance

Create a openQA instance module for openqa.opensuse.org

func (*Instance) DeleteJob

func (i *Instance) DeleteJob(id int) error

func (*Instance) DeleteJobGroup

func (i *Instance) DeleteJobGroup(id int) error

func (*Instance) DeleteJobGroupJobs

func (i *Instance) DeleteJobGroupJobs(id int) error

func (*Instance) DeleteJobTemplate

func (i *Instance) DeleteJobTemplate(id int) error

func (*Instance) DeleteMachine

func (i *Instance) DeleteMachine(id int) error

func (*Instance) GetComments

func (i *Instance) GetComments(job int) ([]Comment, error)

Fetch comments for a given job

func (*Instance) GetJob

func (i *Instance) GetJob(id int) (Job, error)

GetJob fetches detailled job information

func (*Instance) GetJobFollow

func (i *Instance) GetJobFollow(id int) (Job, error)

GetJob fetches detailled job information and follows the job, if it contains a CloneID

func (*Instance) GetJobGroup

func (i *Instance) GetJobGroup(id int) (JobGroup, error)

func (*Instance) GetJobGroupJobs

func (instance *Instance) GetJobGroupJobs(id int) ([]int, error)

func (*Instance) GetJobGroups

func (i *Instance) GetJobGroups() ([]JobGroup, error)

func (*Instance) GetJobTemplate

func (i *Instance) GetJobTemplate(id int) (JobTemplate, error)

func (*Instance) GetJobTemplateYAML

func (i *Instance) GetJobTemplateYAML(id int) (string, error)

func (*Instance) GetJobTemplates

func (i *Instance) GetJobTemplates() ([]JobTemplate, error)

func (*Instance) GetLatestJobs

func (i *Instance) GetLatestJobs(testsuite string, params map[string]string) ([]Job, error)

Get only the latest jobs of a certain testsuite. Testsuite must be given here. * Additional parameters can be supplied via the params map (See GetOverview for more info about usage of those parameters)

func (*Instance) GetMachine

func (i *Instance) GetMachine(id int) (Machine, error)

func (*Instance) GetMachines

func (i *Instance) GetMachines() ([]Machine, error)

func (*Instance) GetOverview

func (i *Instance) GetOverview(testsuite string, params map[string]string) ([]Job, error)

Query the job overview. params is a map for optional parameters, which will be added to the query. * Suitable parameters are `arch`, `distri`, `flavor`, `machine` or `arch`, but everything in this dict will be added to the url * Overview returns only the job id and name

func (*Instance) GetParentJobGroup

func (i *Instance) GetParentJobGroup(id int) (JobGroup, error)

func (*Instance) GetParentJobGroups

func (i *Instance) GetParentJobGroups() ([]JobGroup, error)

func (*Instance) GetProduct

func (i *Instance) GetProduct(id int) (Product, error)

func (*Instance) GetProducts

func (i *Instance) GetProducts() ([]Product, error)

func (*Instance) GetWorkers

func (i *Instance) GetWorkers() ([]Worker, error)

func (*Instance) PostJobGroup

func (i *Instance) PostJobGroup(jobgroup JobGroup) (JobGroup, error)

func (*Instance) PostJobTemplateYAML

func (i *Instance) PostJobTemplateYAML(id int, yaml string) error

func (*Instance) PostMachine

func (i *Instance) PostMachine(machine Machine) (Machine, error)

func (*Instance) PostParentJobGroup

func (i *Instance) PostParentJobGroup(jobgroup JobGroup) (JobGroup, error)

func (*Instance) PostProduct

func (i *Instance) PostProduct(product Product) (Product, error)

func (*Instance) SetApiKey

func (i *Instance) SetApiKey(key string, secret string)

Set the API key and secret

func (*Instance) SetMaxRecursionDepth

func (i *Instance) SetMaxRecursionDepth(depth int)

Set the maximum allowed number of recursions before failing

func (*Instance) SetVerbose

func (i *Instance) SetVerbose(verbose bool)

type Job

type Job struct {
	AssignedWorkerID int      `json:"assigned_worker_id"`
	BlockedByID      int      `json:"blocked_by_id"`
	Children         Children `json:"children"`
	Parents          Children `json:"parents"`
	CloneID          int      `json:"clone_id"`
	GroupID          int      `json:"group_id"`
	ID               int      `json:"id"`
	// Modules
	Name string `json:"name"`
	// Parents
	Priority  int      `json:"priority"`
	Result    string   `json:"result"`
	Settings  Settings `json:"settings"`
	State     string   `json:"state"`
	Tfinished string   `json:"t_finished"`
	Tstarted  string   `json:"t_started"`
	Test      string   `json:"test"`
	/* this is added by the program and not part of the fetched json */
	Link   string
	Prefix string
	// contains filtered or unexported fields
}

Job instance

func (*Job) Equals

func (j1 *Job) Equals(j2 Job) bool

Compares two jobs according to their unique parameters (ID, GroupID, Test)

func (*Job) FetchAllChildren

func (j *Job) FetchAllChildren(follow bool) ([]Job, error)

Fetch all child jobs * follow determines if we should follow the given children, i.e. get their cloned jobs instead of the original ones if present

func (*Job) FetchChildren

func (j *Job) FetchChildren(children []int, follow bool) ([]Job, error)

* Fetch the given child jobs. Use with j.Children.Chained, j.Children.DirectlyChained and j.Children.Parallel * if follow is set to true, the method will return the cloned job instead of the original one, if present

func (*Job) JobState

func (j *Job) JobState() string

func (*Job) String

func (j *Job) String() string

Format job as a string

type JobGroup

type JobGroup struct {
	ID                         int    `json:"id"`
	Name                       string `json:"name"`
	ParentID                   int    `json:"parent_id"`
	Description                string `json:"description"`
	BuildVersionSort           int    `json:"build_version_sort"`
	CarryOverBugrefs           int    `json:"carry_over_bugrefs"`
	DefaultPriority            int    `json:"default_priority`
	KeepImportantLogsInDays    int    `json:"keep_important_logs_in_days"`
	KeepImportantResultsInDays int    `json:"keep_important_results_in_days"`
	KeepLogsInDays             int    `json:"keep_logs_in_days"`
	KeepResultsInDays          int    `json:"keep_results_in_days"`
	SizeLimit                  int    `json:"size_limit_gb"` // Size limit in GB
	SortOrder                  int    `json:"sort_order"`
	Template                   string `json:"template"`
}

Job Group

type JobStatus

type JobStatus struct {
	Arch      string `json:"ARCH"`
	Build     string `json:"BUILD"`
	Flavor    string `json:"FLAVOR"`
	Machine   string `json:"MACHINE"`
	Test      string `json:"TEST"`
	BugRef    string `json:"bugref"`
	GroupID   int    `json:"group_id"`
	ID        int    `json:"id"`
	NewBuild  string `json:"newbuild"`
	Reason    string `json:"reason"`
	Remaining int    `json:"remaining"`
	Result    string `json:"result"`
}

JobStatus is the returns struct for job status updates from RabbitMQ

type JobTemplate

type JobTemplate struct {
	GroupName string    `json:"group_name"`
	ID        int       `json:"id"`
	Machine   Machine   `json:"machine"`
	Priority  int       `json:"prio"`
	Product   Product   `json:"product"`
	TestSuite TestSuite `json:"test_suite"`
}

Job Template

type Machine

type Machine struct {
	ID       int               `json:"id"`
	Backend  string            `json:"backend"`
	Name     string            `json:"name"`
	Settings map[string]string `json:"settings"`
}

Machine type

type Product

type Product struct {
	Arch     string            `json:"arch"`
	Distri   string            `json:"distri"`
	Flavor   string            `json:"flavor"`
	Group    string            `json:"group"`
	ID       int               `json:"id"`
	Version  string            `json:"version"`
	Settings map[string]string `json:"settings"`
}

Product

type RabbitMQ

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

RabbitMQ struct is the object which handles the connection to a RabbitMQ instance

func ConnectRabbitMQ

func ConnectRabbitMQ(remote string) (RabbitMQ, error)

ConnectRabbitMQ connects to a RabbitMQ instance and returns the RabbitMQ object

func (*RabbitMQ) Close

func (mq *RabbitMQ) Close()

Close connection

func (*RabbitMQ) Subscribe

func (mq *RabbitMQ) Subscribe(key string) (RabbitMQSubscription, error)

Subscribe to a given key and get the messages via the callback function. This method will return after establishing the channel and call the callback function when a new message arrives This message returns a RabbitMQSubscription object, which in turn can be used to receive the incoming messages

type RabbitMQSubscription

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

RabbitMQSubscription handles a single subscription

func (*RabbitMQSubscription) Close

func (sub *RabbitMQSubscription) Close()

Close subscription channel

func (*RabbitMQSubscription) Receive

func (sub *RabbitMQSubscription) Receive() (amqp.Delivery, error)

Receive receives a raw RabbitMQ messages

func (*RabbitMQSubscription) ReceiveJob

func (sub *RabbitMQSubscription) ReceiveJob() (Job, error)

ReceiveJob receives the next message and try to parse it as job

func (*RabbitMQSubscription) ReceiveJobStatus

func (sub *RabbitMQSubscription) ReceiveJobStatus() (JobStatus, error)

ReceiveJobStatus receives the next message and try to parse it as JobStatus. Use this for job status updates

type Settings

type Settings struct {
	Arch    string `json:"ARCH"`
	Backend string `json:"BACKEND"`
	Machine string `json:"MACHINE"`
}

Job Setting struct

type TestSuite

type TestSuite struct {
	ID          int               `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Settings    map[string]string `json:"settings"`
}

Test Suite

type Worker

type Worker struct {
	Alive      int               `json:"alive"`
	Connected  int               `json:"connected"`
	Error      string            `json:"error"` // Error string if present
	Host       string            `json:"host"`
	ID         int               `json:"id"`
	Instance   int               `json:"instance"`
	Status     string            `json:"status"`
	Websocket  int               `json:"websocket"`
	Properties map[string]string `json:"properties"` // Worker properties as returned by openQA
}

Worker instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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