mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
cleanup
This commit is contained in:
parent
2ef71eb6e5
commit
23a6c5b3b7
@ -244,12 +244,14 @@ func TestDeleteAddressWithWrongTier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gceProjectId = "test-project"
|
const (
|
||||||
const gceRegion = "test-region"
|
gceProjectId = "test-project"
|
||||||
const zone = "zone1"
|
gceRegion = "test-region"
|
||||||
const nodeName = "test-node-1"
|
zoneName = "zone1"
|
||||||
const clusterName = "Test Cluster Name"
|
nodeName = "test-node-1"
|
||||||
const clusterID = "test-cluster-id"
|
clusterName = "Test Cluster Name"
|
||||||
|
clusterID = "test-cluster-id"
|
||||||
|
)
|
||||||
|
|
||||||
var apiService = &v1.Service{
|
var apiService = &v1.Service{
|
||||||
Spec: v1.ServiceSpec{
|
Spec: v1.ServiceSpec{
|
||||||
@ -279,13 +281,13 @@ func fakeGCECloud() (*GCECloud, error) {
|
|||||||
|
|
||||||
cloud := cloud.NewMockGCE()
|
cloud := cloud.NewMockGCE()
|
||||||
cloud.MockTargetPools.AddInstanceHook = mock.AddInstanceHook
|
cloud.MockTargetPools.AddInstanceHook = mock.AddInstanceHook
|
||||||
zonesWithNodes := createNodeZones([]string{zone})
|
zonesWithNodes := createNodeZones([]string{zoneName})
|
||||||
|
|
||||||
gce := GCECloud{
|
gce := GCECloud{
|
||||||
region: gceRegion,
|
region: gceRegion,
|
||||||
service: service,
|
service: service,
|
||||||
manager: fakeManager,
|
manager: fakeManager,
|
||||||
managedZones: []string{zone},
|
managedZones: []string{zoneName},
|
||||||
projectID: gceProjectId,
|
projectID: gceProjectId,
|
||||||
AlphaFeatureGate: alphaFeatureGate,
|
AlphaFeatureGate: alphaFeatureGate,
|
||||||
nodeZones: zonesWithNodes,
|
nodeZones: zonesWithNodes,
|
||||||
@ -299,7 +301,7 @@ func fakeGCECloud() (*GCECloud, error) {
|
|||||||
func createExternalLoadBalancer(gce *GCECloud) (*v1.LoadBalancerStatus, error) {
|
func createExternalLoadBalancer(gce *GCECloud) (*v1.LoadBalancerStatus, error) {
|
||||||
err := gce.InsertInstance(
|
err := gce.InsertInstance(
|
||||||
gceProjectId,
|
gceProjectId,
|
||||||
zone,
|
zoneName,
|
||||||
&compute.Instance{
|
&compute.Instance{
|
||||||
Name: nodeName,
|
Name: nodeName,
|
||||||
Tags: &compute.Tags{
|
Tags: &compute.Tags{
|
||||||
@ -379,12 +381,14 @@ func TestEnsureExternalLoadBalancer(t *testing.T) {
|
|||||||
func TestUpdateExternalLoadBalancer(t *testing.T) {
|
func TestUpdateExternalLoadBalancer(t *testing.T) {
|
||||||
gce, err := fakeGCECloud()
|
gce, err := fakeGCECloud()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
createExternalLoadBalancer(gce)
|
|
||||||
|
_, err = createExternalLoadBalancer(gce)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
newNodeName := "test-node-2"
|
newNodeName := "test-node-2"
|
||||||
gce.InsertInstance(
|
gce.InsertInstance(
|
||||||
gceProjectId,
|
gceProjectId,
|
||||||
zone,
|
zoneName,
|
||||||
&compute.Instance{
|
&compute.Instance{
|
||||||
Name: newNodeName,
|
Name: newNodeName,
|
||||||
Tags: &compute.Tags{
|
Tags: &compute.Tags{
|
||||||
@ -434,8 +438,8 @@ func TestUpdateExternalLoadBalancer(t *testing.T) {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("/zones/%s/instances/%s", zone, nodeName),
|
fmt.Sprintf("/zones/%s/instances/%s", zoneName, nodeName),
|
||||||
fmt.Sprintf("/zones/%s/instances/%s", zone, newNodeName),
|
fmt.Sprintf("/zones/%s/instances/%s", zoneName, newNodeName),
|
||||||
},
|
},
|
||||||
pool.Instances,
|
pool.Instances,
|
||||||
)
|
)
|
||||||
@ -444,7 +448,9 @@ func TestUpdateExternalLoadBalancer(t *testing.T) {
|
|||||||
func TestEnsureExternalLoadBalancerDeleted(t *testing.T) {
|
func TestEnsureExternalLoadBalancerDeleted(t *testing.T) {
|
||||||
gce, err := fakeGCECloud()
|
gce, err := fakeGCECloud()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
createExternalLoadBalancer(gce)
|
|
||||||
|
_, err = createExternalLoadBalancer(gce)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
err = gce.ensureExternalLoadBalancerDeleted(clusterName, clusterID, apiService)
|
err = gce.ensureExternalLoadBalancerDeleted(clusterName, clusterID, apiService)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user