Skip to content

Commit

Permalink
Add utilization testing to integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Oct 23, 2023
1 parent 1fdff8a commit 83c66c5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package utilization_test
package integration_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -29,26 +26,8 @@ import (
"github.com/aws/karpenter/test/pkg/debug"

awstest "github.com/aws/karpenter/pkg/test"
"github.com/aws/karpenter/test/pkg/environment/aws"
)

var env *aws.Environment

func TestUtilization(t *testing.T) {
RegisterFailHandler(Fail)
BeforeSuite(func() {
env = aws.NewEnvironment(t)
})
AfterSuite(func() {
env.Stop()
})
RunSpecs(t, "Alpha/Utilization")
}

var _ = BeforeEach(func() { env.BeforeEach() })
var _ = AfterEach(func() { env.Cleanup() })
var _ = AfterEach(func() { env.AfterEach() })

var _ = Describe("Utilization", Label(debug.NoWatch), Label(debug.NoEvents), func() {
It("should provision one pod per node", func() {
provider := awstest.AWSNodeTemplate(v1alpha1.AWSNodeTemplateSpec{AWS: v1alpha1.AWS{
Expand Down
43 changes: 43 additions & 0 deletions test/suites/beta/integration/utilization_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package integration_test

import (
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/labels"

"github.com/aws/karpenter-core/pkg/test"
"github.com/aws/karpenter/test/pkg/debug"
)

var _ = Describe("Utilization", Label(debug.NoWatch), Label(debug.NoEvents), func() {
It("should provision one pod per node", func() {
nodePool.Spec.Template.Spec.Requirements = append(nodePool.Spec.Template.Spec.Requirements, v1.NodeSelectorRequirement{
Key: v1.LabelInstanceTypeStable,
Operator: v1.NodeSelectorOpIn,
Values: []string{"t3a.small"},
})

deployment := test.Deployment(test.DeploymentOptions{
Replicas: 100,
PodOptions: test.PodOptions{ResourceRequirements: v1.ResourceRequirements{Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1.5")}}}})

env.ExpectCreated(nodeClass, nodePool, deployment)
env.EventuallyExpectHealthyPodCount(labels.SelectorFromSet(deployment.Spec.Selector.MatchLabels), int(*deployment.Spec.Replicas))
env.ExpectCreatedNodeCount("==", int(*deployment.Spec.Replicas)) // One pod per node enforced by instance size
})
})

0 comments on commit 83c66c5

Please sign in to comment.