Skip to content
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

Test case inserts failing checks into my production consul #20

Closed
nh2 opened this issue Aug 13, 2018 · 3 comments
Closed

Test case inserts failing checks into my production consul #20

nh2 opened this issue Aug 13, 2018 · 3 comments

Comments

@nh2
Copy link
Collaborator

nh2 commented Aug 13, 2018

This test code

testRunServiceTtl :: TestTree
testRunServiceTtl = testCase "testRunServiceTtl" $ do
client@ConsulClient{..} <- newClient
let register = RegisterService Nothing "testRunServiceTtl" [] (Just 8000) $ Just $ Ttl "10s"
runService client register (action client) Nothing
where
action client = do
threadDelay 15000000
mHealth <- getServiceHealth client "testRunServiceTtl"
case mHealth of
Nothing -> assertFailure "testRunServiceTtl: No healthcheck was found"
Just [x] -> do
let checks = hChecks x
mapM_ (testCheck) checks
testCheck check = do
assertBool "testRunServiceTtl: Check not passing" $ cStatus check == Passing

connects to consul on port 8500 and inserts a TTL check.

When you build the package with tests enabled (which is what many build tools, in my case nix, do by default), this will mess with the consul on your machine.

It doesn't even delete the TTL check, so after the test executable runs, the TTL check will swiftly fail, possibly even paging you.

@nh2
Copy link
Collaborator Author

nh2 commented Aug 13, 2018

I think if anything, the tests should pull up a throwaway consul and use that.

nh2 added a commit to nh2/consul-haskell that referenced this issue Jul 13, 2019
Instead, bring up an own instance of consul, and run against that.

Fixes test suite deleting production data when built and tested
on a production machine.
@nh2
Copy link
Collaborator Author

nh2 commented Jul 13, 2019

I've made a commit that fixes this: nh2@63d9f0a

But first: #23

nh2 added a commit to nh2/consul-haskell that referenced this issue Jul 14, 2019
Instead, bring up an own instance of consul, and run against that.

Fixes test suite deleting production data when built and tested
on a production machine.
@nh2
Copy link
Collaborator Author

nh2 commented Jan 18, 2020

Subsumed by #25, where I've cherry-picked the relevant commit and made it compile with other recent PRs.

@nh2 nh2 closed this as completed Jan 18, 2020
nh2 added a commit that referenced this issue Jan 18, 2020
Instead, bring up an own instance of consul, and run against that.

Fixes test suite deleting production data when built and tested
on a production machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant