amulet icon indicating copy to clipboard operation
amulet copied to clipboard

Update docs to warn about dangers of hardcoding unit numbers in tests

Open tvansteenburgh opened this issue 9 years ago • 1 comments

For example:

# bad
sentry.unit['mysql/0']
# good
sentry.unit['mysql'][0]

The reason for this is that bundletester, by default, resets the env between test file executions. So, unit numbers for the running test may not start at zero if the test is not the first to run in the env. Not that env resets can be disabled via the tests.yaml file.

tvansteenburgh avatar Sep 22 '15 16:09 tvansteenburgh

we should just tell people

sentry['mysql/0'] # bad

sentry['mysql'][0] # better

since sentry is also a list? and we don't confuse a service key with the unit lookup

On Tue, Sep 22, 2015 at 12:22 PM Tim Van Steenburgh < [email protected]> wrote:

For example:

bad

sentry.unit['mysql/0']

good

sentry.unit['mysql'][0]

The reason for this is that bundletester, by default, resets the env between test file executions. So, unit numbers for the running test may not start at zero if the test is not the first to run in the env. Not that env resets can be disabled via the tests.yaml file.

— Reply to this email directly or view it on GitHub https://github.com/juju/amulet/issues/97.

marcoceppi avatar Sep 22 '15 16:09 marcoceppi