store

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Pvc represents entity of type PVC
	Pvc EntityTypeEnum = "PVC"
	// Pod represents entity of type Pod
	Pod EntityTypeEnum = "POD"
	// StatefulSet represents entity of type StatefulSet
	StatefulSet EntityTypeEnum = "STATEFULSET"
	// Unknown represents entity of Unknown type
	Unknown EntityTypeEnum = "UNKNOWN"

	// PvcAdded represents PVC_ADDED event type
	PvcAdded EventTypeEnum = "PVC_ADDED"
	// PvcBound represents PVC_BOUND event type
	PvcBound EventTypeEnum = "PVC_BOUND"
	// PvcAttachStarted represents PVC_ATTACH_STARTED event type
	PvcAttachStarted EventTypeEnum = "PVC_ATTACH_STARTED"
	// PvcAttachEnded represents PVC_ATTACH_ENDED event type
	PvcAttachEnded EventTypeEnum = "PVC_ATTACH_ENDED"
	// PvcUnattachStarted represents PVC_UNATTACH_STARTED event type
	PvcUnattachStarted EventTypeEnum = "PVC_UNATTACH_STARTED"
	// PvcUnattachEnded represents PVC_UNATTACH_ENDED event type
	PvcUnattachEnded EventTypeEnum = "PVC_UNATTACH_ENDED"
	// PvcDeletingStarted represents PVC_DELETING_STARTED event type
	PvcDeletingStarted EventTypeEnum = "PVC_DELETING_STARTED"
	// PvcDeletingEnded represents PVC_DELETING_ENDED event type
	PvcDeletingEnded EventTypeEnum = "PVC_DELETING_ENDED"
	// PodAdded represents POD_ADDED event type
	PodAdded EventTypeEnum = "POD_ADDED"
	// PodReady represents POD_READY event type
	PodReady EventTypeEnum = "POD_READY"
	// PodTerminating represents POD_TERMINATING event type
	PodTerminating EventTypeEnum = "POD_TERMINATING"
	// PodDeleted represents POD_DELETED event type
	PodDeleted EventTypeEnum = "POD_DELETED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conditions

type Conditions map[string]interface{}

Conditions interface

type Entity

type Entity struct {
	ID     int64
	Name   string
	K8sUID string
	TcID   int64
	Type   EntityTypeEnum
}

Entity struct

type EntityTypeEnum

type EntityTypeEnum string

EntityTypeEnum specifies type of entity

func (*EntityTypeEnum) Scan

func (ete *EntityTypeEnum) Scan(value interface{}) error

Scan scans EntityTypeEnum

func (EntityTypeEnum) Value

func (ete EntityTypeEnum) Value() (driver.Value, error)

Value returns type of entity

type Event

type Event struct {
	ID        int64
	Name      string
	TcID      int64
	EntityID  int64
	Type      EventTypeEnum
	Timestamp time.Time
}

Event struct

type EventTypeEnum

type EventTypeEnum string

EventTypeEnum specifies type of event

func (*EventTypeEnum) Scan

func (ete *EventTypeEnum) Scan(value interface{}) error

Scan scans EventTypeEnum

func (EventTypeEnum) Value

func (ete EventTypeEnum) Value() (driver.Value, error)

Value returns type of event

type NumberEntities

type NumberEntities struct {
	ID              int64
	TcID            int64
	Timestamp       time.Time
	PodsCreating    int
	PodsReady       int
	PodsTerminating int
	PvcCreating     int
	PvcBound        int
	PvcTerminating  int
}

NumberEntities struct

type ResourceUsage

type ResourceUsage struct {
	ID            int64
	TcID          int64
	Timestamp     time.Time
	PodName       string
	ContainerName string
	CPU           int64
	Mem           int64
}

ResourceUsage struct

type SQLiteStore

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

SQLiteStore implements the Store interface, used for storing objects to sqlite database

func NewSQLiteStore

func NewSQLiteStore(dsn string) *SQLiteStore

NewSQLiteStore creates a new SQLiteStore

func (*SQLiteStore) Close

func (ss *SQLiteStore) Close() error

Close closes db handle

func (*SQLiteStore) CreateEntitiesRelation

func (ss *SQLiteStore) CreateEntitiesRelation(entity1, entity2 Entity) error

CreateEntitiesRelation adds EntitiesRelation to db

func (*SQLiteStore) FailedTestCase

func (ss *SQLiteStore) FailedTestCase(ts *TestCase, endTimestamp time.Time, errMsg string) error

FailedTestCase updates testcase status as failure

func (*SQLiteStore) GetEntities

func (ss *SQLiteStore) GetEntities(whereConditions Conditions, orderBy string, limit int) ([]Entity, error)

GetEntities queries entities from db

func (*SQLiteStore) GetEntitiesWithEventsByTestCaseAndEntityType

