brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorbett <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: BROOKLYN-49: Catalogue persistenc...
Date Mon, 22 Sep 2014 15:39:01 GMT
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/175#discussion_r17857023
  
    --- Diff: core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java
---
    @@ -0,0 +1,94 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package brooklyn.entity.rebind;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.collect.Iterables;
    +
    +import brooklyn.camp.lite.CampPlatformWithJustBrooklynMgmt;
    +import brooklyn.catalog.CatalogItem;
    +import brooklyn.config.BrooklynProperties;
    +import brooklyn.config.BrooklynServerConfig;
    +import brooklyn.entity.proxying.EntitySpec;
    +import brooklyn.internal.BrooklynFeatureEnablement;
    +import brooklyn.management.internal.LocalManagementContext;
    +import brooklyn.test.entity.TestEntity;
    +
    +public class RebindCatalogWhenCatalogPersistenceDisabledTest extends RebindTestFixtureWithApp
{
    +
    +    private static final String TEST_CATALOG = "classpath://brooklyn/entity/rebind/rebind-catalog-item-test-catalog.xml";
    +    private boolean catalogPersistenceWasPreviouslyEnabled;
    +
    +    @BeforeMethod
    +    @Override
    +    public void setUp() throws Exception {
    +        catalogPersistenceWasPreviouslyEnabled = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_CATALOG_PERSISTENCE_PROPERTY);
    +        BrooklynFeatureEnablement.disable(BrooklynFeatureEnablement.FEATURE_CATALOG_PERSISTENCE_PROPERTY);
    +        super.setUp();
    +        new CampPlatformWithJustBrooklynMgmt(origManagementContext);
    +        origApp.createAndManageChild(EntitySpec.create(TestEntity.class));
    +    }
    +
    +    @AfterMethod
    +    @Override
    +    public void tearDown() throws Exception {
    +        super.tearDown();
    +        BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_CATALOG_PERSISTENCE_PROPERTY,
catalogPersistenceWasPreviouslyEnabled);
    +    }
    +
    +    @Override
    +    protected LocalManagementContext createOrigManagementContext() {
    +        BrooklynProperties properties = BrooklynProperties.Factory.newDefault();
    +        properties.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL, TEST_CATALOG);
    +        return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
    +                .properties(properties)
    +                .persistPeriodMillis(getPersistPeriodMillis())
    +                .forLive(useLiveManagementContext())
    +                .buildStarted();
    +    }
    +
    +    @Override
    +    protected LocalManagementContext createNewManagementContext() {
    +        BrooklynProperties properties = BrooklynProperties.Factory.newDefault();
    +        properties.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL, TEST_CATALOG);
    +        return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
    +                .properties(properties)
    +                .forLive(useLiveManagementContext())
    +                .buildUnstarted();
    +    }
    +
    +    @Test
    +    public void testModificationsToCatalogAreNotPersistedWhenCatalogPersistenceFeatureIsDisabled()
throws Exception {
    +        assertEquals(Iterables.size(origManagementContext.getCatalog().getCatalogItems()),
1);
    +        CatalogItem<Object, Object> toRemove = Iterables.getOnlyElement(origManagementContext.getCatalog().getCatalogItems());
    +        origManagementContext.getCatalog().deleteCatalogItem(toRemove.getId());
    +        assertEquals(Iterables.size(origManagementContext.getCatalog().getCatalogItems()),
0);
    +
    +        rebind();
    +
    +        assertEquals(Iterables.size(newManagementContext.getCatalog().getCatalogItems()),
1);
    --- End diff --
    
    So the second `origManagementContext` rebinds to the previously persisted state but does
not persist any modifications? That configuration is not possible at the moment. Should it
be?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message