Search in sources :

Example 1 with TestingParallelAPSPConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.

the class DynamicWritableWrapperTest method testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON.

/*
     * Try to call setter with ObjectName containing transaction name. Verify that
     * ObjectName without transaction name was actually passed on the config bean.
     */
@Test
public void testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON() throws Exception {
    TestingParallelAPSPModuleFactory testingParallelAPSPConfigBeanFactory = new TestingParallelAPSPModuleFactory();
    TestingParallelAPSPModule apspConfigBean = testingParallelAPSPConfigBeanFactory.createModule("", null, null);
    ModuleIdentifier moduleIdentifier2 = new ModuleIdentifier("apsp", "parallel");
    ObjectName dynON2 = ObjectNameUtil.createReadOnlyModuleON(moduleIdentifier2);
    AbstractDynamicWrapper dyn = getDynamicWrapper(apspConfigBean, moduleIdentifier2);
    platformMBeanServer.registerMBean(dyn, dynON2);
    try {
        TestingParallelAPSPConfigMXBean proxy = JMX.newMBeanProxy(platformMBeanServer, dynON2, TestingParallelAPSPConfigMXBean.class);
        ObjectName withTransactionName = ObjectNameUtil.createTransactionModuleON("transaction1", "moduleName", "instanceName");
        proxy.setThreadPool(withTransactionName);
        ObjectName withoutTransactionName = ObjectNameUtil.withoutTransactionName(withTransactionName);
        assertEquals(withoutTransactionName, proxy.getThreadPool());
    } finally {
        platformMBeanServer.unregisterMBean(dynON2);
    }
}
Also used : TestingParallelAPSPModule(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModule) TestingParallelAPSPModuleFactory(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory) ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Example 2 with TestingParallelAPSPConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.

the class TwoInterfacesExportTest method testWithAPSP_useIfcNameMismatch.

@Test
public void testWithAPSP_useIfcNameMismatch() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1");
    TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
    apspProxy.setThreadPool(ObjectNameUtil.createReadOnlyModuleON(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1));
    apspProxy.setSomeParam("someParam");
    transaction.validateConfig();
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Example 3 with TestingParallelAPSPConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.

the class TwoInterfacesExportTest method testWithAPSP_useScheduledNames.

@Test
public void testWithAPSP_useScheduledNames() throws InstanceAlreadyExistsException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName scheduledName = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1");
    TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
    apspProxy.setThreadPool(scheduledName);
    apspProxy.setSomeParam("someParam");
    transaction.validateConfig();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Example 4 with TestingParallelAPSPConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.

the class AbstractParallelAPSPTest method createParallelAPSP.

protected ObjectName createParallelAPSP(final ConfigTransactionJMXClient transaction, final ObjectName threadPoolON) throws InstanceAlreadyExistsException {
    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, apsp1);
    TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
    parallelAPSPConfigProxy.setSomeParam("ahoj");
    parallelAPSPConfigProxy.setThreadPool(threadPoolON);
    return apspName;
}
Also used : ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)

Example 5 with TestingParallelAPSPConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.

the class DependentWiringTest method testDependencies.

@Test
public void testDependencies() throws Exception {
    ObjectName apspON;
    {
        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
        // create fixed1
        ObjectName threadPoolTransactionON = createFixed1(transaction, TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
        // create apsp-parallel
        ObjectName apspNameTransactionON = createParallelAPSP(transaction, threadPoolTransactionON);
        TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction.newMXBeanProxy(apspNameTransactionON, TestingParallelAPSPConfigMXBean.class);
        // trigger validation
        parallelAPSPConfigProxy.setSomeParam("");
        // failure
        try {
            transaction.validateConfig();
            fail();
        } catch (final ValidationException e) {
            for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
                for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
                    assertThat(entry.getValue().getMessage(), containsString("Parameter 'SomeParam' is blank"));
                }
            }
        }
        // try committing (validation fails)
        try {
            transaction.commit();
            fail();
        } catch (final ValidationException e) {
            for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
                for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
                    String err = entry.getValue().getMessage();
                    assertTrue("Unexpected error message: " + err, err.contains("Parameter 'SomeParam' is blank"));
                }
            }
        }
        // fix validation
        parallelAPSPConfigProxy.setSomeParam("abc");
        // failure
        transaction.commit();
        apspON = ObjectNameUtil.withoutTransactionName(apspNameTransactionON);
    }
    // test reported apsp number of threads
    TestingParallelAPSPConfigMXBean parallelAPSPRuntimeProxy = configRegistryClient.newMXBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
    assertEquals((Integer) TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
    // next transaction - recreate new thread pool
    int newNumberOfThreads = TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS * 2;
    {
        // start new transaction
        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
        ObjectName threadPoolNamesNewTx = transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
        TestingFixedThreadPoolConfigMXBean fixedConfigTransactionProxy = transaction.newMXBeanProxy(threadPoolNamesNewTx, TestingFixedThreadPoolConfigMXBean.class);
        fixedConfigTransactionProxy.setThreadCount(newNumberOfThreads);
        transaction.commit();
    }
    // new reference should be copied to apsp-parallel
    assertEquals((Integer) newNumberOfThreads, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ExceptionMessageWithStackTrace(org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace) ValidationException(org.opendaylight.controller.config.api.ValidationException) TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Map(java.util.Map) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Aggregations

ObjectName (javax.management.ObjectName)5 TestingParallelAPSPConfigMXBean (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)5 Test (org.junit.Test)4 ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)3 Map (java.util.Map)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)1 ValidationException (org.opendaylight.controller.config.api.ValidationException)1 ExceptionMessageWithStackTrace (org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace)1 TestingParallelAPSPModule (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModule)1 TestingParallelAPSPModuleFactory (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory)1 TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)1