etesync / etebase-rs

A Rust client library for Etebase
https://www.etebase.com
BSD 3-Clause "New" or "Revised" License
116 stars 11 forks source link

Tests fail with NotFound #14

Closed Shadow53 closed 3 years ago

Shadow53 commented 3 years ago

I am looking to contribute to this project, but I wanted to make sure I have a good testing setup put together before making changes. To simplify things, I made a script that starts the victorrds/etebase:latest docker image and uses that for tests. The relevant bits of the script are below:

ETEBASE_SERVER="${ETEBASE_SERVER:-http}"
ETEBASE_DEBUG="${ETEBASE_DEBUG:-true}"
ETEBASE_AUTO_UPDATE="${ETEBASE_AUTO_UPDATE:-true}"
ETEBASE_SUPER_EMAIL="${ETEBASE_SUPER_EMAIL:-test@localhost}"
ETEBASE_SUPER_USER="${ETEBASE_SUPER_USER:-test_user}"
ETEBASE_SUPER_PASS="${ETEBASE_SUPER_PASS:-SomePassword}"
ETEBASE_NAME="${ETEBASE_NAME:-etebase-rs-tests}"
ETEBASE_IMAGE="${ETEBASE_IMAGE:-victorrds/etebase:latest}"
ETEBASE_DJANGO_DEBUG="${ETEBASE_DJANGO_DEBUG:-true}"

    $docker run \
        -p 8033:3735 \
        -e SERVER="$ETEBASE_SERVER" \
        -e DEBUG="$ETEBASE_DEBUG" \
        -e AUTO_UPDATE="$ETEBASE_AUTO_UPDATE" \
        -e SUPER_USER="$ETEBASE_SUPER_USER" \
        -e SUPER_EMAIL="$ETEBASE_SUPER_EMAIL" \
        -e SUPER_PASS="$ETEBASE_SUPER_PASS" \
        -e DJANGO_DEBUG="$ETEBASE_DJANGO_DEBUG" \
        --name "$ETEBASE_NAME" --replace \
        --detach \
        "$ETEBASE_IMAGE"

When attempting to run the tests, I get the following results:

running 7 tests
test box_crypto_manager ... ok
test crypto_mac ... ok
test crypto_manager ... ok
test derive_key ... ok
test deterministic_encrypt ... ok
test login_crypto_manager ... ok
test pretty_fingerprint ... ok

# ... trimmed extra output ...

running 26 tests
test cache_collections_and_items ... FAILED
test chunk_preupload_and_download ... FAILED
test chunking_large_data ... FAILED
test collection_access_level ... FAILED
test collection_and_item_deletion ... FAILED
test collection_as_item ... FAILED
test collection_invitations ... FAILED
test collection_types ... FAILED
test empty_content ... FAILED
test get_dashboard_url ... FAILED
test is_etebase_server ... ok
test item_batch_stoken ... FAILED
test item_fetch_updates ... FAILED
test item_revisions ... FAILED
test item_transactions ... FAILED
test iterating_invitations ... FAILED
test list_response_correctness ... FAILED
test loading_cache_without_collection_type ... FAILED
test login_and_password_change ... ignored
test login_and_password_change_with_key ... FAILED
test session_save_and_restore ... FAILED
test signup_with_key ... ignored
test simple_collection_handling ... FAILED
test simple_collection_sync ... FAILED
test simple_item_handling ... FAILED
test simple_item_sync ... FAILED

Where every test fails with the same message:

Error: NotFound("NotFound")
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /home/shadow53/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:192:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After talking with SaltFactory:matrix.org in the EteSync matrix room, we've determined that every test is received a 404, likely because a user was not created correctly. So this issue is for two reasons:

  1. Figuring out why the tests are failing
  2. Gathering information to improve the testing documentation and figuring out a way to automate setup and teardown for testing.
    1. If a user does need to be created in a way other than SUPER_*, the preferred solution would be some sort of automated way to create one, with the end goal being that someone can clone the repo and run a testing script/Makefile/etc., and the tests run and pass.

Further information:

tasn commented 3 years ago

The test reset path isn't available in production, it's only available in development. So you would have to set DEBUG=True in the docker image for it to work. I think @gchaincl did something similar in etebase-go, so maybe look there.

tasn commented 3 years ago

Ah, I see it's potentially already in debug mode? (verify). I think you need to open http://localhost:8033/docs to make sure the reset endpoint is actually there.

Edit: OK, I just took a look at the code and it seems like the test user may just not be setup (that will also return a 404), you need to add two users, test_user and test_user2 for the tests to work. I forgot about that. :P

Shadow53 commented 3 years ago

This is odd. I get "It works!" when I go to http://localhost:8033 but a Not Found when I try to go to http://localhost:8033/docs.

tasn commented 3 years ago

Hmm... It could be that the latest docker image points to the latest release rather than latest git state and then it makes sense that it's missing.

djmitche commented 3 years ago

I'm seeing this as well. Can you clarify when the reset endpoint was introduced? The docker image I'm testing against (from https://github.com/etesync/server/issues/94) is running etesync 0.7.0.

Perhaps a new release is in order?

djmitche commented 3 years ago

Ah, I undrestand now -- it's failing because the docker image does not have the users pre-created, and resetting does not create them.

djmitche commented 3 years ago

15 fixed this.