mirror of
https://github.com/kastenhq/kubestr.git
synced 2024-12-14 11:57:56 +00:00
parent
a59299897c
commit
9e128826bd
4 changed files with 14 additions and 15 deletions
|
@ -10,7 +10,7 @@ readonly -a REQUIRED_TOOLS=(
|
|||
kubectl
|
||||
)
|
||||
|
||||
DEFAULT_IMAGE_TAG="0.2.0"
|
||||
DEFAULT_IMAGE_TAG="latest"
|
||||
DEFAULT_JOB_NAME="kubestr"
|
||||
|
||||
helpFunction()
|
||||
|
|
|
@ -24,7 +24,6 @@ const (
|
|||
ConfigMapSCKey = "storageclass"
|
||||
// ConfigMapSizeKey describes the size key in a config map
|
||||
ConfigMapSizeKey = "pvcsize"
|
||||
ConfigMapPredefinedTestKey = "fiotest.fio"
|
||||
// DefaultPVCSize is the default PVC size
|
||||
DefaultPVCSize = "100Gi"
|
||||
// PVCGenerateName is the name to generate for the PVC
|
||||
|
@ -154,11 +153,11 @@ func (s *fioStepper) storageClassExists(ctx context.Context, storageClass string
|
|||
return nil
|
||||
}
|
||||
|
||||
func getConfigMapJob(jobName string) *v1.ConfigMap {
|
||||
if jobName == "" {
|
||||
jobName = DefaultFIOJob
|
||||
func getConfigMapJob(jobNamePtr *string) *v1.ConfigMap {
|
||||
if *jobNamePtr == "" {
|
||||
*jobNamePtr = DefaultFIOJob
|
||||
}
|
||||
cm, ok := fioJobs[jobName]
|
||||
cm, ok := fioJobs[*jobNamePtr]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
@ -167,7 +166,7 @@ func getConfigMapJob(jobName string) *v1.ConfigMap {
|
|||
|
||||
func (s *fioStepper) loadConfigMap(ctx context.Context, args *RunFIOArgs) (*v1.ConfigMap, error) {
|
||||
if args.ConfigMapName == "" {
|
||||
cm := getConfigMapJob(args.JobName)
|
||||
cm := getConfigMapJob(&args.JobName)
|
||||
if cm == nil {
|
||||
return nil, fmt.Errorf("Predefined job (%s) not found", args.JobName)
|
||||
}
|
||||
|
@ -191,19 +190,18 @@ func (s *fioStepper) loadConfigMap(ctx context.Context, args *RunFIOArgs) (*v1.C
|
|||
if val, ok := configMap.Data[ConfigMapSizeKey]; !ok || val == "" {
|
||||
configMap.Data[ConfigMapSizeKey] = DefaultPVCSize
|
||||
}
|
||||
|
||||
// if entry fio entry exists use it.
|
||||
for key := range configMap.Data {
|
||||
if key != ConfigMapSizeKey && key != ConfigMapSCKey {
|
||||
return configMap, nil
|
||||
return s.cli.CoreV1().ConfigMaps(GetPodNamespace()).Update(ctx, configMap, metav1.UpdateOptions{})
|
||||
}
|
||||
}
|
||||
// otherwise load one
|
||||
cm := getConfigMapJob(args.JobName)
|
||||
cm := getConfigMapJob(&args.JobName)
|
||||
if cm == nil {
|
||||
return nil, fmt.Errorf("Predefined job (%s) not found in configmap", args.JobName)
|
||||
}
|
||||
configMap.Data[ConfigMapPredefinedTestKey] = cm.Data[ConfigMapPredefinedTestKey]
|
||||
configMap.Data[args.JobName] = cm.Data[args.JobName]
|
||||
return s.cli.CoreV1().ConfigMaps(GetPodNamespace()).Update(ctx, configMap, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ var fioJobs = map[string]*v1.ConfigMap{
|
|||
GenerateName: DefaultFIOJob,
|
||||
},
|
||||
Data: map[string]string{
|
||||
ConfigMapPredefinedTestKey: testJob1,
|
||||
DefaultFIOJob: testJob1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@ package kubestr
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/kastenhq/kubestr/pkg/fio"
|
||||
)
|
||||
|
||||
func (p *Kubestr) FIO(ctx context.Context, storageClass, configMap, jobName string) *TestOutput {
|
||||
testName := "FIO test results-"
|
||||
testName := "FIO test results"
|
||||
fioResult, err := p.fio.RunFio(ctx, &fio.RunFIOArgs{
|
||||
StorageClass: storageClass,
|
||||
ConfigMapName: configMap,
|
||||
|
@ -16,5 +17,5 @@ func (p *Kubestr) FIO(ctx context.Context, storageClass, configMap, jobName stri
|
|||
if err != nil {
|
||||
return makeTestOutput(testName, StatusError, err.Error(), nil)
|
||||
}
|
||||
return makeTestOutput(testName, StatusOK, fioResult, fioResult)
|
||||
return makeTestOutput(testName, StatusOK, fmt.Sprintf("\n%s\n", fioResult), fioResult)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue