Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/extended-priv/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,24 @@ func (cm *ConfigMap) GetDataValueOrFail(key string) string {
return value
}

// GetAll returns a []ConfigMap list with all existing pinnedimageset sorted by creation timestamp
func (cml *ConfigMapList) GetAll() ([]ConfigMap, error) {
// GetAll returns a []*ConfigMap list with all existing pinnedimageset sorted by creation timestamp
func (cml *ConfigMapList) GetAll() ([]*ConfigMap, error) {
cml.ResourceList.SortByTimestamp()
allResources, err := cml.ResourceList.GetAll()
if err != nil {
return nil, err
}
all := make([]ConfigMap, 0, len(allResources))
all := make([]*ConfigMap, 0, len(allResources))

for _, res := range allResources {
all = append(all, *NewConfigMap(cml.oc, res.namespace, res.name))
all = append(all, NewConfigMap(cml.oc, res.namespace, res.name))
}

return all, nil
}

// GetAllOrFail returns a []ConfigMap list with all existing pinnedimageset sorted by creation time, if any error happens it fails the test
func (cml *ConfigMapList) GetAllOrFail() []ConfigMap {
// GetAllOrFail returns a []*ConfigMap list with all existing pinnedimageset sorted by creation time, if any error happens it fails the test
func (cml *ConfigMapList) GetAllOrFail() []*ConfigMap {
all, err := cml.GetAll()
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "Error getting the list of existing ConfigMap in the cluster")
return all
Expand Down
16 changes: 8 additions & 8 deletions test/extended-priv/controlplanemachineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (cpms ControlPlaneMachineSet) SetUserDataSecret(userDataSecretName string)
}

// GetMachines returns a slice with the machines created for this ControlPlaneMachineSet
func (cpms ControlPlaneMachineSet) GetMachines() ([]Machine, error) {
func (cpms ControlPlaneMachineSet) GetMachines() ([]*Machine, error) {
ml := NewMachineList(cpms.oc, cpms.GetNamespace())
ml.ByLabel("machine.openshift.io/cluster-api-machine-role=master")
ml.ByLabel("machine.openshift.io/cluster-api-machine-type=master")
Expand All @@ -272,7 +272,7 @@ func (cpms ControlPlaneMachineSet) GetMachines() ([]Machine, error) {
}

// GetMachinesOrFail get machines from ControlPlaneMachineSet or fail the test if any error occurred
func (cpms ControlPlaneMachineSet) GetMachinesOrFail() []Machine {
func (cpms ControlPlaneMachineSet) GetMachinesOrFail() []*Machine {
ml, err := cpms.GetMachines()
o.Expect(err).NotTo(o.HaveOccurred(), "Get machines of ControlPlaneMachineSet %s failed", cpms.GetName())
return ml
Expand Down Expand Up @@ -304,23 +304,23 @@ func (cpms ControlPlaneMachineSet) GetNodesOrFail() []*Node {
return nodes
}

// GetAll returns a []ControlPlaneMachineSet list with all existing ControlPlaneMachineSets
func (cpmsl *ControlPlaneMachineSetList) GetAll() ([]ControlPlaneMachineSet, error) {
// GetAll returns a []*ControlPlaneMachineSet list with all existing ControlPlaneMachineSets
func (cpmsl *ControlPlaneMachineSetList) GetAll() ([]*ControlPlaneMachineSet, error) {
allCPMSResources, err := cpmsl.ResourceList.GetAll()
if err != nil {
return nil, err
}
allCPMS := make([]ControlPlaneMachineSet, 0, len(allCPMSResources))
allCPMS := make([]*ControlPlaneMachineSet, 0, len(allCPMSResources))

for _, cpmsRes := range allCPMSResources {
allCPMS = append(allCPMS, *NewControlPlaneMachineSet(cpmsl.oc, cpmsRes.GetNamespace(), cpmsRes.GetName()))
allCPMS = append(allCPMS, NewControlPlaneMachineSet(cpmsl.oc, cpmsRes.GetNamespace(), cpmsRes.GetName()))
}

return allCPMS, nil
}

// GetAllOrFail returns a []ControlPlaneMachineSet list with all existing ControlPlaneMachineSets and fail the test if it is not possible
func (cpmsl *ControlPlaneMachineSetList) GetAllOrFail() []ControlPlaneMachineSet {
// GetAllOrFail returns a []*ControlPlaneMachineSet list with all existing ControlPlaneMachineSets and fail the test if it is not possible
func (cpmsl *ControlPlaneMachineSetList) GetAllOrFail() []*ControlPlaneMachineSet {
allCpms, err := cpmsl.GetAll()
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "Error getting the list of existing ControlPlaneMachineSets")

Expand Down
31 changes: 16 additions & 15 deletions test/extended-priv/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ func NewEventList(oc *exutil.CLI, namespace string) *EventList {
return &EventList{*NewNamespacedResourceList(oc, "Event", namespace)}
}

// GetAll returns a []Event list with all existing events sorted by last occurrence
// GetAll returns a []*Event list with all existing events sorted by last occurrence
// the first element will be the most recent one
func (el *EventList) GetAll() ([]Event, error) {
func (el *EventList) GetAll() ([]*Event, error) {
el.SortByLastTimestamp()
allEventResources, err := el.ResourceList.GetAll()
if err != nil {
return nil, err
}
allEvents := make([]Event, 0, len(allEventResources))
allEvents := make([]*Event, 0, len(allEventResources))

for _, eventRes := range allEventResources {
allEvents = append(allEvents, *NewEvent(el.oc, eventRes.namespace, eventRes.name))
allEvents = append(allEvents, NewEvent(el.oc, eventRes.namespace, eventRes.name))
}
// We want the first element to be the more recent
allEvents = reverseEventsList(allEvents)
Expand All @@ -100,11 +100,11 @@ func (el *EventList) GetLatest() (*Event, error) {
return nil, nil
}

return &(allEvents[0]), nil
return allEvents[0], nil
}

// GetAllEventsSinceEvent returns all events that occurred since a given event (not included)
func (el *EventList) GetAllEventsSinceEvent(sinceEvent *Event) ([]Event, error) {
func (el *EventList) GetAllEventsSinceEvent(sinceEvent *Event) ([]*Event, error) {
allEvents, lerr := el.GetAll()
if lerr != nil {
logger.Errorf("Error getting events %s", lerr)
Expand All @@ -115,7 +115,7 @@ func (el *EventList) GetAllEventsSinceEvent(sinceEvent *Event) ([]Event, error)
return allEvents, nil
}

returnEvents := []Event{}
returnEvents := []*Event{}
for _, event := range allEvents {
if event.name == sinceEvent.name {
break
Expand All @@ -127,7 +127,7 @@ func (el *EventList) GetAllEventsSinceEvent(sinceEvent *Event) ([]Event, error)
}

// GetAllSince return a list of the events that happened since the provided duration
func (el *EventList) GetAllSince(since time.Time) ([]Event, error) {
func (el *EventList) GetAllSince(since time.Time) ([]*Event, error) {
// Remove log noise
el.oc.NotShowInfo()
defer el.oc.SetShowInfo()
Expand All @@ -138,7 +138,7 @@ func (el *EventList) GetAllSince(since time.Time) ([]Event, error) {
return nil, lerr
}

returnEvents := []Event{}
returnEvents := []*Event{}
for _, loopEvent := range allEvents {
event := loopEvent // this is to make sure that we execute defer in all events, and not only in the last one
// Remove log noise
Expand All @@ -162,7 +162,7 @@ func (el *EventList) GetAllSince(since time.Time) ([]Event, error) {
}

// from https://github.com/golang/go/wiki/SliceTricks#reversing
func reverseEventsList(a []Event) []Event {
func reverseEventsList(a []*Event) []*Event {

for i := len(a)/2 - 1; i >= 0; i-- {
opp := len(a) - 1 - i
Expand Down Expand Up @@ -202,14 +202,15 @@ type haveEventsSequenceMatcher struct {
func (matcher *haveEventsSequenceMatcher) Match(actual interface{}) (success bool, err error) {

logger.Infof("Start verifying events sequence: %s", matcher.sequence)
events, ok := actual.([]Event)
events, ok := actual.([]*Event)
if !ok {
return false, fmt.Errorf("HaveSequence matcher expects a slice of Events in test case %v", g.CurrentSpecReport().FullText())
return false, fmt.Errorf("HaveSequence matcher expects a slice of []*Event in test case %v", g.CurrentSpecReport().FullText())
}

// To avoid too many "oc" executions we store the events information in a cached struct list with "lastTimestamp" and "reason" fields.
tmpEvents := make([]tmpEvent, len(events))
for index, event := range events {
for index, loopEvent := range events {
event := loopEvent // this is to make sure that we execute defer in all events, and not only in the last one
event.oc.NotShowInfo()
defer event.oc.SetShowInfo()

Expand Down Expand Up @@ -258,7 +259,7 @@ func (matcher *haveEventsSequenceMatcher) Match(actual interface{}) (success boo

func (matcher *haveEventsSequenceMatcher) FailureMessage(actual interface{}) (message string) {
// The type was already validated in Match, we can safely ignore the error
events, _ := actual.([]Event)
events, _ := actual.([]*Event)

var output strings.Builder

Expand All @@ -277,7 +278,7 @@ func (matcher *haveEventsSequenceMatcher) FailureMessage(actual interface{}) (me

func (matcher *haveEventsSequenceMatcher) NegatedFailureMessage(actual interface{}) (message string) {
// The type was already validated in Match, we can safely ignore the error
events, _ := actual.([]Event)
events, _ := actual.([]*Event)

var output strings.Builder
output.WriteString("Expecte events\n")
Expand Down
14 changes: 7 additions & 7 deletions test/extended-priv/generic_behaviour_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type Checker interface {
Check(checkedNodes ...Node)
Check(checkedNodes ...*Node)
}

type CommandOutputChecker struct {
Expand All @@ -21,7 +21,7 @@ type CommandOutputChecker struct {
Desc string
}

func (cOutChecker CommandOutputChecker) Check(checkedNodes ...Node) {
func (cOutChecker CommandOutputChecker) Check(checkedNodes ...*Node) {
msg := "Executing verification commands"
if cOutChecker.Desc != "" {
msg = cOutChecker.Desc
Expand All @@ -47,7 +47,7 @@ type RemoteFileChecker struct {
Desc string
}

func (rfc RemoteFileChecker) Check(checkedNodes ...Node) {
func (rfc RemoteFileChecker) Check(checkedNodes ...*Node) {
msg := fmt.Sprintf("Checking file: %s", rfc.FileFullPath)
if rfc.Desc != "" {
msg = rfc.Desc
Expand All @@ -65,12 +65,12 @@ func (rfc RemoteFileChecker) Check(checkedNodes ...Node) {
}

// checkDrainAction checks that the drain action in the node is the expected one (drainSkipped)
func checkDrainAction(drainSkipped bool, node Node, controller *Controller) {
func checkDrainAction(drainSkipped bool, node *Node, controller *Controller) {
checkDrainActionWithGomega(drainSkipped, node, controller, o.Default)
}

// checkDrainActionWithGomega checks that the drain action in the node is the expected one (drainSkipped). It accepts an extra Gomega parameter that allows the function to be used in the Eventually gomega matchers
func checkDrainActionWithGomega(drainExecuted bool, node Node, controller *Controller, gm o.Gomega) {
func checkDrainActionWithGomega(drainExecuted bool, node *Node, controller *Controller, gm o.Gomega) {
var (
execDrainLogMsg = "initiating drain"
)
Expand All @@ -97,12 +97,12 @@ func checkDrainActionWithGomega(drainExecuted bool, node Node, controller *Contr
}

// checkRebootAction checks that the reboot action in the node is the expected one (rebootSkipped)
func checkRebootAction(rebootExecuted bool, node Node, startTime time.Time) {
func checkRebootAction(rebootExecuted bool, node *Node, startTime time.Time) {
checkRebootActionWithGomega(rebootExecuted, node, startTime, o.Default)
}

// checkRebootActionWithGomega checks that the reboot action in the node is the expected one (rebootSkipped). It accepts an extra Gomega parameter that allows the function to be used in the Eventually gomega matchers
func checkRebootActionWithGomega(rebootExecuted bool, node Node, startTime time.Time, gm o.Gomega) {
func checkRebootActionWithGomega(rebootExecuted bool, node *Node, startTime time.Time, gm o.Gomega) {
if rebootExecuted {
logger.Infof("Checking that node %s was rebooted", node.GetName())
gm.Expect(node.GetUptime()).Should(o.BeTemporally(">", startTime),
Expand Down
10 changes: 5 additions & 5 deletions test/extended-priv/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (m Machine) GetNode() (*Node, error) {
return nil, fmt.Errorf("No node linked to this Machine. Machine: %s", m.GetName())
}

return &(nodes[0]), nil
return nodes[0], nil
}

// GetNodeOrFail, call GetNode, fail the test if any error occurred
Expand Down Expand Up @@ -75,16 +75,16 @@ func NewMachineList(oc *exutil.CLI, namespace string) *MachineList {
return &MachineList{*NewNamespacedResourceList(oc, MachineFullName, namespace)}
}

// GetAll returns a []Machine slice with all existing nodes
func (ml MachineList) GetAll() ([]Machine, error) {
// GetAll returns a []*Machine slice with all existing nodes
func (ml MachineList) GetAll() ([]*Machine, error) {
allMResources, err := ml.ResourceList.GetAll()
if err != nil {
return nil, err
}
allMs := make([]Machine, 0, len(allMResources))
allMs := make([]*Machine, 0, len(allMResources))

for _, mRes := range allMResources {
allMs = append(allMs, *NewMachine(ml.oc, mRes.GetNamespace(), mRes.GetName()))
allMs = append(allMs, NewMachine(ml.oc, mRes.GetNamespace(), mRes.GetName()))
}

return allMs, nil
Expand Down
Loading