Skip to content

Commit 57de4ae

Browse files
committed
shift test
1 parent f505085 commit 57de4ae

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

google/cloud/bigtable/tests/data_integration_test.cc

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -189,60 +189,6 @@ TEST_P(DataIntegrationTest, TableReadRowTest) {
189189
CheckEqualUnordered(expected, actual);
190190
}
191191

192-
TEST_P(DataIntegrationTest, ClientQueryTest) {
193-
auto const table_id = testing::TableTestEnvironment::table_id();
194-
auto conn = MakeDataConnection(Options{}.set<DataRetryPolicyOption>(
195-
DataLimitedErrorCountRetryPolicy(0).clone()));
196-
auto table = Table(std::move(conn),
197-
TableResource(project_id(), instance_id(), table_id));
198-
std::string const row_key = "row-key-for-client-query-test";
199-
std::string const family = kFamily4;
200-
std::string const column1 = "c1";
201-
std::string const column2 = "c2";
202-
std::string const value1 = "v1";
203-
std::string const value2 = "v2";
204-
205-
std::vector<Cell> created{
206-
{row_key, family, column1, 0, value1},
207-
{row_key, family, column2, 0, value2},
208-
};
209-
BulkApply(table, created);
210-
auto data_connection = table.connection();
211-
auto client =
212-
Client(data_connection,
213-
Options{}
214-
.set<DataRetryPolicyOption>(
215-
DataLimitedErrorCountRetryPolicy(0).clone())
216-
.set<DataBackoffPolicyOption>(
217-
google::cloud::internal::ExponentialBackoffPolicy(
218-
ms(0), ms(0), 2.0)
219-
.clone()));
220-
std::vector<std::string> full_table_path =
221-
absl::StrSplit(table.table_name(), "/");
222-
auto table_name = full_table_path.back();
223-
std::string quoted_table_name = "`" + table_name + "`";
224-
Project project(project_id());
225-
InstanceResource instance_resource(project, instance_id());
226-
auto prepared_query = client.PrepareQuery(
227-
instance_resource,
228-
SqlStatement("SELECT CAST(family4['c0'] AS STRING) AS c0 FROM " +
229-
quoted_table_name + " WHERE _key = '" + row_key + "'"));
230-
ASSERT_STATUS_OK(prepared_query);
231-
232-
auto bound_query = prepared_query->BindParameters({});
233-
auto row_stream = client.ExecuteQuery(std::move(bound_query));
234-
235-
std::vector<StatusOr<bigtable::QueryRow>> rows;
236-
for (auto const& row : std::move(row_stream)) {
237-
rows.push_back(row);
238-
}
239-
240-
ASSERT_EQ(rows.size(), 1);
241-
ASSERT_STATUS_OK(rows[0]);
242-
auto const& row1 = *rows[0];
243-
EXPECT_THAT(row1.columns().at(0), "c0");
244-
}
245-
246192
TEST_P(DataIntegrationTest, TableReadRowNotExistTest) {
247193
auto table = GetTable(GetParam());
248194
std::string const row_key1 = "row-key-1";
@@ -730,6 +676,60 @@ TEST(ConnectionRefresh, Frequent) {
730676
Apply(table, row_key, created);
731677
}
732678

679+
TEST_P(DataIntegrationTest, ClientQueryTest) {
680+
auto const table_id = testing::TableTestEnvironment::table_id();
681+
auto conn = MakeDataConnection(Options{}.set<DataRetryPolicyOption>(
682+
DataLimitedErrorCountRetryPolicy(0).clone()));
683+
auto table = Table(std::move(conn),
684+
TableResource(project_id(), instance_id(), table_id));
685+
std::string const row_key = "row-key-for-client-query-test";
686+
std::string const family = kFamily4;
687+
std::string const column1 = "c1";
688+
std::string const column2 = "c2";
689+
std::string const value1 = "v1";
690+
std::string const value2 = "v2";
691+
692+
std::vector<Cell> created{
693+
{row_key, family, column1, 0, value1},
694+
{row_key, family, column2, 0, value2},
695+
};
696+
BulkApply(table, created);
697+
auto data_connection = table.connection();
698+
auto client =
699+
Client(data_connection,
700+
Options{}
701+
.set<DataRetryPolicyOption>(
702+
DataLimitedErrorCountRetryPolicy(0).clone())
703+
.set<DataBackoffPolicyOption>(
704+
google::cloud::internal::ExponentialBackoffPolicy(
705+
ms(0), ms(0), 2.0)
706+
.clone()));
707+
std::vector<std::string> full_table_path =
708+
absl::StrSplit(table.table_name(), "/");
709+
auto table_name = full_table_path.back();
710+
std::string quoted_table_name = "`" + table_name + "`";
711+
Project project(project_id());
712+
InstanceResource instance_resource(project, instance_id());
713+
auto prepared_query = client.PrepareQuery(
714+
instance_resource,
715+
SqlStatement("SELECT CAST(family4['c0'] AS STRING) AS c0 FROM " +
716+
quoted_table_name + " WHERE _key = '" + row_key + "'"));
717+
ASSERT_STATUS_OK(prepared_query);
718+
719+
auto bound_query = prepared_query->BindParameters({});
720+
auto row_stream = client.ExecuteQuery(std::move(bound_query));
721+
722+
std::vector<StatusOr<bigtable::QueryRow>> rows;
723+
for (auto const& row : std::move(row_stream)) {
724+
rows.push_back(row);
725+
}
726+
727+
ASSERT_EQ(rows.size(), 1);
728+
ASSERT_STATUS_OK(rows[0]);
729+
auto const& row1 = *rows[0];
730+
EXPECT_THAT(row1.columns().at(0), "c0");
731+
}
732+
733733
// TODO(#8800) - remove after deprecation is complete
734734
#include "google/cloud/internal/diagnostics_pop.inc"
735735

0 commit comments

Comments
 (0)