Skip to content

Commit

Permalink
added unit test with regional MIG
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwinhr716 committed Mar 13, 2024
1 parent f8b4727 commit 4a38f69
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,13 @@ func TestGetMigInstanceTemplateName(t *testing.T) {
instanceGroupManager := &gce.InstanceGroupManager{
Zone: mig.GceRef().Zone,
Name: mig.GceRef().Name,
InstanceTemplate: templateName,
InstanceTemplate: "https://www.googleapis.com/compute/v1/projects/test-project/global/instanceTemplates/template-name",
}

instanceGroupManagerRegional := &gce.InstanceGroupManager{
Zone: mig.GceRef().Zone,
Name: mig.GceRef().Name,
InstanceTemplate: "https://www.googleapis.com/compute/v1/projects/test-project/regions/us-central1/instanceTemplates/template-name",
}

testCases := []struct {
Expand All @@ -861,6 +867,7 @@ func TestGetMigInstanceTemplateName(t *testing.T) {
fetchMigs func(string) ([]*gce.InstanceGroupManager, error)
fetchMigTemplateName func(GceRef) (InstanceTemplateName, error)
expectedTemplateName string
expectedRegion bool
expectedErr error
}{
{
Expand All @@ -877,6 +884,12 @@ func TestGetMigInstanceTemplateName(t *testing.T) {
fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{instanceGroupManager}),
expectedTemplateName: templateName,
},
{
name: "target size from cache fill, regional",
cache: emptyCache(),
fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{instanceGroupManagerRegional}),
expectedTemplateName: templateName,
},
{
name: "cache fill without mig, fallback success",
cache: emptyCache(),
Expand Down

0 comments on commit 4a38f69

Please sign in to comment.