func (ss *SQLiteStore) GetEntitiesWithEventsByTestCaseAndEntityType(
	tc *TestCase,
	eType EntityTypeEnum,
) (map[Entity][]Event, error)

GetEntitiesWithEventsByTestCaseAndEntityType queries entities with events and returns the results sorted by testcase and entity

func (*SQLiteStore) GetEntityRelations

func (ss *SQLiteStore) GetEntityRelations(entity Entity) ([]Entity, error)

GetEntityRelations queries EntitiesRelation from db

func (*SQLiteStore) GetEvents

func (ss *SQLiteStore) GetEvents(whereConditions Conditions, orderBy string, limit int) ([]Event, error)

GetEvents queries events from db

func (*SQLiteStore) GetNumberEntities

func (ss *SQLiteStore) GetNumberEntities(
	whereConditions Conditions,
	orderBy string,
	limit int,
) ([]NumberEntities, error)

GetNumberEntities queries NumberEntities from db

func (*SQLiteStore) GetResourceUsage

func (ss *SQLiteStore) GetResourceUsage(
	whereConditions Conditions,
	orderBy string,
	limit int,
) ([]ResourceUsage, error)

GetResourceUsage queries resource usage from db

func (*SQLiteStore) GetTestCases

func (ss *SQLiteStore) GetTestCases(whereConditions Conditions, orderBy string, limit int) ([]TestCase, error)

GetTestCases queries testcases from db

func (*SQLiteStore) GetTestRuns

func (ss *SQLiteStore) GetTestRuns(whereConditions Conditions, orderBy string, limit int) ([]TestRun, error)

GetTestRuns queries test run information from db

func (*SQLiteStore) SaveEntities

func (ss *SQLiteStore) SaveEntities(entities []*Entity) error

SaveEntities saves entities in db

func (*SQLiteStore) SaveEvents

func (ss *SQLiteStore) SaveEvents(events []*Event) error

SaveEvents saves events into db

func (*SQLiteStore) SaveNumberEntities

func (ss *SQLiteStore) SaveNumberEntities(nEntities []*NumberEntities) error

SaveNumberEntities saves NumberEntities in db

func (*SQLiteStore) SaveResourceUsage

func (ss *SQLiteStore) SaveResourceUsage(resUsages []*ResourceUsage) error

SaveResourceUsage saves resource usage in db

func (*SQLiteStore) SaveTestCase

func (ss *SQLiteStore) SaveTestCase(ts *TestCase) error

SaveTestCase saves testcases in db

func (*SQLiteStore) SaveTestRun

func (ss *SQLiteStore) SaveTestRun(tr *TestRun) error

SaveTestRun saves test run result in db

func (*SQLiteStore) SuccessfulTestCase

func (ss *SQLiteStore) SuccessfulTestCase(ts *TestCase, endTimestamp time.Time) error

SuccessfulTestCase updates testcase status as success

type StorageClassDB

type StorageClassDB struct {
	StorageClass string
	DB           *SQLiteStore
	TestRun      TestRun
}

StorageClassDB represents storage class db

type Store

type Store interface {
	SaveTestRun(tr *TestRun) error
	GetTestRuns(whereConditions Conditions, orderBy string, limit int) ([]TestRun, error)
	SaveEvents(events []*Event) error
	GetEvents(whereConditions Conditions, orderBy string, limit int) ([]Event, error)
	SaveTestCase(ts *TestCase) error
	GetTestCases(whereConditions Conditions, orderBy string, limit int) ([]TestCase, error)
	SuccessfulTestCase(ts *TestCase, endTimestamp time.Time) error
	FailedTestCase(ts *TestCase, endTimestamp time.Time, errMsg string) error
	SaveEntities(entities []*Entity) error
	GetEntities(whereConditions Conditions, orderBy string, limit int) ([]Entity, error)
	GetEntitiesWithEventsByTestCaseAndEntityType(tc *TestCase, eType EntityTypeEnum) (map[Entity][]Event, error)
	SaveNumberEntities(nEntities []*NumberEntities) error
	GetNumberEntities(whereConditions Conditions, orderBy string, limit int) ([]NumberEntities, error)
	SaveResourceUsage(resUsages []*ResourceUsage) error
	GetResourceUsage(whereConditions Conditions, orderBy string, limit int) ([]ResourceUsage, error)
	CreateEntitiesRelation(entity1, entity2 Entity) error
	GetEntityRelations(event Entity) ([]Entity, error)
	Close() error
}

Store is a generic interface for stores

type TestCase

type TestCase struct {
	ID             int64
	Name           string
	Parameters     string
	StartTimestamp time.Time
	EndTimestamp   time.Time
	Success        bool
	ErrorMessage   string
	RunID          int64
}

TestCase struct

type TestRun

type TestRun struct {
	ID             int64
	Name           string
	Longevity      bool
	StartTimestamp time.Time
	StorageClass   string
	ClusterAddress string
}

TestRun struct

Jump to

Keyboard shortcuts

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