Search in sources :

Example 21 with Instance

use of com.google.bigtable.admin.v2.Instance in project java-redis by googleapis.

the class ITSystemTest method testGetInstance.

@Test
public void testGetInstance() {
    Instance response = client.getInstance(INSTANCE_NAME);
    assertEquals(TIER, response.getTier());
    assertEquals(INSTANCE_NAME.toString(), response.getName());
}
Also used : Instance(com.google.cloud.redis.v1.Instance) Test(org.junit.Test)

Example 22 with Instance

use of com.google.bigtable.admin.v2.Instance in project java-redis by googleapis.

the class ITSystemTest method testUpdateInstance.

@Test
public void testUpdateInstance() throws ExecutionException, InterruptedException {
    int memorySizeGb = 4;
    FieldMask updateMask = FieldMask.newBuilder().addAllPaths(Arrays.asList("memory_size_gb")).build();
    Instance instance = Instance.newBuilder().setName(INSTANCE_NAME.toString()).setMemorySizeGb(memorySizeGb).build();
    UpdateInstanceRequest updateInstanceRequest = UpdateInstanceRequest.newBuilder().setInstance(instance).setUpdateMask(updateMask).build();
    Instance actualInstance = client.updateInstanceAsync(updateInstanceRequest).get();
    assertEquals(memorySizeGb, actualInstance.getMemorySizeGb());
}
Also used : UpdateInstanceRequest(com.google.cloud.redis.v1.UpdateInstanceRequest) Instance(com.google.cloud.redis.v1.Instance) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 23 with Instance

use of com.google.bigtable.admin.v2.Instance in project java-redis by googleapis.

the class ITSystemTest method testListInstances.

@Test
public void testListInstances() {
    List<Instance> instances = Lists.newArrayList(client.listInstances(PARENT).iterateAll());
    for (Instance instance : instances) {
        if (INSTANCE_NAME.toString().equals(instance.getName())) {
            assertEquals(TIER, instance.getTier());
            assertEquals(INSTANCE_NAME.toString(), instance.getName());
        }
    }
}
Also used : Instance(com.google.cloud.redis.v1.Instance) Test(org.junit.Test)

Example 24 with Instance

use of com.google.bigtable.admin.v2.Instance in project java-redis by googleapis.

the class ITSystemTest method testUpdateInstance.

@Test
public void testUpdateInstance() throws ExecutionException, InterruptedException {
    int memorySizeGb = 4;
    FieldMask updateMask = FieldMask.newBuilder().addAllPaths(Arrays.asList("memory_size_gb")).build();
    Instance instance = Instance.newBuilder().setName(INSTANCE_NAME.toString()).setMemorySizeGb(memorySizeGb).build();
    UpdateInstanceRequest updateInstanceRequest = UpdateInstanceRequest.newBuilder().setInstance(instance).setUpdateMask(updateMask).build();
    Instance actualInstance = client.updateInstanceAsync(updateInstanceRequest).get();
    assertEquals(memorySizeGb, actualInstance.getMemorySizeGb());
}
Also used : UpdateInstanceRequest(com.google.cloud.redis.v1beta1.UpdateInstanceRequest) Instance(com.google.cloud.redis.v1beta1.Instance) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 25 with Instance

use of com.google.bigtable.admin.v2.Instance in project java-redis by googleapis.

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CloudRedisSettings.Builder cloudRedisSettingsBuilder = CloudRedisSettings.newBuilder();
    cloudRedisSettingsBuilder.getInstanceSettings().setRetrySettings(cloudRedisSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(900)).build());
    CloudRedisSettings cloudRedisSettings = cloudRedisSettingsBuilder.build();
    client = CloudRedisClient.create(cloudRedisSettings);
    /* Creates a Redis instance based on the specified tier and memory size. */
    Instance instance = Instance.newBuilder().setTier(TIER).setMemorySizeGb(1).setAuthorizedNetwork(AUTHORIZED_NETWORK).build();
    client.createInstanceAsync(PARENT, INSTANCE, instance).get();
    LOG.info("redis instance created successfully.");
}
Also used : Instance(com.google.cloud.redis.v1beta1.Instance) CloudRedisSettings(com.google.cloud.redis.v1beta1.CloudRedisSettings) BeforeClass(org.junit.BeforeClass)

Aggregations

Test (org.junit.Test)124 AbstractMessage (com.google.protobuf.AbstractMessage)62 ByteString (com.google.protobuf.ByteString)57 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)40 StatusRuntimeException (io.grpc.StatusRuntimeException)40 Operation (com.google.longrunning.Operation)22 InstanceName (com.google.bigtable.admin.v2.InstanceName)20 HashMap (java.util.HashMap)16 ExecutionException (java.util.concurrent.ExecutionException)16 Table (com.google.bigtable.admin.v2.Table)15 TableName (com.google.bigtable.admin.v2.TableName)15 ClusterName (com.google.bigtable.admin.v2.ClusterName)14 Cluster (com.google.bigtable.admin.v2.Cluster)13 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)13 ArrayList (java.util.ArrayList)12 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 Instance (com.google.cloud.notebooks.v1beta1.Instance)9