|
|
@@ -125,6 +125,38 @@ func TestPVPriceFromCSV(t *testing.T) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+func TestPVPriceFromCSVStorageClass(t *testing.T) {
|
|
|
+ nameWant := "pvc-08e1f205-d7a9-4430-90fc-7b3965a18c4d"
|
|
|
+ storageClassWant := "storageclass0"
|
|
|
+ pv := &v1.PersistentVolume{}
|
|
|
+ pv.Name = nameWant
|
|
|
+ pv.Spec.StorageClassName = storageClassWant
|
|
|
+
|
|
|
+ confMan := config.NewConfigFileManager(&config.ConfigFileManagerOpts{
|
|
|
+ LocalConfigPath: "./",
|
|
|
+ })
|
|
|
+
|
|
|
+ wantPrice := "0.1338"
|
|
|
+ c := &cloud.CSVProvider{
|
|
|
+ CSVLocation: "../configs/pricing_schema_pv_storageclass.csv",
|
|
|
+ CustomProvider: &cloud.CustomProvider{
|
|
|
+ Config: cloud.NewProviderConfig(confMan, "../configs/default.json"),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ c.DownloadPricingData()
|
|
|
+ k := c.GetPVKey(pv, make(map[string]string), "")
|
|
|
+ resPV, err := c.PVPricing(k)
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Error in NodePricing: %s", err.Error())
|
|
|
+ } else {
|
|
|
+ gotPrice := resPV.Cost
|
|
|
+ if gotPrice != wantPrice {
|
|
|
+ t.Errorf("Wanted price '%s' got price '%s'", wantPrice, gotPrice)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
func TestNodePriceFromCSVWithGPU(t *testing.T) {
|
|
|
providerIDWant := "providerid"
|
|
|
nameWant := "gke-standard-cluster-1-pool-1-91dc432d-cg69"
|