Skip to content

Concurrency issue when using a context #472

Closed
@wedothings

Description

👓 What did you see?

When running scenarios concurrently, all scenarios seem to be sharing the same testContext.

The testContext is an object used to pass values between steps, the steps add values to the testContext and extract too.

However, all scenarios where attempting to update the map in the testContext at once, which caused the below error

fatal error: concurrent map iteration and map write

✅ What did you expect to see?

I expected to see multiple scenarios to run concurrently, with each scenario to have its own testContext instance and to only be able to update the testContext relevant for that scenario.
And that one scenario wouldn't interfere with another scenarios testContext.

📦 Which tool/library version are you using?

github.com/cucumber/godog v0.12.5
go 1.16

🔬 How could we reproduce it?

opts = godog.Options{
		Output:      colors.Colored(os.Stdout),
		Format:      "pretty",
		Concurrency: 13,
		Randomize:   time.Now().UTC().UnixNano(),
}

A step like.. s.Step(^a customer$, testContext.aCustomer)

The testContext has a map in it, which is added to and extracted from by steps throughout the scenario

type TestContext struct {
	customer       map[string]string

📚 Any additional context?

Each scenario populates the testContext with different values, specific for the scenario.

So if when you enable concurrency, the scenarios all begin to use the same testContext passed between the steps. Then I guess this means that concurrency is not compatible with a scenario unique testContext object being passed between steps. Is that right?


This text was originally generated from a template, then edited by hand. You can modify the template here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions