WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Draft
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
59 changes: 59 additions & 0 deletions test/pkg/environment/azure/expectations_machines.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Portions Copyright (c) Microsoft Corporation.

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 azure

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

containerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v7"
)

// NOTE: Not under current usage, as scaledown should ensure the machines are deleted
// func (env *Environment) ExpectMachinesEventuallyDeleted(machines []*containerservice.Machine) {
// GinkgoHelper()
// var machineNames []*string
// for _, machine := range machines {
// machineNames = append(machineNames, machine.Name)
// }
// aksMachines := containerservice.AgentPoolDeleteMachinesParameter{
// MachineNames: machineNames,
// }
// poller, err := env.agentpoolsClient.BeginDeleteMachines(env.Context, env.ClusterResourceGroup, env.ClusterName, env.MachineAgentPoolName, aksMachines, nil)
// Expect(err).ToNot(HaveOccurred())
// _, err = poller.PollUntilDone(env.Context, nil)
// Expect(err).ToNot(HaveOccurred())
// }

func (env *Environment) ExpectListMachines() []*containerservice.Machine {
GinkgoHelper()
var machines []*containerservice.Machine
pager := env.machinesClient.NewListPager(env.ClusterResourceGroup, env.ClusterName, env.MachineAgentPoolName, nil)
Expect(pager).ToNot(BeNil())
for pager.More() {
page, err := pager.NextPage(env.Context)
Expect(err).ToNot(HaveOccurred())
machines = append(machines, page.Value...)
}

return machines
}

func (env *Environment) ExpectNoMachines() {
GinkgoHelper()
Expect(len(env.ExpectListMachines())).To(Equal(0))
}
60 changes: 60 additions & 0 deletions test/suites/machines/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Portions Copyright (c) Microsoft Corporation.

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 machines_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/Azure/karpenter-provider-azure/pkg/apis/v1beta1"
"github.com/Azure/karpenter-provider-azure/test/pkg/environment/azure"
karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
)

var env *azure.Environment
var nodeClass *v1beta1.AKSNodeClass
var nodePool *karpv1.NodePool

func TestMachines(t *testing.T) {
RegisterFailHandler(Fail)
BeforeSuite(func() {
env = azure.NewEnvironment(t)
// > Note: we want to run this test case in Machine Mode regardless of what the config is,
// > so only check for the condition of InClusterController for machine pool creation, and usage
if env.InClusterController {
env.ExpectRunInClusterControllerWithMachineMode()
}
})
AfterSuite(func() {
env.Stop()
})
RunSpecs(t, "Machines")
}

var _ = BeforeSuite(func() {

})

var _ = BeforeEach(func() {
env.BeforeEach()
nodeClass = env.DefaultAKSNodeClass()
nodePool = env.DefaultNodePool(nodeClass)
})
var _ = AfterEach(func() { env.Cleanup() })
var _ = AfterEach(func() { env.AfterEach() })
Loading