akshaykarle / terraform-provider-mongodbatlas

Terraform provider for MongoDB Atlas
Mozilla Public License 2.0
122 stars 54 forks source link

Dont set IOPS on disk update #81

Closed gordonbondon closed 5 years ago

gordonbondon commented 5 years ago

When you downgrade disk size you can get this error if IOPS is set in cluster provider settings for a patch:

* mongodbatlas_cluster.cluster: Error reading MongoDB Cluster cluster-name: MongoDB Atlas: 400 The cluster's disk IOPS of 300 is invalid. For a disk of size 60 on instance size M10 with a volume type of STANDARD, the IOPS must be 180.0.
codecov-io commented 5 years ago

Codecov Report

Merging #81 into master will decrease coverage by 0.03%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   41.04%   41.01%   -0.04%     
==========================================
  Files          11       11              
  Lines        1206     1207       +1     
==========================================
  Hits          495      495              
- Misses        710      711       +1     
  Partials        1        1
Impacted Files Coverage Δ
mongodbatlas/resource_mongodbatlas_cluster.go 43.38% <0%> (-0.14%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 54dd3b6...c1e9723. Read the comment docs.

gordonbondon commented 5 years ago

I've added test to cover this scenario. Before change:

make testacc TEST=./mongodbatlas TESTARGS='-run=TestAccMongodbatlasCluster_basic'
Password:
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TEST="./mongodbatlas" TESTARGS="-run=TestAccMongodbatlasCluster_basic -timeout 120m" sh -c "'/Users/ayarmoliuk/go/src/github.com/akshaykarle/terraform-provider-mongodbatlas/scripts/gotest.sh'"
=== RUN   TestAccMongodbatlasCluster_basic
--- FAIL: TestAccMongodbatlasCluster_basic (2454.75s)
    testing.go:538: Step 2 error: Error applying: 1 error(s) occurred:

        * mongodbatlas_cluster.test: 1 error(s) occurred:

        * mongodbatlas_cluster.test: Error reading MongoDB Cluster test-nj4v9dw8ew: MongoDB Atlas: 400 The cluster's disk IOPS of 100 is invalid. For a disk of size 35 on instance size M20 with a volume type of STANDARD, the IOPS must be 105.0.
FAIL
FAIL    github.com/akshaykarle/terraform-provider-mongodbatlas/mongodbatlas 2454.770s
make: *** [testacc] Error 1

After change:

make testacc TEST=./mongodbatlas TESTARGS='-run=TestAccMongodbatlasCluster_basic'
Password:
Enter your MFA code: 709389
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TEST="./mongodbatlas" TESTARGS="-run=TestAccMongodbatlasCluster_basic -timeout 120m" sh -c "'/Users/ayarmoliuk/go/src/github.com/akshaykarle/terraform-provider-mongodbatlas/scripts/gotest.sh'"
=== RUN   TestAccMongodbatlasCluster_basic
--- PASS: TestAccMongodbatlasCluster_basic (3749.30s)
PASS
ok      github.com/akshaykarle/terraform-provider-mongodbatlas/mongodbatlas 3749.330s