Skip to content

Commit

Permalink
Fix v1 secret naming (#1380)
Browse files Browse the repository at this point in the history
* Fix v1 secret naming

  - Fix issue where namespace was mistakenly included in v1 secret
    naming key generation. Some resources are not expected to have
    namespace prefix in certain KeyVault scenarios.

* Increase build timeout a bit

* Don't create many different randoms in test

* SecretClient should not be modified

* Change region VM tests are run in

  - Due to capacity constraints. We can move back later.
  • Loading branch information
matthchr authored Feb 17, 2021
1 parent 736367a commit 78e493c
Show file tree
Hide file tree
Showing 24 changed files with 329 additions and 140 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test-integration-controllers: generate fmt vet manifests
.PHONY: test-v1-secret-naming
test-v1-secret-naming: generate fmt vet manifests
TEST_RESOURCE_PREFIX=$(TEST_RESOURCE_PREFIX) TEST_USE_EXISTING_CLUSTER=false REQUEUE_AFTER=20 AZURE_SECRET_NAMING_VERSION=1 \
go test -v -run "^.*_SecretNamedCorrectly$$" -tags "$(BUILD_TAGS)" -coverprofile=reports/v1-secret-naming-coverage-output.txt -coverpkg=./... -covermode count -parallel 4 -timeout 10m \
go test -v -run "^.*_SecretNamedCorrectly$$" -tags "$(BUILD_TAGS)" -coverprofile=reports/v1-secret-naming-coverage-output.txt -coverpkg=./... -covermode count -parallel 4 -timeout 15m \
./controllers/...

# Run Resource Manager tests against the configured cluster
Expand Down
3 changes: 2 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ resources:
- repo: self

pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-latest'
timeoutInMinutes: 80

variables:
tag: '$(Build.BuildId)'
Expand Down
14 changes: 9 additions & 5 deletions controllers/azurevirtualmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestVirtualMachineControllerNoResourceGroup(t *testing.T) {
sshPublicKeyData := GenerateTestResourceNameWithRandom("ssh", 10)
nicName := GenerateTestResourceNameWithRandom("nic", 10)
platformImageUrn := "Canonical:UbuntuServer:16.04-LTS:latest"
location := tc.resourceGroupLocation

// Create a VM
vmInstance := &azurev1alpha1.AzureVirtualMachine{
Expand All @@ -35,7 +36,7 @@ func TestVirtualMachineControllerNoResourceGroup(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureVirtualMachineSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: rgName,
VMSize: vmSize,
OSType: osType,
Expand All @@ -56,6 +57,9 @@ func TestVirtualMachineHappyPathWithNicPipVNetAndSubnet(t *testing.T) {
defer PanicRecover(t)
ctx := context.Background()

// location := tc.resourceGroupLocation
location := "australiaeast"

// Create a vnet with a subnet
vnetName := GenerateTestResourceNameWithRandom("vnt", 10)
subnetName := GenerateTestResourceNameWithRandom("snt", 10)
Expand All @@ -70,7 +74,7 @@ func TestVirtualMachineHappyPathWithNicPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.VirtualNetworkSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
AddressSpace: "110.0.0.0/8",
Subnets: []azurev1alpha1.VNetSubnets{vnetSubNetInstance},
Expand All @@ -90,7 +94,7 @@ func TestVirtualMachineHappyPathWithNicPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzurePublicIPAddressSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
PublicIPAllocationMethod: publicIPAllocationMethod,
IdleTimeoutInMinutes: idleTimeoutInMinutes,
Expand All @@ -109,7 +113,7 @@ func TestVirtualMachineHappyPathWithNicPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureNetworkInterfaceSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VNetName: vnetName,
SubnetName: subnetName,
Expand All @@ -134,7 +138,7 @@ func TestVirtualMachineHappyPathWithNicPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureVirtualMachineSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VMSize: vmSize,
OSType: osType,
Expand Down
13 changes: 8 additions & 5 deletions controllers/azurevirtualmachineextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
defer PanicRecover(t)
ctx := context.Background()

// location := tc.resourceGroupLocation
location := "australiaeast"

// Create a vnet with a subnet
vnetName := GenerateTestResourceNameWithRandom("vnt", 10)
subnetName := GenerateTestResourceNameWithRandom("snt", 10)
Expand All @@ -66,7 +69,7 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.VirtualNetworkSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
AddressSpace: "110.0.0.0/8",
Subnets: []azurev1alpha1.VNetSubnets{vnetSubNetInstance},
Expand All @@ -86,7 +89,7 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzurePublicIPAddressSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
PublicIPAllocationMethod: publicIPAllocationMethod,
IdleTimeoutInMinutes: idleTimeoutInMinutes,
Expand All @@ -105,7 +108,7 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureNetworkInterfaceSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VNetName: vnetName,
SubnetName: subnetName,
Expand All @@ -130,7 +133,7 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureVirtualMachineSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VMSize: vmSize,
OSType: osType,
Expand All @@ -151,7 +154,7 @@ func TestVirtualMachineExtensionHappyPath(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureVirtualMachineExtensionSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VMName: vmName,
AutoUpgradeMinorVersion: true,
Expand Down
11 changes: 7 additions & 4 deletions controllers/azurevmscaleset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func TestVMScaleSetHappyPathWithLbPipVNetAndSubnet(t *testing.T) {
defer PanicRecover(t)
ctx := context.Background()

// location := tc.resourceGroupLocation
location := "australiaeast"

// Create a vnet with a subnet
vnetName := GenerateTestResourceNameWithRandom("vnt", 10)
subnetName := GenerateTestResourceNameWithRandom("snt", 10)
Expand All @@ -80,7 +83,7 @@ func TestVMScaleSetHappyPathWithLbPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.VirtualNetworkSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
AddressSpace: "110.0.0.0/8",
Subnets: []azurev1alpha1.VNetSubnets{vnetSubNetInstance},
Expand All @@ -100,7 +103,7 @@ func TestVMScaleSetHappyPathWithLbPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzurePublicIPAddressSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
PublicIPAllocationMethod: publicIPAllocationMethod,
IdleTimeoutInMinutes: idleTimeoutInMinutes,
Expand All @@ -124,7 +127,7 @@ func TestVMScaleSetHappyPathWithLbPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureLoadBalancerSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
PublicIPAddressName: pipName,
BackendAddressPoolName: bpName,
Expand Down Expand Up @@ -152,7 +155,7 @@ func TestVMScaleSetHappyPathWithLbPipVNetAndSubnet(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureVMScaleSetSpec{
Location: tc.resourceGroupLocation,
Location: location,
ResourceGroup: tc.resourceGroupName,
VMSize: vmSize,
Capacity: capacity,
Expand Down
Loading

0 comments on commit 78e493c

Please sign in to comment.