Search in sources :

Example 16 with Quantity

use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.

the class InitTaskManagerDecoratorTest method testMainContainerResourceRequirements.

@Test
public void testMainContainerResourceRequirements() {
    final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
    final Map<String, Quantity> requests = resourceRequirements.getRequests();
    assertEquals(Double.toString(TASK_MANAGER_CPU), requests.get("cpu").getAmount());
    assertEquals(String.valueOf(TOTAL_PROCESS_MEMORY), requests.get("memory").getAmount());
    final Map<String, Quantity> limits = resourceRequirements.getLimits();
    assertEquals(Double.toString(TASK_MANAGER_CPU * TASK_MANAGER_CPU_LIMIT_FACTOR), limits.get("cpu").getAmount());
    assertEquals(Integer.toString((int) (TOTAL_PROCESS_MEMORY * TASK_MANAGER_MEMORY_LIMIT_FACTOR)), limits.get("memory").getAmount());
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) Test(org.junit.Test)

Example 17 with Quantity

use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.

the class InitTaskManagerDecoratorTest method testExternalResourceInResourceRequirements.

@Test
public void testExternalResourceInResourceRequirements() {
    final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
    final Map<String, Quantity> requests = resourceRequirements.getRequests();
    assertEquals(Long.toString(RESOURCE_AMOUNT), requests.get(RESOURCE_CONFIG_KEY).getAmount());
    final Map<String, Quantity> limits = resourceRequirements.getLimits();
    assertEquals(Long.toString(RESOURCE_AMOUNT), limits.get(RESOURCE_CONFIG_KEY).getAmount());
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) Test(org.junit.Test)

Example 18 with Quantity

use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.

the class InitJobManagerDecoratorTest method testMainContainerResourceRequirements.

@Test
public void testMainContainerResourceRequirements() {
    final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
    final Map<String, Quantity> requests = resourceRequirements.getRequests();
    assertEquals(Double.toString(JOB_MANAGER_CPU), requests.get("cpu").getAmount());
    assertEquals(String.valueOf(JOB_MANAGER_MEMORY), requests.get("memory").getAmount());
    final Map<String, Quantity> limits = resourceRequirements.getLimits();
    assertEquals(Double.toString(JOB_MANAGER_CPU * JOB_MANAGER_CPU_LIMIT_FACTOR), limits.get("cpu").getAmount());
    assertEquals(Integer.toString((int) (JOB_MANAGER_MEMORY * JOB_MANAGER_MEMORY_LIMIT_FACTOR)), limits.get("memory").getAmount());
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) Test(org.junit.Test)

Example 19 with Quantity

use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.

the class DecoratorWithPodTemplateTestBase method testMainContainerResourceRequirementsMerging.

@Test
public void testMainContainerResourceRequirementsMerging() {
    final ResourceRequirements resourceRequirements = this.resultPod.getMainContainer().getResources();
    final Map<String, Quantity> requests = resourceRequirements.getRequests();
    assertThat(requests.get("cpu").getAmount(), is(String.valueOf(RESOURCE_CPU)));
    assertThat(requests.get("memory").getAmount(), is(String.valueOf(RESOURCE_MEMORY)));
    assertThat(requests.get("ephemeral-storage").getAmount(), is("256"));
    final Map<String, Quantity> limits = resourceRequirements.getLimits();
    assertThat(limits.get("cpu").getAmount(), is(String.valueOf(RESOURCE_CPU)));
    assertThat(limits.get("memory").getAmount(), is(String.valueOf(RESOURCE_MEMORY)));
    assertThat(limits.get("ephemeral-storage").getAmount(), is("256"));
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) Test(org.junit.Test)

Example 20 with Quantity

use of io.fabric8.kubernetes.api.model.Quantity in project zalenium by zalando.

the class KubernetesContainerClient method buildResourceMaps.

private void buildResourceMaps() {
    for (Resources resource : Resources.values()) {
        String envValue = environment.getStringEnvVariable(resource.getEnvVar(), null);
        if (StringUtils.isNotBlank(envValue)) {
            Map<String, Quantity> resourceMap = null;
            switch(resource.getResourceType()) {
                case REQUEST:
                    resourceMap = seleniumPodRequests;
                    break;
                case LIMIT:
                    resourceMap = seleniumPodLimits;
                    break;
                default:
                    break;
            }
            if (resourceMap != null) {
                Quantity quantity = new Quantity(envValue);
                resourceMap.put(resource.getRequestType(), quantity);
            }
        }
    }
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity)

Aggregations

Quantity (io.fabric8.kubernetes.api.model.Quantity)20 HashMap (java.util.HashMap)8 Test (org.junit.Test)7 ResourceRequirements (io.fabric8.kubernetes.api.model.ResourceRequirements)6 Map (java.util.Map)6 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)5 Then (io.cucumber.java.en.Then)3 PersistentVolumeClaimBuilder (io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder)3 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)3 Service (io.fabric8.kubernetes.api.model.Service)3 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)3 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)2 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)2 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)2 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)2 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)2 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)2 ServiceSpecBuilder (io.fabric8.kubernetes.api.model.ServiceSpecBuilder)2 VolumeBuilder (io.fabric8.kubernetes.api.model.VolumeBuilder)2