brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: MongoDB powershell blueprint for ...
Date Tue, 20 Oct 2015 22:22:01 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/937#discussion_r42562739
  
    --- Diff: software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBWinEc2LiveTest.java
---
    @@ -0,0 +1,138 @@
    +/*
    + * 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 org.apache.brooklyn.entity.nosql.mongodb;
    +
    +import org.apache.brooklyn.api.entity.EntitySpec;
    +import org.apache.brooklyn.api.location.MachineProvisioningLocation;
    +import org.apache.brooklyn.core.entity.Attributes;
    +import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
    +import org.apache.brooklyn.core.entity.Entities;
    +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
    +import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
    +import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
    +import org.apache.brooklyn.core.test.entity.TestApplication;
    +import org.apache.brooklyn.entity.software.base.VanillaWindowsProcess;
    +import org.apache.brooklyn.entity.software.base.test.location.WindowsTestFixture;
    +import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
    +import org.apache.brooklyn.test.EntityTestUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.annotations.AfterClass;
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeClass;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +
    +public class MongoDBWinEc2LiveTest {
    +    private static final Logger LOG = LoggerFactory.getLogger(MongoDBWinEc2LiveTest.class);
    +
    +    protected ManagementContextInternal mgmt;
    +    protected TestApplication app;
    +    protected MachineProvisioningLocation<WinRmMachineLocation> location;
    +    protected WinRmMachineLocation machine;
    +
    +    @BeforeClass(alwaysRun = true)
    +    public void setUpClass() throws Exception {
    +        mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
    +
    +        location = WindowsTestFixture.setUpWindowsLocation(mgmt);
    +        machine = location.obtain(ImmutableMap.of());
    +    }
    +
    +    @AfterClass(alwaysRun = true)
    +    public void tearDownClass() throws Exception {
    +        try {
    +            try {
    +                if (location != null)
    +                    location.release(machine);
    +            } finally {
    +                if (mgmt != null)
    +                    Entities.destroyAll(mgmt);
    +            }
    +        } catch (Throwable t) {
    +            LOG.error("Caught exception in tearDownClass method", t);
    +        } finally {
    +            mgmt = null;
    +        }
    +    }
    +
    +    @BeforeMethod(alwaysRun = true)
    +    public void setUp() throws Exception {
    +        EntitySpec<TestApplication> appSpec = EntitySpec.create(TestApplication.class)
    +                .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true);
    +        app = ApplicationBuilder.newManagedApp(appSpec, mgmt);
    +    }
    +
    +    @AfterMethod(alwaysRun = true)
    +    public void tearDown() throws Exception {
    +        try {
    +            try {
    +                if (app != null)
    +                    Entities.destroy(app);
    +            } catch (Throwable t) {
    +                LOG.error("Caught exception in tearDown method", t);
    +            }
    +        } finally {
    +            app = null;
    +        }
    +    }
    +
    +    @Test(groups = "Live")
    +    public void doTest() {
    +
    +        ImmutableMap<String, String> installTemplates = new ImmutableMap.Builder<String,
String>()
    +                .put("classpath://org/apache/brooklyn/entity/nosql/mongodb/win/install_mongodb.ps1",
"C:\\install_mongodb.ps1")
    +                .put("classpath://org/apache/brooklyn/entity/nosql/mongodb/win/configure_mongodb.ps1",
"C:\\configure_mongodb.ps1")
    +                .put("classpath://org/apache/brooklyn/entity/nosql/mongodb/win/launch_mongodb.ps1",
"C:\\launch_mongodb.ps1")
    +                .put("classpath://org/apache/brooklyn/entity/nosql/mongodb/win/stop_mongodb.ps1",
"C:\\stop_mongodb.ps1")
    +                .put("classpath://org/apache/brooklyn/entity/nosql/mongodb/win/checkrunning_mongodb.ps1",
"C:\\checkrunning_mongodb.ps1")
    +                .build();
    +
    +        VanillaWindowsProcess entity = app.createAndManageChild(EntitySpec.create(VanillaWindowsProcess.class)
    --- End diff --
    
    Feels like we should have been able to just use `mongodb_win.yaml`, rather than re-creating
those contents as a java EntitySpec. To do that, we'd probably have to have put the test in
launcher or some such so that the camp/rest api is accessible.
    
    Happy to leave it as-is for now, but would be good to revisit. It's worth a TODO at the
top of the class to say about the yaml file, and that we'd prefer to use that.
    
    Will merge now anyway.


---
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