Skip to content

Improve test suite to handle external servers better.#9033

Merged
yossigo merged 53 commits into
redis:unstablefrom
yossigo:external-tests
Jun 9, 2021
Merged

Improve test suite to handle external servers better.#9033
yossigo merged 53 commits into
redis:unstablefrom
yossigo:external-tests

Conversation

@yossigo

@yossigo yossigo commented Jun 2, 2021

Copy link
Copy Markdown
Collaborator

This commit revives the improves the ability to run the test suite against
external servers, instead of launching and managing redis-server processes as
part of the test fixture.

This capability existed in the past, using the --host and --port options.
However, it was quite limited and mostly useful when running a specific tests.
Attempting to run larger chunks of the test suite experienced many issues:

  • Many tests depend on being able to start and control redis-server themselves,
    and there's no clear distinction between external server compatible and other
    tests.
  • Cluster mode is not supported (resulting with CROSSSLOT errors).

This PR cleans up many things and makes it possible to run the entire test suite
against an external server. It also provides more fine grained controls to
handle cases where the external server supports a subset of the Redis commands,
limited number of databases, cluster mode, etc.

The tests directory now contains a README.md file that describes how this
works.

This commit also includes additional cleanups and fixes:

  • Tests can now be tagged.
  • Tag-based selection is now unified across start_server, tags and test.
  • More information is provided about skipped or ignored tests.
  • Repeated patterns in tests have been extracted to common procedures, both at a
    global level and on a per-test file basis.
  • Cleaned up some cases where test setup was based on a previous test executing
    (a major anti-pattern that repeats itself in many places).
  • Cleaned up some cases where test teardown was not part of a test (in the
    future we should have dedicated teardown code that executes even when tests
    fail).
  • Fixed some tests that were flaky running on external servers.

Comment thread tests/support/util.tcl Outdated

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to add a CI job that spins up a server (possibly one in cluster mode) and runs the test suite against it.
this way is a test is added that's incompatible with the external mode, we'll detect it before merging.
if we do that, we'll also feel safer to make the skip-external an opt-out feature rather than the opt-in one (external-ok)

Comment thread tests/support/server.tcl Outdated
Comment thread tests/unit/other.tcl
Comment thread tests/unit/keyspace.tcl Outdated
Comment thread tests/support/util.tcl Outdated
Comment thread tests/unit/type/hash.tcl
Comment thread tests/unit/type/stream.tcl Outdated
Comment thread tests/unit/keyspace.tcl
Comment thread tests/unit/expire.tcl Outdated
Comment on lines +166 to +167
# two seconds.
after 2000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. i think we should use a wait-for-condition here with a timeout rather than an sleep. (that's actually true for all sleeps).
  2. any test that's time-dependent (has a long sleep, or a wait_for that waits for something in redis that takes a long time), should have a slow tag, so that we can run the test suite skipping inherently slow tests
  3. i'd like the slow skip tag to somehow be used by default? (i want it to be an opt-in, like --accurate rather than opt-out), or at the very least, i want to skip these in the CI.yml runs, since we keep adding more and more of these.

@sundb FYI (in the context of #9003)

Comment thread tests/unit/slowlog.tcl
Comment thread tests/unit/expire.tcl Outdated
@sundb

sundb commented Jun 2, 2021

Copy link
Copy Markdown
Collaborator

@yossigo I'm not sure if I'm reading this wrong, I seem to remember reading somewhere that we can ignore certain tags when running runtest, but I can't find it now.

@oranagra

oranagra commented Jun 3, 2021

Copy link
Copy Markdown
Member

@sundb there's the --tags argument (had it since forever), have a look at the new README Yossi added with an example.

@sundb

sundb commented Jun 3, 2021

Copy link
Copy Markdown
Collaborator

@oranagra I see that.
i.e. we can use --tags -slow to ignore slow tests.

Comment thread tests/unit/keyspace.tcl Outdated
Comment thread .github/workflows/external.yml Outdated

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last round of comments.
p.s. i see that a few of my old ones are still unresolved.

Comment thread tests/unit/introspection.tcl Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread tests/README.md
* Skip slow tests on CI
* Move external tests (CI and daily) to a separate file.
@yossigo yossigo marked this pull request as ready for review June 9, 2021 09:04
@yossigo yossigo merged commit 8a86bca into redis:unstable Jun 9, 2021
@yossigo yossigo deleted the external-tests branch June 9, 2021 12:13
@sundb

sundb commented Jun 9, 2021

Copy link
Copy Markdown
Collaborator

@yossigo I have a problem with my branch merge this pr, when a file has only one test it reports an error.
exec ./runtest --single unit/querybuf --tags -slow.

start_server {tags {slow}} {
    test "query buffer resized correctly" {
    }
}

error

Executing test client: expected non-negative integer but got "".
expected non-negative integer but got ""
    while executing
"read $::test_server_fd $bytes"
    (procedure "test_client_main" line 7)
    invoked from within
"test_client_main $::test_server_port "

When I change it to the following, no error occurs.

start_server {} {
    tags {slow} {
        test "query buffer resized correctly" {

        }
    }
}

@oranagra

oranagra commented Jun 9, 2021

Copy link
Copy Markdown
Member

@sundb it seems to work for me. even checked out your branch and executed the test with and without --tags -slow.

@sundb

sundb commented Jun 9, 2021

Copy link
Copy Markdown
Collaborator

@oranagra It's ok without --tags -slow and --tags slow is also ok.
I ran the same test on unit/type/string, also had this problem, and could not use --clients 1, it will ok.

change string.tcl to follow and run ./runtest --single unit/type/string --tags -slow

start_server {tags {"slow"}} {
    test {Very big payload random access} {
    } {}
}

@sundb

sundb commented Jun 9, 2021

Copy link
Copy Markdown
Collaborator

@oranagra My branch is working fine because I moved tags {slow} inside start_server.

@sundb

sundb commented Jun 9, 2021

Copy link
Copy Markdown
Collaborator

@oranagra It only goes wrong with --single testname --tags -slow, /runtest --tags -slow is ok.

JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Sep 8, 2021
This commit revives the improves the ability to run the test suite against
external servers, instead of launching and managing `redis-server` processes as
part of the test fixture.

This capability existed in the past, using the `--host` and `--port` options.
However, it was quite limited and mostly useful when running a specific tests.
Attempting to run larger chunks of the test suite experienced many issues:

* Many tests depend on being able to start and control `redis-server` themselves,
and there's no clear distinction between external server compatible and other
tests.
* Cluster mode is not supported (resulting with `CROSSSLOT` errors).

This PR cleans up many things and makes it possible to run the entire test suite
against an external server. It also provides more fine grained controls to
handle cases where the external server supports a subset of the Redis commands,
limited number of databases, cluster mode, etc.

The tests directory now contains a `README.md` file that describes how this
works.

This commit also includes additional cleanups and fixes:

* Tests can now be tagged.
* Tag-based selection is now unified across `start_server`, `tags` and `test`.
* More information is provided about skipped or ignored tests.
* Repeated patterns in tests have been extracted to common procedures, both at a
  global level and on a per-test file basis.
* Cleaned up some cases where test setup was based on a previous test executing
  (a major anti-pattern that repeats itself in many places).
* Cleaned up some cases where test teardown was not part of a test (in the
  future we should have dedicated teardown code that executes even when tests
  fail).
* Fixed some tests that were flaky running on external servers.
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

Successfully merging this pull request may close these issues.

3 participants