Search in sources :

Example 1 with ResourceQuotas

use of com.yahoo.pulsar.client.admin.ResourceQuotas in project pulsar by yahoo.

the class PulsarAdminToolTest method resourceQuotas.

@Test
void resourceQuotas() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    ResourceQuotas mockResourceQuotas = mock(ResourceQuotas.class);
    when(admin.resourceQuotas()).thenReturn(mockResourceQuotas);
    CmdResourceQuotas cmdResourceQuotas = new CmdResourceQuotas(admin);
    ResourceQuota quota = new ResourceQuota();
    quota.setMsgRateIn(10);
    quota.setMsgRateOut(20);
    quota.setBandwidthIn(10000);
    quota.setBandwidthOut(20000);
    quota.setMemory(100);
    quota.setDynamic(false);
    cmdResourceQuotas.run(split("get"));
    verify(mockResourceQuotas).getDefaultResourceQuota();
    cmdResourceQuotas.run(split("set -mi 10 -mo 20 -bi 10000 -bo 20000 -mem 100"));
    verify(mockResourceQuotas).setDefaultResourceQuota(quota);
    // reset mocks
    mockResourceQuotas = mock(ResourceQuotas.class);
    when(admin.resourceQuotas()).thenReturn(mockResourceQuotas);
    cmdResourceQuotas = new CmdResourceQuotas(admin);
    cmdResourceQuotas.run(split("get --namespace myprop/clust/ns1 --bundle 0x80000000_0xffffffff"));
    verify(mockResourceQuotas).getNamespaceBundleResourceQuota("myprop/clust/ns1", "0x80000000_0xffffffff");
    cmdResourceQuotas.run(split("set --namespace myprop/clust/ns1 --bundle 0x80000000_0xffffffff -mi 10 -mo 20 -bi 10000 -bo 20000 -mem 100"));
    verify(mockResourceQuotas).setNamespaceBundleResourceQuota("myprop/clust/ns1", "0x80000000_0xffffffff", quota);
    cmdResourceQuotas.run(split("reset-namespace-bundle-quota --namespace myprop/clust/ns1 --bundle 0x80000000_0xffffffff"));
    verify(mockResourceQuotas).resetNamespaceBundleResourceQuota("myprop/clust/ns1", "0x80000000_0xffffffff");
}
Also used : PulsarAdmin(com.yahoo.pulsar.client.admin.PulsarAdmin) ResourceQuota(com.yahoo.pulsar.common.policies.data.ResourceQuota) ResourceQuotas(com.yahoo.pulsar.client.admin.ResourceQuotas) Test(org.testng.annotations.Test)

Aggregations

PulsarAdmin (com.yahoo.pulsar.client.admin.PulsarAdmin)1 ResourceQuotas (com.yahoo.pulsar.client.admin.ResourceQuotas)1 ResourceQuota (com.yahoo.pulsar.common.policies.data.ResourceQuota)1 Test (org.testng.annotations.Test)1