-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: fix deadlock when dependable node replaced with non-dependable one #2968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func testContext2(t *testing.T, opts *ContextOpts) *Context { | ||
|
@@ -170,6 +171,27 @@ func resourceState(resourceType, resourceID string) *ResourceState { | |
} | ||
} | ||
|
||
// Test helper that gives a function 3 seconds to finish, assumes deadlock and | ||
// fails test if it does not. | ||
func testCheckDeadlock(t *testing.T, f func()) { | ||
timeout := make(chan bool, 1) | ||
done := make(chan bool, 1) | ||
go func() { | ||
time.Sleep(3 * time.Second) | ||
timeout <- true | ||
}() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should just use |
||
go func(f func(), done chan bool) { | ||
defer func() { done <- true }() | ||
f() | ||
}(f, done) | ||
select { | ||
case <-timeout: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, you can just remove all the above timeout stuff and replace this with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I knew I had used something more concise before! Will do in a follow up commit. 👍 |
||
t.Fatalf("timed out! probably deadlock") | ||
case <-done: | ||
// ok | ||
} | ||
} | ||
|
||
const testContextGraph = ` | ||
root: root | ||
aws_instance.bar | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resource "aws_instance" "baz" {} | ||
|
||
output "id" { value = "${aws_instance.baz.id}" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module "grandchild" { | ||
source = "./grandchild" | ||
} | ||
|
||
resource "aws_instance" "bar" { | ||
grandchildid = "${module.grandchild.id}" | ||
} | ||
|
||
output "id" { value = "${aws_instance.bar.id}" } | ||
output "grandchild_id" { value = "${module.grandchild.id}" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
module "child" { | ||
source = "./child" | ||
} | ||
|
||
resource "aws_instance" "bar" { | ||
childid = "${module.child.id}" | ||
grandchildid = "${module.child.grandchild_id}" | ||
} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this debugging.