Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more scheduling unit tests #1565

Merged
merged 3 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions pkg/cloudprovider/fake/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package fake

import (
"fmt"
"strings"

"github.com/aws/karpenter/pkg/apis/provisioning/v1alpha5"

"github.com/aws/karpenter/pkg/cloudprovider/aws/apis/v1alpha1"

Expand Down Expand Up @@ -65,6 +68,40 @@ func NewInstanceType(options InstanceTypeOptions) *InstanceType {
}
}

// InstanceTypesAssorted create many unique instance types with varying CPU/memory/architecture/OS/zone/capacity type.
func InstanceTypesAssorted() []cloudprovider.InstanceType {
var instanceTypes []cloudprovider.InstanceType
for _, cpu := range []int{1, 2, 4, 8, 16, 32, 64} {
tzneal marked this conversation as resolved.
Show resolved Hide resolved
for _, mem := range []int{1, 2, 4, 8, 16, 32, 64, 128} {
for _, zone := range []string{"test-zone-1", "test-zone-2", "test-zone-3"} {
for _, ct := range []string{v1alpha1.CapacityTypeSpot, v1alpha1.CapacityTypeOnDemand} {
for _, os := range []sets.String{sets.NewString("linux"), sets.NewString("windows")} {
for _, arch := range []string{v1alpha5.ArchitectureAmd64, v1alpha5.ArchitectureArm64} {
it := NewInstanceType(InstanceTypeOptions{
Name: fmt.Sprintf("%d-cpu-%d-mem-%s-%s-%s-%s", cpu, mem, arch, strings.Join(os.List(), ","), zone, ct),
Architecture: arch,
OperatingSystems: os,
Resources: v1.ResourceList{
v1.ResourceCPU: resource.MustParse(fmt.Sprintf("%d", cpu)),
v1.ResourceMemory: resource.MustParse(fmt.Sprintf("%dGi", mem)),
},
Offerings: []cloudprovider.Offering{
{
CapacityType: ct,
Zone: zone,
},
},
})
instanceTypes = append(instanceTypes, it)
}
}
}
}
}
}
return instanceTypes
}

// InstanceTypes creates instance types with incrementing resources
// 2Gi of RAM and 10 pods for every 1vcpu
// i.e. 1vcpu, 2Gi mem, 10 pods
Expand Down
Loading