Commit Graph

29 Commits

Author SHA1 Message Date
Tim Gross
ab6f13db1d Fix flaky operator debug test (#12501)
We introduced a `pprof-interval` argument to `operator debug` in #11938, and unfortunately this has resulted in a lot of test flakes. The actual command in use is mostly fine (although I've fixed some quirks here), so what's really happened is that the change has revealed some existing issues in the tests. Summary of changes:

* Make first pprof collection synchronous to preserve the existing
  behavior for the common case where the pprof interval matches the
  duration.

* Clamp `operator debug` pprof timing to that of the command. The
  `pprof-duration` should be no more than `duration` and the
  `pprof-interval` should be no more than `pprof-duration`. Clamp the
  values rather than throwing errors, which could change the commands
  that existing users might already have in debugging scripts

* Testing: remove test parallelism

  The `operator debug` tests that stand up servers can't be run in
  parallel, because we don't have a way of canceling the API calls for
  pprof. The agent will still be running the last pprof when we exit,
  and that breaks the next test that talks to that same agent.
  (Because you can only run one pprof at a time on any process!)

  We could split off each subtest into its own server, but this test
  suite is already very slow. In future work we should fix this "for
  real" by making the API call cancelable.


* Testing: assert against unexpected errors in `operator debug` tests.

  If we assert there are no unexpected error outputs, it's easier for
  the developer to debug when something is going wrong with the tests
  because the error output will be presented as a failing test, rather
  than just a failing exit code check. Or worse, no failing exit code
  check!

  This also forces us to be explicit about which tests will return 0
  exit codes but still emit (presumably ignorable) error outputs.

Additional minor bug fixes (mostly in tests) and test refactorings:

* Fix text alignment on pprof Duration in `operator debug` output

* Remove "done" channel from `operator debug` event stream test. The
  goroutine we're blocking for here already tells us it's done by
  sending a value, so block on that instead of an extraneous channel

* Event stream test timer should start at current time, not zero

* Remove noise from `operator debug` test log output. The `t.Logf`
  calls already are picked out from the rest of the test output by
  being prefixed with the filename.

* Remove explicit pprof args so we use the defaults clamped from
  duration/interval
2022-04-07 15:00:07 -04:00
Mahmood Ali
ff1b2f7623 tests: ensure that tests restore env-var values (#11309)
Fix a test corruption issue, where a test accidentally unsets
the `NOMAD_LICENSE` environment variable, that's relied on by some
tests.

As a habit, tests should always restore the environment variable value
on test completion. Golang 1.17 introduced
[`t.Setenv`](https://pkg.go.dev/testing#T.Setenv) to address this issue.
However, as 1.0.x and 1.1.x branches target golang 1.15 and 1.16, I
opted to use a helper function to ease backports.
2021-10-13 17:26:56 -04:00
Dave May
1bd132f09d debug: Improve namespace and region support (#11269)
* Include region and namespace in CLI output
* Add region and prefix matching for server members
* Add namespace and region API outputs to cluster metadata folder
* Add region awareness to WaitForClient helper function
* Add helper functions for SliceStringHasPrefix and StringHasPrefixInSlice
* Refactor test client agent generation
* Add tests for region
* Add changelog
2021-10-12 16:58:41 -04:00
Mahmood Ali
9741c2a88c always shutdown test server on test cleanup 2020-06-25 12:44:19 -04:00
Tim Gross
02209b1371 Multiregion job registration
Integration points for multiregion jobs to be registered in the enterprise
version of Nomad:
* hook in `Job.Register` for enterprise to send job to peer regions
* remove monitoring from `nomad job run` and `nomad job stop` for multiregion jobs
2020-06-17 11:04:58 -04:00
Drew Bailey
ce8f230cab Multiregion deploy status and job status CLI 2020-06-17 11:03:34 -04:00
Jasmine Dahilig
c467a94e2b backfill region from job hcl in jobUpdate and jobPlan endpoints
- updated region in job metadata that gets persisted to nomad datastore
- fixed many unrelated unit tests that used an invalid region value
(they previously passed because hcl wasn't getting picked up and
the job would default to global region)
2019-06-13 08:03:16 -07:00
Alex Dadgar
e1b1465081 Standardize retrieving a free port into a helper package 2017-10-23 16:48:20 -07:00
Alex Dadgar
da25a3d5ce Switch to in-process agent 2017-07-20 21:07:32 -07:00
Diptanu Choudhury
5502a669e8 Added tests 2017-02-16 13:52:39 -08:00
Diptanu Choudhury
396e45629b Renaming LocalDisk to EphemeralDisk (#1710)
Renaming LocalDisk to EphemeralDisk
2016-09-14 15:43:42 -07:00
Diptanu Choudhury
efb0d3de8a Fixed some more tests 2016-08-25 23:05:21 -05:00
Diptanu Choudhury
5036f24591 Attempting to fix alloc status test 2016-08-22 15:07:49 -05:00
Cameron Davison
40bc21fa8f add time flag to add created column to allocation 2016-08-07 19:44:56 -05:00
Alex Dadgar
6c32b1ebd8 Validate driver config on job register 2016-04-13 15:55:46 -07:00
Alex Dadgar
73733a8542 Fixes 2016-02-19 15:49:32 -08:00
Diptanu Choudhury
05999809aa Fixed some more tests 2016-02-11 22:33:41 -08:00
Diptanu Choudhury
38ec33c508 Fixed some tests 2016-02-11 10:42:56 -08:00
Alex Dadgar
7ea6619928 Tests 2016-02-02 13:50:30 -08:00
Ryan Uber
da35ecc4f3 command: fix tests after job validation 2015-09-16 11:42:28 -07:00
Ryan Uber
550434dc9b command: dump allocations for nodes in node-status 2015-09-15 11:20:08 -07:00
Ryan Uber
f19682d87e command: tests 2015-09-14 14:08:50 -07:00
Ryan Uber
ac6de2c157 command: guard tests from multiple parallel calls 2015-09-14 14:06:37 -07:00
Ryan Uber
7e26f938a2 command: use meta struct for common options 2015-09-14 13:24:03 -07:00
Ryan Uber
0e16348052 command: cleanup 2015-09-14 13:24:03 -07:00
Ryan Uber
4b708bf6df command: use testutil.TestServer in command tests 2015-09-14 13:24:03 -07:00
Ryan Uber
8246db154d command: cli tests 2015-09-14 13:24:03 -07:00
Ryan Uber
8698c1d757 command: fix test agent helper 2015-09-14 13:24:03 -07:00
Ryan Uber
0f597d3984 command: tests 2015-09-14 13:24:02 -07:00