Skip to content

Commit

Permalink
chore: update terraform version used in integration tests that
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-marcela-campo committed Nov 22, 2023
1 parent b07d0a9 commit 185877f
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 48 deletions.
4 changes: 2 additions & 2 deletions integrationtest/fixtures/database-encryption/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
2 changes: 1 addition & 1 deletion integrationtest/fixtures/global-labels/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
version: 1.5.7
- name: terraform-provider-random
version: 2.2.1
service_definitions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
version: 1.5.7
- name: terraform-provider-random
version: 2.2.1
service_definitions:
Expand Down
4 changes: 2 additions & 2 deletions integrationtest/fixtures/purge-service-instance/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
4 changes: 2 additions & 2 deletions integrationtest/fixtures/subsume/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
- name: terraform-provider-random
version: 3.1.0
service_definitions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
version: 1.4.6
- name: terraform
version: 0.13.7
version: 1.5.7
default: true
- name: terraform-provider-random
version: 3.1.0
source: https://github.com/terraform-providers/terraform-provider-random/archive/v3.1.0.zip
terraform_state_provider_replacements:
registry.terraform.io/-/random: "registry.terraform.io/hashicorp/random"
terraform_upgrade_path:
- version: 0.12.21
- version: 0.13.7
- version: 1.4.6
- version: 1.5.7
service_definitions:
- fake-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
version: 1.4.6
- name: terraform-provider-random
version: 2.2.1
service_definitions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ resource "random_password" "password" {

output "provision_output" {
value = random_password.password.result
sensitive = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ plans:
description: First plan
display_name: First
provision:
template_ref: fake-provision.tf
template_refs:
main: fake-provision.tf
outputs:
- field_name: provision_output
type: string
details: provision output
bind:
template_ref: fake-provision.tf
template_refs:
main: fake-provision.tf
outputs:
- field_name: provision_output
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ terraform_binaries:
version: 1.0.10
- name: terraform
version: 1.1.6
- name: terraform
version: 1.5.7
default: true
- name: terraform-provider-random
version: 3.1.0
Expand All @@ -30,5 +32,6 @@ terraform_upgrade_path:
- version: 0.14.9
- version: 1.0.10
- version: 1.1.6
- version: 1.5.7
service_definitions:
- fake-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ plans:
description: First plan
display_name: First
provision:
template_ref: fake-provision.tf
template_refs:
main: fake-provision.tf
outputs:
- field_name: provision_output
type: string
details: provision output
bind:
template_ref: fake-provision.tf
template_refs:
main: fake-provision.tf
outputs:
- field_name: provision_output
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.13.7
version: 1.5.7
default: true
- name: terraform-provider-random
provider: "ContentSquare/random"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform_binaries:
- name: terraform
version: 1.1.6
- name: terraform
version: 1.2.3
version: 1.5.7
default: true
- name: terraform-provider-random
version: 3.1.0
Expand All @@ -32,6 +32,6 @@ terraform_upgrade_path:
- version: 0.14.9
- version: 1.0.10
- version: 1.1.6
- version: 1.2.3
- version: 1.5.7
service_definitions:
- fake-service.yml
16 changes: 16 additions & 0 deletions integrationtest/fixtures/tf_attribute_skip/fake-provision.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## new versions of terraform fail with a different error to the one we want to trigger if this file is empty.
## adding some dummy terraform to test errors when a particular field is not present.

terraform {
required_providers {
random = {
source = "hashicorp/random"
version = "3.1.0"
}
}
}

resource "random_integer" "priority" {
min = 3
max = 4
}
6 changes: 4 additions & 2 deletions integrationtest/fixtures/tf_attribute_skip/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.4.6.zip
- name: terraform-provider-random
version: 3.1.0
service_definitions:
- fake-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
4 changes: 2 additions & 2 deletions integrationtest/fixtures/update-brokerpak-hcl/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platforms:
arch: amd64
terraform_binaries:
- name: terraform
version: 0.12.21
source: https://github.com/hashicorp/terraform/archive/v0.12.21.zip
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
service_definitions:
- fake-service.yml
19 changes: 10 additions & 9 deletions integrationtest/terraform_block_action_before_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
var _ = Describe("Terraform block action before upgrade", func() {
const serviceOfferingGUID = "df2c1512-3013-11ec-8704-2fbfa9c8a802"
const servicePlanGUID = "e59773ce-3013-11ec-9bbb-9376b4f72d14"
const oldTerraformVersion = "1.4.6"

var (
brokerpak string
Expand Down Expand Up @@ -48,9 +49,9 @@ var _ = Describe("Terraform block action before upgrade", func() {
Describe("Bind", func() {
When("Default Terraform version greater than instance", func() {
It("returns an error", func() {
By("provisioning a service instance at 0.12")
By("provisioning a service instance at an older version of terraform")
serviceInstance := must(broker.Provision(serviceOfferingGUID, servicePlanGUID))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))

By("updating the brokerpak and restarting the broker")
Expect(broker.Stop()).To(Succeed())
Expand All @@ -62,17 +63,17 @@ var _ = Describe("Terraform block action before upgrade", func() {
_, err := broker.CreateBinding(serviceInstance)
Expect(err).To(MatchError(ContainSubstring("operation attempted with newer version of Terraform than current state, upgrade the service before retrying operation")))
Expect(broker.LastOperationFinalState(serviceInstance.GUID)).To(Equal(domain.Succeeded))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))
})
})
})

Describe("Unbind", func() {
When("Default Terraform version greater than instance", func() {
It("returns an error", func() {
By("provisioning a service instance at 0.12")
By("provisioning a service instance at an old terraform version")
serviceInstance := must(broker.Provision(serviceOfferingGUID, servicePlanGUID))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))

By("creating a binding")
binding := must(broker.CreateBinding(serviceInstance))
Expand All @@ -87,17 +88,17 @@ var _ = Describe("Terraform block action before upgrade", func() {
err := broker.DeleteBinding(serviceInstance, binding.GUID)
Expect(err).To(MatchError(ContainSubstring("operation attempted with newer version of Terraform than current state, upgrade the service before retrying operation")))
Expect(broker.LastOperationFinalState(serviceInstance.GUID)).To(Equal(domain.Succeeded))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))
})
})
})

Describe("Delete", func() {
When("Default Terraform version greater than instance", func() {
It("returns an error", func() {
By("provisioning a service instance at 0.12")
By("provisioning a service instance at an old terraform version")
serviceInstance := must(broker.Provision(serviceOfferingGUID, servicePlanGUID))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))

By("updating the brokerpak and restarting the broker")
Expect(broker.Stop()).To(Succeed())
Expand All @@ -109,7 +110,7 @@ var _ = Describe("Terraform block action before upgrade", func() {
err := broker.Deprovision(serviceInstance)
Expect(err).To(MatchError(ContainSubstring("operation attempted with newer version of Terraform than current state, upgrade the service before retrying operation")))
Expect(broker.LastOperationFinalState(serviceInstance.GUID)).To(Equal(domain.Succeeded))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal("0.12.21"))
Expect(terraformStateVersion(serviceInstance.GUID)).To(Equal(oldTerraformVersion))
})
})
})
Expand Down
9 changes: 5 additions & 4 deletions integrationtest/terraform_module_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _ = Describe("Terraform Module Upgrade", func() {
const (
serviceOfferingGUID = "df2c1512-3013-11ec-8704-2fbfa9c8a802"
servicePlanGUID = "e59773ce-3013-11ec-9bbb-9376b4f72d14"
newTerraformVersion = "1.5.7"
)

var (
Expand Down Expand Up @@ -65,12 +66,12 @@ var _ = Describe("Terraform Module Upgrade", func() {
Expect(bindingTerraformStateVersion(serviceInstance.GUID, secondBinding.GUID)).To(Equal("0.12.21"))

By("running 'cf update-service'")
Expect(broker.UpgradeService(serviceInstance, "1.1.6", testdrive.WithUpgradePreviousValues(domain.PreviousValues{PlanID: servicePlanGUID}))).To(Succeed())
Expect(broker.UpgradeService(serviceInstance, newTerraformVersion, testdrive.WithUpgradePreviousValues(domain.PreviousValues{PlanID: servicePlanGUID}))).To(Succeed())

By("observing that the instance TF state file has been updated to the latest version")
Expect(instanceTerraformStateVersion(serviceInstance.GUID)).To(Equal("1.1.6"))
Expect(bindingTerraformStateVersion(serviceInstance.GUID, firstBinding.GUID)).To(Equal("1.1.6"))
Expect(bindingTerraformStateVersion(serviceInstance.GUID, secondBinding.GUID)).To(Equal("1.1.6"))
Expect(instanceTerraformStateVersion(serviceInstance.GUID)).To(Equal(newTerraformVersion))
Expect(bindingTerraformStateVersion(serviceInstance.GUID, firstBinding.GUID)).To(Equal(newTerraformVersion))
Expect(bindingTerraformStateVersion(serviceInstance.GUID, secondBinding.GUID)).To(Equal(newTerraformVersion))
})
})
})
9 changes: 5 additions & 4 deletions integrationtest/terraform_rename_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

var _ = Describe("Terraform Rename Provider", func() {
var (
brokerpak string
broker *testdrive.Broker
brokerpak string
broker *testdrive.Broker
terraformVersion = "1.5.7"
)

BeforeEach(func() {
Expand Down Expand Up @@ -40,10 +41,10 @@ var _ = Describe("Terraform Rename Provider", func() {

By("running 'cf update-service'")
Expect(broker.UpgradeService(
serviceInstance, "0.13.7",
serviceInstance, terraformVersion,
testdrive.WithUpgradePreviousValues(domain.PreviousValues{
PlanID: servicePlanGUID,
MaintenanceInfo: &domain.MaintenanceInfo{Version: "0.13.7"},
MaintenanceInfo: &domain.MaintenanceInfo{Version: terraformVersion},
}),
testdrive.WithUpgradeParams(`{"alpha_input":"quz"}`),
)).To(Succeed())
Expand Down
2 changes: 1 addition & 1 deletion integrationtest/terraform_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _ = Describe("Terraform Upgrade", func() {
serviceOfferingGUID = "df2c1512-3013-11ec-8704-2fbfa9c8a802"
servicePlanGUID = "e59773ce-3013-11ec-9bbb-9376b4f72d14"
startingVersion = "0.12.21"
endingVersion = "1.2.3"
endingVersion = "1.5.7"
)

var (
Expand Down

0 comments on commit 185877f

Please sign in to comment.