brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-49) Catalogue should be persisted and used when rebinding
Date Fri, 19 Sep 2014 16:04:33 GMT

    [ https://issues.apache.org/jira/browse/BROOKLYN-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14140795#comment-14140795
] 

ASF GitHub Bot commented on BROOKLYN-49:
----------------------------------------

Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/175#discussion_r17793254
  
    --- 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 --
    
    As well as this test, do we not also need... persist a catalog; then create `origManagementContext`
that disables persisted catalog and removes an item; then create `newManagementContext` that
enables persistence to check that the item was not actually deleted by `origManagementContext`?


> Catalogue should be persisted and used when rebinding
> -----------------------------------------------------
>
>                 Key: BROOKLYN-49
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-49
>             Project: Brooklyn
>          Issue Type: Improvement
>            Reporter: Sam Corbett
>            Assignee: Sam Corbett
>
> Proposal:
> The catalogue, consisting of application templates, entities, policies and 'configuration'
(whose purpose is unknown to me and is unused in general), will be persisted to a `catalog`
directory alongside enrichers, entities, locations, nodes, plane and policies. Location definitions
(that are conceptually linked but are unrelated in code) will be stored too.
> Modes of operation:
> * If persistence if disabled load the default catalogue;
> * If persistence is enabled but there is no persisted catalogue (i.e. the server is running
for the first time) then load the default catalogue;
> * Otherwise load the persisted catalogue. Do _not_ load the default catalogue. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message