Skip to content

Commit 24a8e78

Browse files
authored
Merge pull request #107 from openebs/platform-csi-provisioner
chore: add config for platform csi provisioner
2 parents 9913de7 + 0416e6a commit 24a8e78

File tree

4 files changed

+92
-18
lines changed

4 files changed

+92
-18
lines changed

common/e2e_config/e2e_config.go

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ type E2EConfig struct {
169169
FilteredMayastorPodCheck int `yaml:"filteredMayastorPodCheck" env-default:"0"`
170170
// data plane interface
171171
IOEngineTargetNvmfIface string `yaml:"ioengineTargetNvmfIface" env-default:"" env:"e2e_ioengine_target_nvmf_iface"`
172+
// CSI provisioner , HZ: csi.hetzner.cloud
173+
CsiProvisioner string `yaml:"csiProvisioner" env-default:"csi.hetzner.cloud"`
172174
} `yaml:"platform"`
173175
Product ProductSpec `yaml:"product"`
174176

common/k8stest/util.go

+35-18
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,6 @@ func DeploymentReady(deploymentName, namespace string) bool {
380380
return false
381381
}
382382

383-
func DaemonSetReady(daemonName string, namespace string) bool {
384-
daemon, err := gTestEnv.KubeInt.AppsV1().DaemonSets(namespace).Get(
385-
context.TODO(),
386-
daemonName,
387-
metaV1.GetOptions{},
388-
)
389-
if err != nil {
390-
logf.Log.Info("Failed to get daemonset", "error", err)
391-
return false
392-
}
393-
394-
status := daemon.Status
395-
logf.Log.Info("DaemonSet "+daemonName, "status", status)
396-
return status.DesiredNumberScheduled == status.CurrentNumberScheduled &&
397-
status.DesiredNumberScheduled == status.NumberReady &&
398-
status.DesiredNumberScheduled == status.NumberAvailable
399-
}
400-
401383
func ControlPlaneReady(sleepTime int, duration int) bool {
402384
ready := false
403385
count := (duration + sleepTime - 1) / sleepTime
@@ -1886,3 +1868,38 @@ func WaitForDeploymentToMatchExpectedState(deployName string, namespace string,
18861868
}
18871869
return false, err
18881870
}
1871+
1872+
// SizeToBytes return size in bytes, input can be string like 10 GiB , 512 MiB
1873+
func SizeToBytes(capacity string) (uint64, error) {
1874+
// Map for unit multipliers
1875+
unitMultipliers := map[string]float64{
1876+
"KiB": 1024,
1877+
"MiB": math.Pow(1024, 2),
1878+
"GiB": math.Pow(1024, 3),
1879+
"TiB": math.Pow(1024, 4),
1880+
"PiB": math.Pow(1024, 5),
1881+
}
1882+
1883+
// Split capacity into value and unit
1884+
parts := strings.Fields(capacity)
1885+
if len(parts) != 2 {
1886+
return 0, fmt.Errorf("invalid size string format")
1887+
}
1888+
1889+
// Parse the numeric value
1890+
value, err := strconv.ParseFloat(parts[0], 64)
1891+
if err != nil {
1892+
return 0, fmt.Errorf("invalid numeric value in size: %v", err)
1893+
}
1894+
1895+
// Get the multiplier for the unit
1896+
unit := parts[1]
1897+
multiplier, exists := unitMultipliers[unit]
1898+
if !exists {
1899+
return 0, fmt.Errorf("invalid or unsupported unit: %s", unit)
1900+
}
1901+
1902+
// Calculate bytes
1903+
bytes := value * multiplier
1904+
return uint64(bytes), nil
1905+
}

common/k8stest/util_daemonset.go

+54
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package k8stest
33
import (
44
"context"
55
"fmt"
6+
"time"
67

78
appsV1 "k8s.io/api/apps/v1"
89
v1 "k8s.io/api/apps/v1"
910
coreV1 "k8s.io/api/core/v1"
1011
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+
logf "sigs.k8s.io/controller-runtime/pkg/log"
1113
)
1214

1315
func ListDaemonSet(namespace string) (v1.DaemonSetList, error) {
@@ -109,3 +111,55 @@ func UpdateDemonsetContainerAllEnv(daemonsetName string, containerName string, n
109111
}
110112
return nil
111113
}
114+
115+
func WaitForDaemonsetReady(dsName string, namespace string, sleepTime int, duration int) bool {
116+
ready := false
117+
count := (duration + sleepTime - 1) / sleepTime
118+
119+
logf.Log.Info("DaemonsetReadyCheck", "Daemonet", dsName, "namespace", namespace)
120+
for ix := 0; ix < count && !ready; ix++ {
121+
time.Sleep(time.Duration(sleepTime) * time.Second)
122+
123+
ready = DaemonSetReady(dsName, namespace)
124+
logf.Log.Info("DaemonSetReady: ", "daemonset", dsName, "ready", ready)
125+
}
126+
127+
if !ready {
128+
logf.Log.Info("Daemonset not ready", "Daemonset", dsName, "namespace", namespace)
129+
return false
130+
}
131+
132+
dsPodList, err := ListPodsByPrefix(namespace, dsName)
133+
if err != nil {
134+
logf.Log.Info("Failed to list pods with daemonset prefix", "daemonset", dsName, "error", err)
135+
return false
136+
}
137+
for _, pod := range dsPodList {
138+
// verify pod running
139+
err := WaitForPodRunning(pod.Name, namespace, duration)
140+
if err != nil {
141+
logf.Log.Info("Pod not ready", "Pod name", pod.Name, "namespace", namespace)
142+
return false
143+
}
144+
145+
}
146+
return ready
147+
}
148+
149+
func DaemonSetReady(daemonName string, namespace string) bool {
150+
daemon, err := gTestEnv.KubeInt.AppsV1().DaemonSets(namespace).Get(
151+
context.TODO(),
152+
daemonName,
153+
metaV1.GetOptions{},
154+
)
155+
if err != nil {
156+
logf.Log.Info("Failed to get daemonset", "error", err)
157+
return false
158+
}
159+
160+
status := daemon.Status
161+
logf.Log.Info("DaemonSet "+daemonName, "status", status)
162+
return status.DesiredNumberScheduled == status.CurrentNumberScheduled &&
163+
status.DesiredNumberScheduled == status.NumberReady &&
164+
status.DesiredNumberScheduled == status.NumberAvailable
165+
}

configurations/hcloudci_config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ deferredAssert: true
88
beforeEachCheckAndRestart: true
99
ioEngineNvmeTimeout: 110
1010
networkInterface: eth0
11+
csiProvisioner: csi.hetzner.cloud

0 commit comments

Comments
 (0)