-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Arnob kumar saha <[email protected]>
- Loading branch information
1 parent
642f78c
commit 9df0259
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package apis | ||
|
||
import ( | ||
core "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
"testing" | ||
) | ||
|
||
var ( | ||
DefaultResources = core.ResourceRequirements{ | ||
Requests: core.ResourceList{ | ||
core.ResourceCPU: resource.MustParse(".500"), | ||
core.ResourceMemory: resource.MustParse("1.5Gi"), | ||
}, | ||
Limits: core.ResourceList{ | ||
core.ResourceCPU: resource.MustParse("1"), | ||
core.ResourceMemory: resource.MustParse("2Gi"), | ||
}, | ||
} | ||
) | ||
|
||
func TestSetDefaultResourceLimits(t *testing.T) { | ||
type args struct { | ||
req *core.ResourceRequirements | ||
defaultResources core.ResourceRequirements | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
}{ | ||
{ | ||
name: "both set", | ||
args: args{ | ||
req: &core.ResourceRequirements{ | ||
Requests: core.ResourceList{ | ||
core.ResourceCPU: resource.MustParse(".200"), | ||
core.ResourceMemory: resource.MustParse("1.2Gi"), | ||
}, | ||
Limits: core.ResourceList{ | ||
core.ResourceCPU: resource.MustParse(".2"), | ||
core.ResourceMemory: resource.MustParse("2.2Gi"), | ||
}, | ||
}, | ||
defaultResources: DefaultResources, | ||
}, | ||
}, | ||
{ | ||
name: "no defaults", | ||
}, | ||
{ | ||
name: "no requests", | ||
}, | ||
{ | ||
name: "no limits", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
old := tt.args.req | ||
SetDefaultResourceLimits(tt.args.req, tt.args.defaultResources) | ||
checkExpexcted(tt.args.req, old) | ||
}) | ||
} | ||
} | ||
|
||
func checkExpexcted(req *core.ResourceRequirements, old *core.ResourceRequirements) bool { | ||
// implement | ||
} |