This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathutils_test.go
85 lines (73 loc) · 2.28 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package subsystem
import (
"context"
"time"
"github.com/filanov/bm-inventory/client/installer"
"github.com/filanov/bm-inventory/models"
"github.com/go-openapi/strfmt"
"github.com/google/uuid"
. "github.com/onsi/gomega"
)
const (
defaultWaitForHostStateTimeout = 20 * time.Second
defaultWaitForClusterStateTimeout = 30 * time.Second
)
func clearDB() {
db.Delete(&models.Host{})
db.Delete(&models.Cluster{})
}
func strToUUID(s string) *strfmt.UUID {
u := strfmt.UUID(s)
return &u
}
func registerHost(clusterID strfmt.UUID) *models.Host {
host, err := bmclient.Installer.RegisterHost(context.Background(), &installer.RegisterHostParams{
ClusterID: clusterID,
NewHostParams: &models.HostCreateParams{
HostID: strToUUID(uuid.New().String()),
},
})
Expect(err).NotTo(HaveOccurred())
return host.GetPayload()
}
func getHost(clusterID, hostID strfmt.UUID) *models.Host {
host, err := bmclient.Installer.GetHost(context.Background(), &installer.GetHostParams{
ClusterID: clusterID,
HostID: hostID,
})
Expect(err).NotTo(HaveOccurred())
return host.GetPayload()
}
func getStepInList(steps models.Steps, sType models.StepType) (*models.Step, bool) {
for _, step := range steps.Instructions {
if step.StepType == sType {
return step, true
}
}
return nil, false
}
func getNextSteps(clusterID, hostID strfmt.UUID) models.Steps {
steps, err := bmclient.Installer.GetNextSteps(context.Background(), &installer.GetNextStepsParams{
ClusterID: clusterID,
HostID: hostID,
})
Expect(err).NotTo(HaveOccurred())
return *steps.GetPayload()
}
func updateProgress(hostID strfmt.UUID, clusterID strfmt.UUID, current_step models.HostStage) {
updateProgressWithInfo(hostID, clusterID, current_step, "")
}
func updateProgressWithInfo(hostID strfmt.UUID, clusterID strfmt.UUID, current_step models.HostStage, info string) {
ctx := context.Background()
installProgress := &models.HostProgress{
CurrentStage: current_step,
ProgressInfo: info,
}
updateReply, err := bmclient.Installer.UpdateHostInstallProgress(ctx, &installer.UpdateHostInstallProgressParams{
ClusterID: clusterID,
HostProgress: installProgress,
HostID: hostID,
})
Expect(err).ShouldNot(HaveOccurred())
Expect(updateReply).Should(BeAssignableToTypeOf(installer.NewUpdateHostInstallProgressOK()))
}