Skip to content

Commit 217507b

Browse files
authored
Rename hello-world-type examples. (#2631)
Renaming the examples to make their role clearer. There is some amount of duplication and cleanup needed, but that will be in a future PR.
1 parent 9aa7388 commit 217507b

7 files changed

Lines changed: 105 additions & 33 deletions

File tree

google/cloud/bigtable/examples/BUILD

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@ package(default_visibility = ["//visibility:public"])
1717
licenses(["notice"]) # Apache 2.0
1818

1919
cc_binary(
20-
name = "bigtable_hello_world",
21-
srcs = ["bigtable_hello_world.cc"],
20+
name = "bigtable_hello_app_profile",
21+
srcs = ["bigtable_hello_app_profile.cc"],
2222
deps = ["//google/cloud/bigtable:bigtable_client"],
2323
)
2424

2525
cc_binary(
26-
name = "bigtable_hello_app_profile",
27-
srcs = ["bigtable_hello_app_profile.cc"],
26+
name = "bigtable_hello_instance_admin",
27+
srcs = ["bigtable_hello_instance_admin.cc"],
2828
deps = ["//google/cloud/bigtable:bigtable_client"],
2929
)
3030

3131
cc_binary(
32-
name = "bigtable_quickstart",
33-
srcs = ["bigtable_quickstart.cc"],
32+
name = "bigtable_hello_table_admin",
33+
srcs = ["bigtable_hello_table_admin.cc"],
3434
deps = ["//google/cloud/bigtable:bigtable_client"],
3535
)
3636

3737
cc_binary(
38-
name = "bigtable_samples",
39-
srcs = ["bigtable_samples.cc"],
38+
name = "bigtable_hello_world",
39+
srcs = ["bigtable_hello_world.cc"],
4040
deps = ["//google/cloud/bigtable:bigtable_client"],
4141
)
4242

4343
cc_binary(
44-
name = "bigtable_instance_admin_snippets",
45-
srcs = ["bigtable_instance_admin_snippets.cc"],
44+
name = "bigtable_quickstart",
45+
srcs = ["bigtable_quickstart.cc"],
4646
deps = ["//google/cloud/bigtable:bigtable_client"],
4747
)
4848

4949
cc_binary(
50-
name = "bigtable_samples_instance_admin",
51-
srcs = ["bigtable_samples_instance_admin.cc"],
50+
name = "bigtable_instance_admin_snippets",
51+
srcs = ["bigtable_instance_admin_snippets.cc"],
5252
deps = ["//google/cloud/bigtable:bigtable_client"],
5353
)
5454

google/cloud/bigtable/examples/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
# to keep this particular file as simple as possible, as it is intended to be
1919
# part of the examples.
2020

21+
add_executable(bigtable_hello_table_admin bigtable_hello_table_admin.cc)
22+
target_link_libraries(bigtable_hello_table_admin bigtable_client
23+
bigtable_common_options)
24+
25+
add_executable(bigtable_hello_instance_admin bigtable_hello_instance_admin.cc)
26+
target_link_libraries(bigtable_hello_instance_admin bigtable_client
27+
bigtable_common_options)
28+
2129
add_executable(bigtable_hello_world bigtable_hello_world.cc)
2230
target_link_libraries(bigtable_hello_world bigtable_client
2331
bigtable_common_options)
@@ -30,19 +38,11 @@ add_executable(bigtable_quickstart bigtable_quickstart.cc)
3038
target_link_libraries(bigtable_quickstart bigtable_client
3139
bigtable_common_options)
3240

33-
add_executable(bigtable_samples bigtable_samples.cc)
34-
target_link_libraries(bigtable_samples bigtable_client bigtable_common_options)
35-
3641
add_executable(bigtable_instance_admin_snippets
3742
bigtable_instance_admin_snippets.cc)
3843
target_link_libraries(bigtable_instance_admin_snippets bigtable_client
3944
bigtable_common_options)
4045

41-
add_executable(bigtable_samples_instance_admin
42-
bigtable_samples_instance_admin.cc)
43-
target_link_libraries(bigtable_samples_instance_admin bigtable_client
44-
bigtable_common_options)
45-
4646
add_executable(instance_admin_async_snippets instance_admin_async_snippets.cc)
4747
target_link_libraries(instance_admin_async_snippets bigtable_client
4848
bigtable_common_options)

google/cloud/bigtable/examples/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ referenced from the Doxygen landing page as "Hello World".
1818

1919
### Compile the Examples
2020

21+
<!-- START bigtable_hw_install -->
22+
2123
These examples are compiled as part of the build for the Cloud Bigtable C++
2224
Client. The instructions on how to compile the code are in the
2325
[top-level README](../../README.md) file.
2426

27+
<!-- END bigtable_hw_install -->
28+
2529
### Run the Examples
2630

2731
You first need to create a production instance, the easiest way is to
@@ -61,7 +65,8 @@ $ gcloud auth login
6165

6266
### Hello world
6367

64-
View the [Hello World][hello_world_code] example to see sample usage of the Bigtable client library.
68+
View the [Hello World][hello_world_code] example to see sample usage of the
69+
Bigtable client library.
6570

6671
#### Usage
6772

@@ -71,6 +76,7 @@ Usage: bigtable_hello_world <project_id> <instance_id> <table_id>
7176
```
7277

7378
#### Run Hello world
79+
7480
After configuring gRPC, you can run the examples using:
7581

7682
```console
@@ -81,8 +87,8 @@ $ ./bigtable_hello_world ${PROJECT_ID} ${INSTANCE_ID} example-table
8187

8288
### Administer Instances
8389

84-
View the [example][instance_admin_code] to see sample usage of instance administration of
85-
the Bigtable client library.
90+
View the [example][instance_admin_code] to see sample usage of instance
91+
administration of the Bigtable client library.
8692

8793
#### Usage
8894

@@ -114,7 +120,7 @@ $ ./bigtable_samples_instance_admin run ${PROJECT_ID} ${INSTANCE_ID} ${CLUSTER_I
114120
```
115121

116122
[hello_world_code]: bigtable_hello_world.cc
117-
[instance_admin_code]: bigtable_samples_instance_admin.cc
123+
[instance_admin_code]: bigtable_hello_instance_admin.cc
118124

119125
### Administer Tables
120126

google/cloud/bigtable/examples/bigtable_samples_instance_admin.cc renamed to google/cloud/bigtable/examples/bigtable_hello_instance_admin.cc

File renamed without changes.

google/cloud/bigtable/examples/bigtable_samples.cc renamed to google/cloud/bigtable/examples/bigtable_hello_table_admin.cc

File renamed without changes.

google/cloud/bigtable/examples/run_admin_examples_production.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ source "${BINDIR}/../../../../ci/colors.sh"
3636
echo "${COLOR_YELLOW}run_quickstart_example${COLOR_RESET}"
3737
run_quickstart_example "${PROJECT_ID}" "${INSTANCE_ID}"
3838

39+
echo "${COLOR_YELLOW}run_hello_instance_admin_example${COLOR_RESET}"
40+
run_hello_instance_admin_example "${PROJECT_ID}" "${ZONE_A}"
41+
42+
echo "${COLOR_YELLOW}run_hello_table_admin_example${COLOR_RESET}"
43+
run_hello_table_admin_example "${PROJECT_ID}" "${INSTANCE_ID}"
44+
3945
echo "${COLOR_YELLOW}run_hello_world_example${COLOR_RESET}"
4046
run_hello_world_example "${PROJECT_ID}" "${INSTANCE_ID}"
4147

google/cloud/bigtable/examples/run_examples_utils.sh

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ function run_all_instance_admin_examples {
139139
# Verify that calling without a command produces the right exit status and
140140
# some kind of Usage message.
141141
run_example_usage ./bigtable_instance_admin_snippets
142-
run_example_usage ./bigtable_samples_instance_admin
143142
}
144143

145144
# Run all the instance admin async examples.
@@ -225,8 +224,6 @@ function run_all_table_admin_examples {
225224
run_example ./bigtable_instance_admin_snippets create-instance \
226225
"${project_id}" "${INSTANCE}" "${zone_id}"
227226

228-
run_example ./bigtable_samples run "${project_id}" "${INSTANCE}" "${TABLE}"
229-
230227
run_example ./table_admin_snippets create-table \
231228
"${project_id}" "${INSTANCE}" "${TABLE}"
232229
run_example ./table_admin_snippets list-tables \
@@ -433,12 +430,6 @@ run_all_data_examples() {
433430

434431
run_mutate_examples "${project_id}" "${instance_id}"
435432

436-
# Use a different table for the full example test, if we use the same table
437-
# as the other tests this can fail with timeouts.
438-
local -r FULL_TABLE="data-ex-full-${RANDOM}-${RANDOM}"
439-
run_example ./bigtable_samples run-full-example \
440-
"${project_id}" "${instance_id}" "${FULL_TABLE}"
441-
442433
# Use the same table in all the tests.
443434
local -r TABLE="data-ex-tbl-${RANDOM}-${RANDOM}"
444435
local -r PREFIX_1="root/0/1/"
@@ -695,6 +686,75 @@ run_quickstart_example() {
695686
run_example_usage ./bigtable_quickstart
696687
}
697688

689+
################################################
690+
# Run the Bigtable hello world for InstanceAdmin example.
691+
# Globals:
692+
# None
693+
# Arguments:
694+
# project_id: the Google Cloud Platform project used in the test. Can be a
695+
# fake project when testing against the emulator, as the emulator creates
696+
# projects on demand. It must be a valid, existing instance when testing
697+
# against production.
698+
# zone_id: a Google Cloud Platform zone with support for Cloud Bigtable.
699+
# Returns:
700+
# None
701+
################################################
702+
run_hello_instance_admin_example() {
703+
local project_id=$1
704+
local zone_id=$2
705+
shift 2
706+
707+
# Use the same table in all the tests.
708+
local -r RANDOM_INSTANCE_ID="it-${RANDOM}-${RANDOM}"
709+
local -r RANDOM_CLUSTER_ID="${RANDOM_INSTANCE_ID}-c1"
710+
711+
run_example ./bigtable_hello_instance_admin "run" \
712+
"${project_id}" "${RANDOM_INSTANCE_ID}" "${RANDOM_CLUSTER_ID}" \
713+
"${zone_id}"
714+
715+
# Verify that calling without a command produces the right exit status and
716+
# some kind of Usage message.
717+
run_example_usage ./bigtable_hello_instance_admin
718+
}
719+
720+
################################################
721+
# Run the Bigtable hello world for Table Admin example.
722+
# Globals:
723+
# None
724+
# Arguments:
725+
# project_id: the Google Cloud Platform project used in the test. Can be a
726+
# fake project when testing against the emulator, as the emulator creates
727+
# projects on demand. It must be a valid, existing instance when testing
728+
# against production.
729+
# instance_id: the Google Cloud Bigtable instance used in the test. Can be a
730+
# fake instance when testing against the emulator, as the emulator creates
731+
# instances on demand. It must be a valid, existing instance when testing
732+
# against production.
733+
# Returns:
734+
# None
735+
################################################
736+
run_hello_table_admin_example() {
737+
local project_id=$1
738+
local instance_id=$2
739+
shift 2
740+
741+
# TODO(#2626) - remove "run-full-example" it is just a duplicate of "run".
742+
# Use a different table for the full example test, if we use the same table
743+
# as the other tests this can fail with timeouts.
744+
local -r FULL_TABLE="data-ex-full-${RANDOM}-${RANDOM}"
745+
run_example ./bigtable_hello_table_admin run-full-example \
746+
"${project_id}" "${instance_id}" "${FULL_TABLE}"
747+
748+
# Use the same table in all the tests.
749+
local -r TABLE="hello-table-admin-${RANDOM}"
750+
run_example ./bigtable_hello_table_admin run \
751+
"${project_id}" "${instance_id}" "${TABLE}"
752+
753+
# Verify that calling without a command produces the right exit status and
754+
# some kind of Usage message.
755+
run_example_usage ./bigtable_hello_world
756+
}
757+
698758
################################################
699759
# Run the Bigtable hello world example.
700760
# Globals:

0 commit comments

Comments
 (0)