You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by bostko <gi...@git.apache.org> on 2017/01/03 08:38:45 UTC

[GitHub] brooklyn-server pull request #491: (WIP) execAsync parameter for SshMachineL...

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

    https://github.com/apache/brooklyn-server/pull/491#discussion_r94371054
  
    --- Diff: core/src/test/java/org/apache/brooklyn/location/ssh/SshjExecAsyncInSshMachineLocationIntegrationTest.java ---
    @@ -0,0 +1,93 @@
    +/*
    + * 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.location.ssh;
    +
    +import com.google.common.collect.ImmutableMap;
    +import org.apache.brooklyn.api.location.NoMachinesAvailableException;
    +import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
    +import org.apache.brooklyn.util.core.internal.ssh.sshj.SshjTool;
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.testng.Assert;
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.atomic.AtomicInteger;
    +
    +import static org.apache.brooklyn.util.core.internal.ssh.ShellTool.PROP_EXEC_ASYNC;
    +import static org.apache.brooklyn.util.core.internal.ssh.SshTool.BROOKLYN_CONFIG_KEY_PREFIX;
    +
    +@Test(groups = "WIP")
    +public class SshjExecAsyncInSshMachineLocationIntegrationTest extends SshMachineLocationIntegrationTest {
    +    public static class RecordingSshjTool extends SshjTool {
    +        public static final AtomicInteger execCount = new AtomicInteger(0);
    +
    +        public RecordingSshjTool(Map<String, ?> map) {
    +            super(map);
    +        }
    +
    +        @Override
    +        protected int execScriptAsyncAndPoll(final Map<String,?> props, final List<String> commands, final Map<String,?> env) {
    +            try {
    +                return super.execScriptAsyncAndPoll(props, commands, env);
    +            } finally {
    +                execCount.incrementAndGet();
    +            }
    +        }
    +    }
    +    @Override
    +    protected SshMachineLocation newHost() {
    +        LocalhostMachineProvisioningLocation localhostMachineProvisioningLocation = (LocalhostMachineProvisioningLocation) mgmt.getLocationRegistry().getLocationManaged("localhost");
    +        localhostMachineProvisioningLocation.config().putAll(ImmutableMap.of(BROOKLYN_CONFIG_KEY_PREFIX + PROP_EXEC_ASYNC.getName(), true));
    +        localhostMachineProvisioningLocation.config().set(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshjTool.class.getName());
    +        try {
    +            return localhostMachineProvisioningLocation.obtain();
    +        } catch (NoMachinesAvailableException e) {
    +            throw Exceptions.propagate(e);
    +        }
    +    }
    +
    +    @BeforeMethod(alwaysRun=true)
    +    public void setUp() throws Exception {
    +        super.setUp();
    +    }
    +
    +    // TODO fix failing test
    +    @Test(groups = "Integration")
    +    @Override
    +    public void testSshExecScript() throws Exception {
    +        super.testSshExecScript();
    --- End diff --
    
    I'd like to ask for help on that failing test.


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