Search in sources :

Example 1 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class MultipleDependenciesModuleTest method testCloseOrdering.

@Test
public void testCloseOrdering() throws Exception {
    // Tests whether close is called in correct order on the module instances on following graph
    // Each module tests whether its dependencies were closed before it (to simulate resource clean up failure)
    // R1
    // | \
    // M1 M2
    // |
    // L1
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1");
    ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1");
    ObjectName m2 = transaction.createModule(factory.getImplementationName(), "middle2");
    ObjectName l1 = transaction.createModule(factory.getImplementationName(), "leaf1");
    MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class);
    MultipleDependenciesModuleMXBean i1Proxy = transaction.newMXBeanProxy(m1, MultipleDependenciesModuleMXBean.class);
    r1Proxy.setSingle(m1);
    i1Proxy.setSingle(l1);
    r1Proxy.setTestingDeps(asList(m2));
    transaction.commit();
    configRegistryClient.createTransaction().commit();
    transaction = configRegistryClient.createTransaction();
    MultipleDependenciesModuleMXBean l1Proxy = transaction.newMXBeanProxy(l1, MultipleDependenciesModuleMXBean.class);
    l1Proxy.setSimple(true);
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 2 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class MultipleDependenciesModuleTest method testMultipleDependencies.

@Test
public void testMultipleDependencies() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName d1 = transaction.createModule(factory.getImplementationName(), "d1");
    ObjectName d2 = transaction.createModule(factory.getImplementationName(), "d2");
    assertEquals(transaction.getTransactionName(), getTransactionName(d1));
    ObjectName parent = transaction.createModule(factory.getImplementationName(), "parent");
    MultipleDependenciesModuleMXBean multipleDependenciesModuleMXBean = transaction.newMXBeanProxy(parent, MultipleDependenciesModuleMXBean.class);
    multipleDependenciesModuleMXBean.setTestingDeps(asList(d1, d2));
    List<ObjectName> found = multipleDependenciesModuleMXBean.getTestingDeps();
    ObjectName d1WithoutTxName = found.get(0);
    assertEquals(getInstanceName(d1), getInstanceName(d1WithoutTxName));
    // check that transaction name gets stripped automatically from attribute.
    // d1,2 contained tx name, found doesn't
    assertNull(getTransactionName(d1WithoutTxName));
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 3 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class NetconfTestImplModuleTest method testIdentities.

@Test
public void testIdentities() throws Exception {
    final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
    final ObjectName nameCreated = transaction.createModule(IdentityTestModuleFactory.NAME, this.instanceName);
    final IdentityTestModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, IdentityTestModuleMXBean.class);
    final IdentitiesContainer c = new IdentitiesContainer();
    c.setAfi(new IdentityAttributeRef(TestIdentity2.QNAME.toString()));
    mxBean.setIdentitiesContainer(c);
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) IdentityAttributeRef(org.opendaylight.controller.config.api.IdentityAttributeRef) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 4 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class NetconfTestImplModuleTest method testDependencyList.

@Test
public void testDependencyList() throws Exception {
    ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
    final ObjectName on = createInstance(transaction, this.instanceName, 4);
    transaction.validateConfig();
    final CommitStatus status1 = transaction.commit();
    assertBeanCount(1, this.factory.getImplementationName());
    assertBeanCount(4 + 1, DepTestImplModuleFactory.NAME);
    assertStatus(status1, 1 + 4 + 1, 0, 0);
    transaction = this.configRegistryClient.createTransaction();
    final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(ObjectNameUtil.withoutTransactionName(on), NetconfTestImplModuleMXBean.class);
    proxy.getComplexList();
    final List<ObjectName> testingDeps = proxy.getTestingDeps();
    final ObjectName testingDep = proxy.getTestingDep();
    assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep));
    assertTestingDeps(testingDeps, 4);
    transaction.abortConfig();
    // check that reuse logic works - equals on list of dependencies.
    transaction = this.configRegistryClient.createTransaction();
    final CommitStatus status2 = transaction.commit();
    assertStatus(status2, 0, 0, 6);
    // replace single dependency
    transaction = this.configRegistryClient.createTransaction();
    final String instanceName1 = TESTING_DEP_PREFIX + 1;
    transaction.destroyModule(DepTestImplModuleFactory.NAME, instanceName1);
    transaction.createModule(DepTestImplModuleFactory.NAME, instanceName1);
    final CommitStatus status3 = transaction.commit();
    assertStatus(status3, 1, 1, 4);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 5 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class ShutdownTest method testSingleton_invalidName.

@Test
public void testSingleton_invalidName() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    try {
        transaction.createModule(NAME, "foo");
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Singleton enforcement failed. Expected instance name shutdown", e.getMessage());
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Aggregations

ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)43 Test (org.junit.Test)38 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)26 ObjectName (javax.management.ObjectName)22 CommitStatus (org.opendaylight.controller.config.api.jmx.CommitStatus)15 TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 TestingParallelAPSPConfigMXBean (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)3 Map (java.util.Map)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ConflictingVersionException (org.opendaylight.controller.config.api.ConflictingVersionException)2 ValidationException (org.opendaylight.controller.config.api.ValidationException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Attribute (javax.management.Attribute)1 IntrospectionException (javax.management.IntrospectionException)1 ReflectionException (javax.management.ReflectionException)1 Before (org.junit.Before)1 IdentityAttributeRef (org.opendaylight.controller.config.api.IdentityAttributeRef)1 ExceptionMessageWithStackTrace (org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace)1