[
https://issues.apache.org/jira/browse/BROOKLYN-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15276530#comment-15276530
]
ASF GitHub Bot commented on BROOKLYN-259:
-----------------------------------------
Github user johnmccabe commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/132#discussion_r62522025
--- Diff:
locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverStubbedTest.java
---
@@ -0,0 +1,157 @@
+/*
+ * 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.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.LoginCredentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+public class JcloudsByonLocationResolverStubbedTest extends
AbstractJcloudsStubbedLiveTest {
+
+ @SuppressWarnings("unused")
+ private static final Logger log =
LoggerFactory.getLogger(JcloudsByonLocationResolverStubbedTest.class);
+
+ private final String nodeId = "mynodeid";
+ private final String nodePublicAddress = "173.194.32.123";
+ private final String nodePrivateAddress = "172.168.10.11";
+
+ protected LocalManagementContext newManagementContext() {
+ // This really is stubbed; no live access to the cloud
+ LocalManagementContext result =
LocalManagementContextForTests.builder(true).build();
+ BrooklynProperties brooklynProperties =
result.getBrooklynProperties();
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".identity",
"myidentity");
+
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".credential",
"mycredential");
+ return result;
+
+ }
+
+ @Override
+ protected NodeCreator newNodeCreator() {
+ return new NodeCreator() {
+ @Override
+ public Set<? extends NodeMetadata>
listNodesDetailsMatching(Predicate<ComputeMetadata> filter) {
+ NodeMetadata result = new NodeMetadataBuilder()
+ .id(nodeId)
+
.credentials(LoginCredentials.builder().identity("dummy").credential("dummy").build())
+ .loginPort(22)
+ .status(Status.RUNNING)
+
.publicAddresses(ImmutableList.of(nodePublicAddress))
+
.privateAddresses(ImmutableList.of(nodePrivateAddress))
+ .build();
+ return
ImmutableSet.copyOf(Iterables.filter(ImmutableList.of(result), filter));
+ }
+ @Override
+ protected NodeMetadata newNode(String group, Template
template) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Test
+ public void testResolvesHostInSpec() throws Exception {
+ String spec =
"jcloudsByon:(provider=\""+SOFTLAYER_PROVIDER+"\",region=\""+SOFTLAYER_AMS01_REGION_NAME+"\",user=\"myuser\",password=\"mypassword\",hosts=\""+nodeId+"\")";
+ Map<?,?> specFlags =
ImmutableMap.of(JcloudsLocationConfig.COMPUTE_SERVICE_REGISTRY,
computeServiceRegistry);
+
+ FixedListMachineProvisioningLocation<MachineLocation> location =
getLocationManaged(spec, specFlags);
+
+ JcloudsSshMachineLocation machine = (JcloudsSshMachineLocation)
Iterables.getOnlyElement(location.getAllMachines());
+ assertEquals(machine.getJcloudsId(), nodeId);
+ assertEquals(machine.getPublicAddresses(),
ImmutableSet.of(nodePublicAddress));
+ assertEquals(machine.getPrivateAddresses(),
ImmutableSet.of(nodePrivateAddress));
+
+ // TODO what user/password should we expect? Fails below because
has "dummy":
+// assertEquals(machine.getUser(), "myuser");
--- End diff --
This is whats throwing the NPE mentioned earlier, previously it was these
user/password values that were being used.
> jcloudsByon location spec leaks location instances
> --------------------------------------------------
>
> Key: BROOKLYN-259
> URL: https://issues.apache.org/jira/browse/BROOKLYN-259
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Aled Sage
> Fix For: 0.10.0
>
>
> When declaring in brooklyn.properties a location spec such as
> {noformat}
> jcloudsByon(provider="aws-ec2",region="us-east-1",user="brooklyn",password="pa55w0rd",hosts="i-12345678")
> {noformat}
> It caused new locations to be created and persisted every few seconds, but
> for those locations to be never deleted.
> ---
> This was caused by changes made in 0.9.0 to {{LocationResolver}}
> implementations, so that it creates a {{LocationSpec}} rather than
> instantiating a location directly. Unfortunately,
> {{JcloudsByonLocationResolver}} had not been updated. The REST api would poll
> this regularly to find out about the types of location, and on every poll it
> would create new locations.
> This is similar to the problem encountered for localhost, fixed in time for
> 0.9.0 in https://github.com/apache/brooklyn-server/pull/97.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)