Search in sources :

Example 11 with AppType

use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.

the class MetricsEnquirerTest method oneMBeanOneMetricAdminApp.

@Test
public void oneMBeanOneMetricAdminApp() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
    ObjectName mBeanName = new ObjectName("domain", "key", "value");
    names.add(mBeanName);
    AppType appType = AppType.ADMIN;
    ObjectName objName = new ObjectName("org.glassfish.jersey:type=AdminRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
    when(mBeanServer.queryNames(objName, null)).thenReturn(names);
    String attributeName = "name_total";
    MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false) };
    MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
    when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
    when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
    List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
    assertThat(metrics.size()).isEqualTo(1);
    assertThat(metrics.get(0).getName()).isEqualTo("name_total");
}
Also used : AppType(com.quorum.tessera.config.AppType) Test(org.junit.Test)

Example 12 with AppType

use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.

the class MetricsEnquirerTest method metricNameDoesNotEndWithTotalSoIsNotIncluded.

@Test
public void metricNameDoesNotEndWithTotalSoIsNotIncluded() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
    ObjectName mBeanName = new ObjectName("domain", "key", "value");
    names.add(mBeanName);
    AppType appType = AppType.P2P;
    ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.api.*,executionTimes=RequestTimes,detail=methods,method=*");
    when(mBeanServer.queryNames(objName, null)).thenReturn(names);
    String attributeName = "name";
    MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false) };
    MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
    when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
    when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
    List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
    assertThat(metrics.size()).isEqualTo(0);
}
Also used : AppType(com.quorum.tessera.config.AppType) Test(org.junit.Test)

Example 13 with AppType

use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.

the class MetricsEnquirerTest method multipleMBeansOneMetricEach.

@Test
public void multipleMBeansOneMetricEach() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
    ObjectName mBeanName1 = new ObjectName("domain1", "key1", "value1");
    ObjectName mBeanName2 = new ObjectName("domain2", "key2", "value2");
    names.add(mBeanName1);
    names.add(mBeanName2);
    AppType appType = AppType.P2P;
    ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
    when(mBeanServer.queryNames(objName, null)).thenReturn(names);
    String attributeName1 = "name_total";
    String attributeName2 = "name2_total";
    MBeanAttributeInfo[] mBeanAttributes1 = { new MBeanAttributeInfo(attributeName1, "type", "desc", true, false, false) };
    MBeanAttributeInfo[] mBeanAttributes2 = { new MBeanAttributeInfo(attributeName2, "type", "desc", true, false, false) };
    MBeanInfo mBeanInfo1 = new MBeanInfo(null, null, mBeanAttributes1, null, null, null);
    MBeanInfo mBeanInfo2 = new MBeanInfo(null, null, mBeanAttributes2, null, null, null);
    when(mBeanServer.getMBeanInfo(mBeanName1)).thenReturn(mBeanInfo1);
    when(mBeanServer.getMBeanInfo(mBeanName2)).thenReturn(mBeanInfo2);
    when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
    List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
    assertThat(metrics.size()).isEqualTo(2);
    assertThat(metrics.get(0).getName()).isEqualTo("name2_total");
    assertThat(metrics.get(1).getName()).isEqualTo("name_total");
}
Also used : AppType(com.quorum.tessera.config.AppType) Test(org.junit.Test)

Example 14 with AppType

use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.

the class MetricsEnquirerTest method multipleMBeansSomeMetricsNotAddedAsDoNotEndWithTotal.

@Test
public void multipleMBeansSomeMetricsNotAddedAsDoNotEndWithTotal() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
    ObjectName mBeanName1 = new ObjectName("domain1", "key1", "value1");
    ObjectName mBeanName2 = new ObjectName("domain2", "key2", "value2");
    names.add(mBeanName1);
    names.add(mBeanName2);
    AppType appType = AppType.P2P;
    ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
    when(mBeanServer.queryNames(objName, null)).thenReturn(names);
    String attributeName1 = "name_total";
    String attributeName2 = "name2";
    String attributeName3 = "name3_total";
    MBeanAttributeInfo[] mBeanAttributes1 = { new MBeanAttributeInfo(attributeName1, "type", "desc", true, false, false) };
    MBeanAttributeInfo[] mBeanAttributes2 = { new MBeanAttributeInfo(attributeName2, "type", "desc", true, false, false), new MBeanAttributeInfo(attributeName3, "type", "desc", true, false, false) };
    MBeanInfo mBeanInfo1 = new MBeanInfo(null, null, mBeanAttributes1, null, null, null);
    MBeanInfo mBeanInfo2 = new MBeanInfo(null, null, mBeanAttributes2, null, null, null);
    when(mBeanServer.getMBeanInfo(mBeanName1)).thenReturn(mBeanInfo1);
    when(mBeanServer.getMBeanInfo(mBeanName2)).thenReturn(mBeanInfo2);
    when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
    List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
    assertThat(metrics.size()).isEqualTo(2);
    assertThat(metrics.get(0).getName()).isEqualTo("name3_total");
    assertThat(metrics.get(1).getName()).isEqualTo("name_total");
}
Also used : AppType(com.quorum.tessera.config.AppType) Test(org.junit.Test)

Example 15 with AppType

use of com.quorum.tessera.config.AppType in project tessera by ConsenSys.

the class MetricsEnquirerTest method oneMBeanMultipleMetricsSomeNotAddedAsDoNotEndWithTotal.

@Test
public void oneMBeanMultipleMetricsSomeNotAddedAsDoNotEndWithTotal() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException {
    ObjectName mBeanName = new ObjectName("domain", "key", "value");
    names.add(mBeanName);
    AppType appType = AppType.P2P;
    ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*");
    when(mBeanServer.queryNames(objName, null)).thenReturn(names);
    String attributeName = "name_total";
    String attributeName2 = "name2";
    String attributeName3 = "name3_total";
    MBeanAttributeInfo[] mBeanAttributes = { new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false), new MBeanAttributeInfo(attributeName2, "type", "desc", true, false, false), new MBeanAttributeInfo(attributeName3, "type", "desc", true, false, false) };
    MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null);
    when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo);
    when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1);
    List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType);
    assertThat(metrics.size()).isEqualTo(2);
    assertThat(metrics.get(0).getName()).isEqualTo("name_total");
    assertThat(metrics.get(1).getName()).isEqualTo("name3_total");
}
Also used : AppType(com.quorum.tessera.config.AppType) Test(org.junit.Test)

Aggregations

AppType (com.quorum.tessera.config.AppType)18 Test (org.junit.Test)16 ServerConfig (com.quorum.tessera.config.ServerConfig)1 ConstraintValidatorContext (jakarta.validation.ConstraintValidatorContext)1 GET (jakarta.ws.rs.GET)1 Produces (jakarta.ws.rs.Produces)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 Before (org.junit.Before)1