Search in sources :

Example 31 with Cluster

use of com.google.container.v1beta1.Cluster in project java-container by googleapis.

the class ClusterManagerClientTest method getClusterTest2.

@Test
public void getClusterTest2() throws Exception {
    Cluster expectedResponse = Cluster.newBuilder().setName("name3373707").setDescription("description-1724546052").setInitialNodeCount(1682564205).setNodeConfig(NodeConfig.newBuilder().build()).setMasterAuth(MasterAuth.newBuilder().build()).setLoggingService("loggingService1098570326").setMonitoringService("monitoringService-1431578291").setNetwork("network1843485230").setClusterIpv4Cidr("clusterIpv4Cidr-277423341").setAddonsConfig(AddonsConfig.newBuilder().build()).setSubnetwork("subnetwork-1302785042").addAllNodePools(new ArrayList<NodePool>()).addAllLocations(new ArrayList<String>()).setEnableKubernetesAlpha(true).putAllResourceLabels(new HashMap<String, String>()).setLabelFingerprint("labelFingerprint379449680").setLegacyAbac(LegacyAbac.newBuilder().build()).setNetworkPolicy(NetworkPolicy.newBuilder().build()).setIpAllocationPolicy(IPAllocationPolicy.newBuilder().build()).setMasterAuthorizedNetworksConfig(MasterAuthorizedNetworksConfig.newBuilder().build()).setMaintenancePolicy(MaintenancePolicy.newBuilder().build()).setBinaryAuthorization(BinaryAuthorization.newBuilder().build()).setAutoscaling(ClusterAutoscaling.newBuilder().build()).setNetworkConfig(NetworkConfig.newBuilder().build()).setDefaultMaxPodsConstraint(MaxPodsConstraint.newBuilder().build()).setResourceUsageExportConfig(ResourceUsageExportConfig.newBuilder().build()).setAuthenticatorGroupsConfig(AuthenticatorGroupsConfig.newBuilder().build()).setPrivateClusterConfig(PrivateClusterConfig.newBuilder().build()).setDatabaseEncryption(DatabaseEncryption.newBuilder().build()).setVerticalPodAutoscaling(VerticalPodAutoscaling.newBuilder().build()).setShieldedNodes(ShieldedNodes.newBuilder().build()).setReleaseChannel(ReleaseChannel.newBuilder().build()).setWorkloadIdentityConfig(WorkloadIdentityConfig.newBuilder().build()).setMeshCertificates(MeshCertificates.newBuilder().build()).setNotificationConfig(NotificationConfig.newBuilder().build()).setConfidentialNodes(ConfidentialNodes.newBuilder().build()).setSelfLink("selfLink1191800166").setZone("zone3744684").setEndpoint("endpoint1741102485").setInitialClusterVersion("initialClusterVersion-1547734558").setCurrentMasterVersion("currentMasterVersion1871927069").setCurrentNodeVersion("currentNodeVersion373921085").setCreateTime("createTime1369213417").setStatusMessage("statusMessage-958704715").setNodeIpv4CidrSize(1181176815).setServicesIpv4Cidr("servicesIpv4Cidr-1785842313").addAllInstanceGroupUrls(new ArrayList<String>()).setCurrentNodeCount(178977560).setExpireTime("expireTime-834724724").setLocation("location1901043637").setEnableTpu(true).setTpuIpv4CidrBlock("tpuIpv4CidrBlock997172251").addAllConditions(new ArrayList<StatusCondition>()).setAutopilot(Autopilot.newBuilder().build()).setId("id3355").setNodePoolDefaults(NodePoolDefaults.newBuilder().build()).setLoggingConfig(LoggingConfig.newBuilder().build()).setMonitoringConfig(MonitoringConfig.newBuilder().build()).build();
    mockClusterManager.addResponse(expectedResponse);
    String projectId = "projectId-894832108";
    String zone = "zone3744684";
    String clusterId = "clusterId561939637";
    Cluster actualResponse = client.getCluster(projectId, zone, clusterId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetClusterRequest actualRequest = ((GetClusterRequest) actualRequests.get(0));
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(zone, actualRequest.getZone());
    Assert.assertEquals(clusterId, actualRequest.getClusterId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetClusterRequest(com.google.container.v1.GetClusterRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) Cluster(com.google.container.v1.Cluster) StatusCondition(com.google.container.v1.StatusCondition) Test(org.junit.Test)

Example 32 with Cluster

use of com.google.container.v1beta1.Cluster in project java-container by googleapis.

the class ClusterManagerClientTest method createClusterExceptionTest.

@Test
public void createClusterExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockClusterManager.addException(exception);
    try {
        String parent = "parent-995424086";
        Cluster cluster = Cluster.newBuilder().build();
        client.createCluster(parent, cluster);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Cluster(com.google.container.v1.Cluster) Test(org.junit.Test)

Example 33 with Cluster

use of com.google.container.v1beta1.Cluster in project java-container by googleapis.

the class ITSystemTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    client = ClusterManagerClient.create();
    Util.cleanUpExistingInstanceCluster(PROJECT_ID, ZONE, client);
    /**
     * create node pool*
     */
    NodePool nodePool = NodePool.newBuilder().setInitialNodeCount(INITIAL_NODE_COUNT).setName(NODE_POOL_NAME).setSelfLink(NODE_POOL_SEL_LINK).setStatusMessage(STATUS_MESSAGE).build();
    /**
     * create cluster
     */
    Cluster cluster = Cluster.newBuilder().setName(CLUSTER_NAME).setLocation("us-central1").setDescription(DETAIL).setSelfLink(SELF_LINK).addNodePools(nodePool).setStatusMessage(STATUS_MESSAGE).setNetwork(NETWORK).build();
    operation = client.createCluster(PROJECT_ID, ZONE, cluster);
    LOG.info(String.format("%s cluster created successfully.", CLUSTER_NAME));
    LOG.info(String.format("%s node pool created successfully.", NODE_POOL_NAME));
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) BeforeClass(org.junit.BeforeClass)

Example 34 with Cluster

use of com.google.container.v1beta1.Cluster in project java-container by googleapis.

the class ITSystemTest method getClusterTest.

@Test
public void getClusterTest() {
    Cluster cluster = client.getCluster(PROJECT_ID, ZONE, CLUSTER_NAME);
    NodePool nodePool = client.getNodePool(PROJECT_ID, ZONE, CLUSTER_NAME, NODE_POOL_NAME);
    assertEquals(CLUSTER_NAME, cluster.getName());
    assertEquals(DETAIL, cluster.getDescription());
    assertEquals(ZONE, cluster.getLocation());
    assertEquals(SELF_LINK, cluster.getSelfLink());
    assertEquals(NETWORK, cluster.getNetwork());
    assertEquals(INITIAL_NODE_COUNT, nodePool.getInitialNodeCount());
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) Test(org.junit.Test)

Example 35 with Cluster

use of com.google.container.v1beta1.Cluster in project java-container by googleapis.

the class ITSystemTest method listClusterTest.

@Test
public void listClusterTest() {
    ListClustersResponse clustersResponse = client.listClusters(PROJECT_ID, ZONE);
    List<Cluster> clusters = clustersResponse.getClustersList();
    NodePool nodePool = client.getNodePool(PROJECT_ID, ZONE, CLUSTER_NAME, NODE_POOL_NAME);
    for (Cluster cluster : clusters) {
        if (CLUSTER_NAME.equals(cluster.getName())) {
            assertEquals(CLUSTER_NAME, cluster.getName());
            assertEquals(DETAIL, cluster.getDescription());
            assertEquals(ZONE, cluster.getLocation());
            assertEquals(SELF_LINK, cluster.getSelfLink());
            assertEquals(NETWORK, cluster.getNetwork());
            assertEquals(INITIAL_NODE_COUNT, nodePool.getInitialNodeCount());
        }
    }
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) ListClustersResponse(com.google.container.v1.ListClustersResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)53 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)25 Cluster (com.google.cloud.dataproc.v1.Cluster)18 AbstractMessage (com.google.protobuf.AbstractMessage)17 Cluster (com.google.bigtable.admin.v2.Cluster)16 ExecutionException (java.util.concurrent.ExecutionException)16 ByteString (com.google.protobuf.ByteString)14 ArrayList (java.util.ArrayList)14 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)13 Cluster (com.google.container.v1.Cluster)12 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)11 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)11 HashMap (java.util.HashMap)11 Operation (com.google.longrunning.Operation)10 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)9 SoftwareConfig (com.google.cloud.dataproc.v1.SoftwareConfig)9 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)8 InstanceGroupConfig (com.google.cloud.dataproc.v1.InstanceGroupConfig)8 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ApiException (com.google.api.gax.rpc.ApiException)6