Skip to content

Commit

Permalink
Merge pull request databendlabs#1299 from datafuselabs/fusecli-e2e
Browse files Browse the repository at this point in the history
[Datafuse CLI] e2e framework for fusecli
  • Loading branch information
databend-bot authored Aug 5, 2021
2 parents add8ecd + 4e34d24 commit be787d2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Rust
target/*
distro/*
fusecli/cli/e2e/datafuse-cli

# cargo
.cargo/
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ clean:

docker_release:
docker buildx build . -f ./docker/release/Dockerfile --platform ${PLATFORM} --allow network.host --builder host -t ${HUB}/datafuse:${TAG} --push

cli-e2e:
cargo build --bin datafuse-cli --out-dir fusecli/cli/e2e -Z unstable-options
(cd ./fusecli/cli/e2e && python3 e2e.py)
.PHONY: setup test run build fmt lint docker clean
5 changes: 5 additions & 0 deletions fusecli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Build:
$ make cli
```

E2E test:
```bash
make cli-e2e
```

Usage:
```
$ ./target/release/datafuse-cli
Expand Down
37 changes: 37 additions & 0 deletions fusecli/cli/e2e/e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import time
import warnings

from absl.testing import absltest
from absl.testing import parameterized
import asynctest
import logging
import asyncio


async def execute(argument):
proc = await asyncio.create_subprocess_exec(
*argument,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)

outdata = await proc.stdout.readline()
out = outdata.decode('ascii').strip()

errdata = await proc.stderr.readline()
err = errdata.decode('ascii').strip()
# Wait for the subprocess exit.
await proc.wait()
return out, err
class FuseCliTest(parameterized.TestCase, asynctest.TestCase):
@parameterized.parameters(
{'command': "10"},
{'command': "--balala"},
{'command': "foo"},
)
async def testUnsupportedCommands(self, command):
out, err = await execute(("./datafuse-cli", command))
self.assertTrue('''error: Found argument '{}' which wasn't expected, or isn't valid in this context'''.format(command) in err)


if __name__ == '__main__':
absltest.main()

0 comments on commit be787d2

Please sign in to comment.