-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hatchery): openstack max CPUs count and flavor weigth (#5190)
* feat(hatchery): openstask max CPUs count and flavor weigth * feat: sort and filter models enabled, check max CPUs count * feat: impl CountSmallerFlavorToKeep check * test: unit test func
- Loading branch information
Showing
9 changed files
with
415 additions
and
65 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
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
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,41 @@ | ||
package openstack | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ovh/cds/sdk/log" | ||
) | ||
|
||
func TestHatcheryOpenstack_initFlavors(t *testing.T) { | ||
log.SetLogger(t) | ||
|
||
h := &HatcheryOpenstack{} | ||
|
||
allFlavors := []flavors.Flavor{ | ||
{Name: "b2-7", VCPUs: 2}, | ||
{Name: "b2-15", VCPUs: 4}, | ||
{Name: "b2-30", VCPUs: 8}, | ||
{Name: "b2-60", VCPUs: 16}, | ||
{Name: "b2-120", VCPUs: 32}, | ||
} | ||
|
||
filteredFlavors := h.filterAllowedFlavors(allFlavors) | ||
require.Len(t, filteredFlavors, 5, "no filter as allowed flavor list is empty in config") | ||
|
||
h.Config.AllowedFlavors = []string{"b2-15", "b2-60"} | ||
|
||
filteredFlavors = h.filterAllowedFlavors(allFlavors) | ||
require.Len(t, filteredFlavors, 2) | ||
assert.Equal(t, "b2-15", filteredFlavors[0].Name) | ||
assert.Equal(t, "b2-60", filteredFlavors[1].Name) | ||
|
||
h.Config.AllowedFlavors = []string{"s1-4", "b2-15"} | ||
|
||
filteredFlavors = h.filterAllowedFlavors(allFlavors) | ||
require.Len(t, filteredFlavors, 1) | ||
assert.Equal(t, "b2-15", filteredFlavors[0].Name) | ||
} |
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
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
Oops, something went wrong.