|
| 1 | +/* |
| 2 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +you may not use this file except in compliance with the License. |
| 4 | +You may obtain a copy of the License at |
| 5 | +
|
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software |
| 9 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +See the License for the specific language governing permissions and |
| 12 | +limitations under the License. |
| 13 | +*/ |
| 14 | + |
| 15 | +package webhooks_test |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + "testing" |
| 20 | + |
| 21 | + v1beta1 "github.com/aws/karpenter/pkg/apis/v1beta1" |
| 22 | + "github.com/aws/karpenter/test/pkg/environment/aws" |
| 23 | + |
| 24 | + karpv1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" |
| 25 | + |
| 26 | + karptest "sigs.k8s.io/karpenter/pkg/test" |
| 27 | + |
| 28 | + . "github.com/onsi/ginkgo/v2" |
| 29 | + . "github.com/onsi/gomega" |
| 30 | + . "knative.dev/pkg/logging/testing" |
| 31 | +) |
| 32 | + |
| 33 | +var ctx context.Context |
| 34 | +var env *aws.Environment |
| 35 | +var nodeClass *v1beta1.EC2NodeClass |
| 36 | +var nodePool *karpv1beta1.NodePool |
| 37 | + |
| 38 | +func TestWebhooks(t *testing.T) { |
| 39 | + RegisterFailHandler(Fail) |
| 40 | + |
| 41 | + ctx = TestContextWithLogger(t) |
| 42 | + BeforeSuite(func() { |
| 43 | + env = aws.NewEnvironment(t) |
| 44 | + }) |
| 45 | + AfterSuite(func() { |
| 46 | + env.Stop() |
| 47 | + }) |
| 48 | + RunSpecs(t, "Webhooks") |
| 49 | +} |
| 50 | + |
| 51 | +var _ = BeforeEach(func() { |
| 52 | + env.BeforeEach() |
| 53 | + nodeClass = env.DefaultEC2NodeClass() |
| 54 | + nodePool = env.DefaultNodePool(nodeClass) |
| 55 | +}) |
| 56 | +var _ = AfterEach(func() { env.Cleanup() }) |
| 57 | +var _ = AfterEach(func() { env.AfterEach() }) |
| 58 | + |
| 59 | +var _ = Describe("Webhooks", func() { |
| 60 | + It("should schedule pods when webhooks are disabled", func() { |
| 61 | + pod := karptest.Pod() |
| 62 | + env.ExpectCreated(pod, nodeClass, nodePool) |
| 63 | + env.EventuallyExpectHealthy(pod) |
| 64 | + env.ExpectCreatedNodeCount("==", 1) |
| 65 | + }) |
| 66 | +}) |
0 commit comments