-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
- Loading branch information
Showing
11 changed files
with
285 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...gtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.it; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.common.truth.TruthJUnit.assume; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.gax.rpc.NotFoundException; | ||
import com.google.cloud.bigtable.admin.v2.models.Cluster; | ||
import com.google.cloud.bigtable.data.v2.models.Query; | ||
import com.google.cloud.bigtable.data.v2.models.Row; | ||
import com.google.cloud.bigtable.stats.BuiltinViews; | ||
import com.google.cloud.bigtable.stats.StatsWrapper; | ||
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv; | ||
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; | ||
import com.google.common.collect.Lists; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
public class StreamingMetricsMetadataIT { | ||
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule(); | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
assume() | ||
.withMessage("StreamingMetricsMetadataIT is not supported on Emulator") | ||
.that(testEnvRule.env()) | ||
.isNotInstanceOf(EmulatorEnv.class); | ||
BuiltinViews.registerBigtableBuiltinViews(); | ||
} | ||
|
||
@Test | ||
public void testSuccess() throws Exception { | ||
String prefix = UUID.randomUUID().toString(); | ||
String uniqueKey = prefix + "-read"; | ||
|
||
Query query = Query.create(testEnvRule.env().getTableId()).rowKey(uniqueKey); | ||
ArrayList<Row> rows = Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query)); | ||
|
||
ApiFuture<List<Cluster>> clustersFuture = | ||
testEnvRule | ||
.env() | ||
.getInstanceAdminClient() | ||
.listClustersAsync(testEnvRule.env().getInstanceId()); | ||
|
||
List<Cluster> clusters = clustersFuture.get(1, TimeUnit.MINUTES); | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getZone()); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getId()); | ||
} | ||
|
||
@Test | ||
public void testFailure() throws InterruptedException { | ||
Query query = Query.create("non-exist-table"); | ||
try { | ||
Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query)); | ||
} catch (NotFoundException e) { | ||
} | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...d-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.it; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.common.truth.TruthJUnit.assume; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.gax.rpc.NotFoundException; | ||
import com.google.cloud.bigtable.admin.v2.models.Cluster; | ||
import com.google.cloud.bigtable.data.v2.models.RowMutation; | ||
import com.google.cloud.bigtable.stats.BuiltinViews; | ||
import com.google.cloud.bigtable.stats.StatsWrapper; | ||
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv; | ||
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
public class UnaryMetricsMetadataIT { | ||
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule(); | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
assume() | ||
.withMessage("UnaryMetricsMetadataIT is not supported on Emulator") | ||
.that(testEnvRule.env()) | ||
.isNotInstanceOf(EmulatorEnv.class); | ||
BuiltinViews.registerBigtableBuiltinViews(); | ||
} | ||
|
||
@Test | ||
public void testSuccess() throws Exception { | ||
String rowKey = UUID.randomUUID().toString(); | ||
String familyId = testEnvRule.env().getFamilyId(); | ||
|
||
ApiFuture<Void> future = | ||
testEnvRule | ||
.env() | ||
.getDataClient() | ||
.mutateRowCallable() | ||
.futureCall( | ||
RowMutation.create(testEnvRule.env().getTableId(), rowKey) | ||
.setCell(familyId, "q", "myVal")); | ||
|
||
future.get(1, TimeUnit.MINUTES); | ||
|
||
ApiFuture<List<Cluster>> clustersFuture = | ||
testEnvRule | ||
.env() | ||
.getInstanceAdminClient() | ||
.listClustersAsync(testEnvRule.env().getInstanceId()); | ||
List<Cluster> clusters = clustersFuture.get(1, TimeUnit.MINUTES); | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getZone()); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getId()); | ||
} | ||
|
||
@Test | ||
public void testFailure() throws InterruptedException { | ||
String rowKey = UUID.randomUUID().toString(); | ||
String familyId = testEnvRule.env().getFamilyId(); | ||
|
||
try { | ||
testEnvRule | ||
.env() | ||
.getDataClient() | ||
.mutateRowCallable() | ||
.call(RowMutation.create("non-exist-table", rowKey).setCell(familyId, "q", "myVal")); | ||
} catch (NotFoundException e) { | ||
} | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
} | ||
} |
Oops, something went wrong.