Debugging acceptance tests with SDK v2

In previous SDK version, it was possible to step-by-step debug resources, as well as seeing logs of them. Right now it’s not possible (or at least i was not able to find a way after 1 hour reading the sources) how to debug a in VSCode. What bothers me more is that debug logs disappeared from test debug output’s stderr. Is there a way of bringing those back?

Delve and other debuggers should Just Work for providers built on v2.0.0 or later of the SDK. If they don’t, I’d love to hear more about it as an issue. But they’re fundamentally just like any other Go program (though with a lot of sleight of hand going on behind the scenes to make that happen) and so should be debuggable as such.

As for log output, I’m interested that you were seeing it before–I have trouble explaining that, to be honest. I know why it’s not there now–we worked really hard to try and keep log output from drowning out the test results, and only partially succeeded, so I’m not surprised it’s missing, I’m more interested in how it was showing up before and under what circumstances, because we may be able to make that happen, as long as it doesn’t mean the test results get drowned out, too.

In the meantime, I know it’s probably not as good, but setting TF_ACC_LOG_PATH to the path of a file should write log output to that file.

What i meant with debugging acceptance tests:

  1. Open VSCode (the only free IDE available with Go support) with TF_ACC env variable set
  2. Set breakpoints in resource’s Create|Read|Update|Delete[Context] functions
  3. Debug test that is calling

Expected behavior is to have debugger stopped at those breakpoints, but right now tests are launched in subprocess and this is kind of not possible anymore :confused:

This works for me locally in VS Code (and was one of the design goals in the v2 Binary Testing Framework). The main issue I think though is that we need to better document this (including providing a sample launch.json, etc). It does run the Terraform CLI in a subprocess, but its “reattaching” the running provider process that is being debugged, so breakpoints, coverage, etc, should all work within acceptance testing.

Here are docs from the upgrade guide at least, but I think this is mostly about external debugging (ie an external terraform apply):

Yeah, I’d be interested in hearing more about your setup, because that sounds exactly like the setup we tested with prior to release: