brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #468: Added functionality to overwrite private ...
Date Fri, 25 Nov 2016 23:36:38 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/468#discussion_r89640337
  
    --- Diff: locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocationEndpointOverwriteTest.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.jclouds;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.util.List;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.base.Optional;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.ImmutableSet;
    +
    +import org.jclouds.compute.domain.NodeMetadata;
    +import org.jclouds.compute.domain.NodeMetadata.Status;
    +import org.jclouds.compute.domain.NodeMetadataBuilder;
    +import org.jclouds.compute.domain.OsFamily;
    +import org.jclouds.compute.domain.Template;
    +import org.jclouds.domain.LoginCredentials;
    +
    +import org.apache.brooklyn.location.jclouds.StubbedComputeServiceRegistry.AbstractNodeCreator;
    +import org.apache.brooklyn.location.jclouds.StubbedComputeServiceRegistry.NodeCreator;
    +import org.apache.brooklyn.location.ssh.SshMachineLocation;
    +import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
    +import org.apache.brooklyn.util.core.internal.ssh.SshTool;
    +import org.apache.brooklyn.util.core.internal.winrm.WinRmTool;
    +
    +public class JcloudsSshMachineLocationEndpointOverwriteTest extends AbstractJcloudsStubbedUnitTest
{
    +
    +    @SuppressWarnings("unused")
    +    private static final Logger log = LoggerFactory.getLogger(JcloudsImageChoiceStubbedLiveTest.class);
    +    
    +    private List<String> privateAddresses;
    +    private List<String> publicAddresses;
    +
    +    @BeforeMethod(alwaysRun=true)
    +    public void setUp() throws Exception {
    +        super.setUp();
    +        privateAddresses = ImmutableList.of("172.168.10.11");
    +        publicAddresses = ImmutableList.of("173.194.32.123");
    +        initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of(JcloudsLocationConfig.USE_PUBLIC_ENDPOINT_AS_PRIVATE_ENDPOINT.getName(),
true));
    +    }
    +    
    +    protected NodeCreator newNodeCreator() {
    +        return new AbstractNodeCreator() {
    +            @Override protected NodeMetadata newNode(String group, Template template)
{
    +                NodeMetadata result = new NodeMetadataBuilder()
    +                        .id("myid")
    +                        .credentials(LoginCredentials.builder().identity("myuser").credential("mypassword").build())
    +                        .loginPort(22)
    +                        .status(Status.RUNNING)
    +                        .publicAddresses(publicAddresses)
    +                        .privateAddresses(privateAddresses)
    +                        .build();
    +                return result;
    +            }
    +        };
    +    }
    +
    +
    +    @Test
    +    public void testSetPrivateIpToPublicIp() throws Exception {
    +        JcloudsSshMachineLocation machine = obtainMachine(ImmutableMap.of());
    +
    +        assertEquals(machine.getPublicAddresses().size(), 1);
    +        String publicAddress = machine.getPublicAddresses().iterator().next();
    +
    +        assertEquals(machine.getPrivateAddress().get(), publicAddress);
    --- End diff --
    
    Why is this not asserting that the value(s) are equal to the field `publicAddresses`?
That would feel like a stronger assertion - checking that the address was the same as the
public address we injected into the `NodeMetadata`.


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