-
Notifications
You must be signed in to change notification settings - Fork 433
Implement an integration test for Table::Apply() #74
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
Implement an integration test for Table::Apply() #74
Conversation
This is part of the fixes for googleapis#37. The script starts up the emulator and runs the integration test against it.
Also run the integration tests as part of the CI builds.
mbrukman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts for your consideration.
ci/Dockerfile.fedora
Outdated
| wget \ | ||
| zlib-devel | ||
|
|
||
| # Install the bigtable emulator and the bigtable command-line client. They |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/bigtable/Bigtable/g
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ci/Dockerfile.ubuntu
Outdated
| g++-4.8 \ | ||
| || /bin/true | ||
|
|
||
| # Install the bigtable emulator and the bigtable command-line client. They |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/bigtable/Bigtable/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
bigtable/tests/apply_test.cc
Outdated
|
|
||
| int main() try { | ||
| bigtable::Client client("emulated", "emulated"); | ||
| std::unique_ptr<bigtable::Table> table = client.Open("test-table"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have the Admin API available yet? If so, it should create and delete the table itself. Same for the column family.
Otherwise, it's a bunch of magic strings here: both table and column family are set up via script, and must match here, but it's not stated anywhere either in the shell script or this C++ test.
Some options:
- document the implicit dependency (easy and cheesy)
- set env vars in the script, read those env vars in C++ so that it's clear it's an external input (preferred, unless option 3 is coming soon)
- once Admin API is available, just create/delete table + column family in the script (defer)
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, there is no Admin API, nor is the Admin API part of the MVP. I have created #79 for this. I am inclined to do (2) because it will make this program reusable for testing against production too. I used command-line args for the first cut.
| mutation.emplace_back(bigtable::SetCell("fam", "col0", 0, "value-1-0")); | ||
| mutation.emplace_back(bigtable::SetCell("fam", "col1", 0, "value-1-1")); | ||
| table->Apply(std::move(mutation)); | ||
| std::cout << "row-key-1 mutated successfully\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also do a read after each write to ensure it actually wrote what it thinks it did?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| set -eu | ||
|
|
||
| function kill_emulator { | ||
| kill ${EMULATOR_PID} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2- or 4-space indent for shell scripts?
ci/Dockerfile.ubuntu
Outdated
| ARG GOPATH=/var/tmp/build/cbt | ||
| WORKDIR ${GOPATH} | ||
| RUN if grep -q 14.04 /etc/lsb-release; then \ | ||
| echo "Skip cloud bigtable client install, go version too old in Ubuntu 14.04."; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/go/Go/g
ci/Dockerfile.ubuntu
Outdated
| ARG GOPATH=/var/tmp/build/cbt | ||
| WORKDIR ${GOPATH} | ||
| RUN if grep -q 14.04 /etc/lsb-release; then \ | ||
| echo "Skip cloud bigtable client install, go version too old in Ubuntu 14.04."; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Skip/Skipping/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ci/Dockerfile.ubuntu
Outdated
|
|
||
| WORKDIR /var/tmp/build/gccpp/build-output/bigtable | ||
| RUN if grep -q 14.04 /etc/lsb-release; then \ | ||
| echo "Skip integration tests, go version too old in Ubuntu 14.04."; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Skip/Skipping/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| "${GOPATH}/bin/emulator" >emulator.log 2>&1 </dev/null & | ||
| EMULATOR_PID=$! | ||
| if [ $? -ne 0 ]; then | ||
| echo "emulator failed, aborting" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
echo "Cloud Bigtable emulator failed; aborting test." >&2
?
|
|
||
| trap kill_emulator EXIT | ||
|
|
||
| export BIGTABLE_EMULATOR_HOST=localhost:9000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 9000 the default port on which the emulator listens on? Is this running inside a container so we're guaranteed that 9000 is not taken already? Is it worthwhile to document where this magic number comes from? Is it worthwhile to choose a specific port explicitly and use a var so the connection is clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| echo "Launching Cloud Bigtable emulator in the background" | ||
| "${GOPATH}/bin/emulator" >emulator.log 2>&1 </dev/null & | ||
| # The tests typically run on a docker container, where the ports are largely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/on a docker/in a Docker/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| echo "Launching Cloud Bigtable emulator in the background" | ||
| "${GOPATH}/bin/emulator" >emulator.log 2>&1 </dev/null & | ||
| # The tests typically run on a docker container, where the ports are largely | ||
| # free, when using in manual tests you can set EMULATOR_PORT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/free,/free;/
s/manual tests/manual tests,/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
ci/Dockerfile.ubuntu
Outdated
| WORKDIR ${GOPATH} | ||
| RUN if grep -q 14.04 /etc/lsb-release; then \ | ||
| echo "Skip cloud bigtable client install, go version too old in Ubuntu 14.04."; \ | ||
| echo "Skipping cloud bigtable client install, Go version too old in Ubuntu 14.04."; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/cloud bigtable client/cbt/ ?
or if you want to be more descriptive, "cbt CLI"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
PTAL. |
mbrukman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
||
| echo "Creating test-table in the emulator." | ||
| "${GOPATH}/bin/cbt" $CBT_ARGS createtable test-table | ||
| echo "Creating family in test-table." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/family/column family/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, I missed that. Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #81
Leftover review comment from PR #74.
This fixes #37. It implements an integration test for
Table::Apply()against the Cloud Bigtable Emulator.I think both @sduskis and @mbrukman will have opinions on the need for such integration tests. I want to hear from them if this is good enough. @garye and @DanielMahu please check the code too!