akshaykarle / terraform-provider-mongodbatlas

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

Cluster data source #61

Open snowiow opened 5 years ago

snowiow commented 5 years ago

Hi, first of all thanks for creating this provider. It is a huge help for our automated infrastructure provisioning.

Nevertheless we needed the cluster as a data source as well. Otherwise we have to apply the cluster creation together with the creation of other resources, because we needed the mongodb_uri_with_options as an env paremeter for a ec2 user_data script. This would have the drawback, that every time we want to destroy the ec2 instance, the mongodb cluster was destroyed as well, which results in long test iteration cycles.

Here I created the data source and the documentation for it. But I couldn't write the test, because I always get an error while executing make test:

=== RUN   TestAccMongodbatlasCluster_basic
SIGQUIT: quit
PC=0x489c31 m=0 sigcode=0

goroutine 0 [idle]:
runtime.futex(0x1b054c0, 0x80, 0x0, 0x0, 0x0, 0xc00064d800, 0x0, 0x0, 0x7ffd1e94c020, 0x434052, ...)
        /usr/lib/go/src/runtime/sys_linux_amd64.s:531 +0x21
runtime.futexsleep(0x1b054c0, 0xc000000000, 0xffffffffffffffff)
        /usr/lib/go/src/runtime/os_linux.go:46 +0x4b
runtime.notesleep(0x1b054c0)
        /usr/lib/go/src/runtime/lock_futex.go:151 +0xa2
runtime.stopm()
        /usr/lib/go/src/runtime/proc.go:2016 +0xe3
runtime.findrunnable(0xc000053400, 0x0)
        /usr/lib/go/src/runtime/proc.go:2487 +0x4dc
runtime.schedule()
        /usr/lib/go/src/runtime/proc.go:2613 +0x13a
runtime.park_m(0xc0003aec00)
        /usr/lib/go/src/runtime/proc.go:2676 +0xae
runtime.mcall(0x0)
        /usr/lib/go/src/runtime/asm_amd64.s:299 +0x5b

goroutine 1 [chan receive, 9 minutes]:
testing.(*T).Run(0xc0002f2000, 0x118cd49, 0x20, 0x11ac470, 0xc00023db01)
        /usr/lib/go/src/testing/testing.go:879 +0x689
testing.runTests.func1(0xc0002f2000)
        /usr/lib/go/src/testing/testing.go:1119 +0xa9
testing.tRunner(0xc0002f2000, 0xc00023dd20)
        /usr/lib/go/src/testing/testing.go:827 +0x163
testing.runTests(0xc0002dc700, 0x1afcfe0, 0xa, 0xa, 0x300)
        /usr/lib/go/src/testing/testing.go:1117 +0x4ef
testing.(*M).Run(0xc000184400, 0x0)
        /usr/lib/go/src/testing/testing.go:1034 +0x2ef
main.main()
        _testmain.go:130 +0x333

....

Maybe you can help me with that problem? :slightly_smiling_face:

codecov-io commented 5 years ago

Codecov Report

Merging #61 into master will increase coverage by 3.82%. The diff coverage is 75.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
+ Coverage    41.4%   45.22%   +3.82%     
==========================================
  Files          11       12       +1     
  Lines        1181     1331     +150     
==========================================
+ Hits          489      602     +113     
- Misses        691      728      +37     
  Partials        1        1
Impacted Files Coverage Δ
mongodbatlas/provider.go 83.78% <100%> (+0.45%) :arrow_up:
mongodbatlas/data_source_mongodbatlas_cluster.go 75.16% <75.16%> (ø)

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 814d329...24b9944. Read the comment docs.

akshaykarle commented 5 years ago

Hey @snowiow thanks for making the PR. Not sure about that error you are seeing. Can you try updating your dependencies and make sure you are on the correct go version 1.10 and re-run them?

snowiow commented 5 years ago

I tried to run the tests agian, but currently I get a timeout because the cluster creation takes a pretty long time and the test only waits for 10 minutes

akshaykarle commented 5 years ago

Hey @snowiow if you are running make test it should not attempt to create the cluster as that is done only in the acceptance tests which you won't be able to run locally without the mongodb credentials. Can you check to make sure you are not running acceptance tests?

BrendanThompson commented 5 years ago

@akshaykarle / @snowiow any timeframes around getting this merged?

snowiow commented 5 years ago

@akshaykarle those are running without problems. But the problem I have is, if I go to make tests for the cluster data source, it would be an Acceptance Test as well and therefore I couldn't run the tests myself.

@BrendanThompson From my point of view it can be merged, because the data source itself is working correctly. We used my fork of this provider for two of our environments already, without problems. The only thing I would like to have aswell is an acceptance test for the feature for completeness sake, but I can't verify the tests at the moment, because the acceptance tests aren't running through for me.