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

    https://github.com/apache/incubator-brooklyn/pull/1082#discussion_r46522492
  
    --- Diff: 
locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/RebindJcloudsLocationLiveTest.java
 ---
    @@ -94,6 +101,100 @@ public void testRebindsToJcloudsMachine() throws 
Exception {
             assertJcloudsLocationEquals(newJcloudsLoction, 
origJcloudsLocation);
         }
     
    +    // TODO In jclouds-azure, the AzureComputeTemplateOptions fields 
changed, which meant old 
    +    // persisted state could not be deserialized. These files are examples 
of the old format.
    +    @Test(groups={"Live", "WIP"}, enabled=false)
    +    public void testRebindsToJcloudsMachineWithInvalidTemplate() throws 
Exception {
    +        ResourceUtils resourceUtils = ResourceUtils.create(this);
    +        FileUtils.write(
    +                new File(mementoDir, "locations/briByOel"),
    +                
resourceUtils.getResourceAsString("classpath://org/apache/brooklyn/location/jclouds/persisted-azure-parent-briByOel"));
    +        FileUtils.write(
    +                new File(mementoDir, "locations/VNapYjwp"),
    +                
resourceUtils.getResourceAsString("classpath://org/apache/brooklyn/location/jclouds/persisted-azure-machine-VNapYjwp"));
    +        
    +        TestApplication newApp = rebind();
    +        
    +        JcloudsLocation loc = (JcloudsLocation) 
newApp.getManagementContext().getLocationManager().getLocation("briByOel");
    +        JcloudsSshMachineLocation machine = (JcloudsSshMachineLocation) 
newApp.getManagementContext().getLocationManager().getLocation("VNapYjwp");
    +        assertEquals(ImmutableSet.of(loc.getChildren()), 
ImmutableSet.of(machine));
    +    }
    +
    +    @Test(groups="Live")
    +    public void testRebindsToJcloudsMachineWithTemplateAndNode() throws 
Exception {
    +        // Populate the mementoDir with some old-style peristed state
    +        ResourceUtils resourceUtils = ResourceUtils.create(this);
    +        String origParentXml = 
resourceUtils.getResourceAsString("classpath://org/apache/brooklyn/location/jclouds/persisted-aws-parent-lCYB3mTb");
    +        String origMachineXml = 
resourceUtils.getResourceAsString("classpath://org/apache/brooklyn/location/jclouds/persisted-aws-machine-aKEcbxKN");
    +        File persistedParentFile = new File(mementoDir, 
"locations/lCYB3mTb");
    +        File persistedMachineFile = new File(mementoDir, 
"locations/aKEcbxKN");
    +        FileUtils.write(
    +                persistedParentFile,
    +                origParentXml);
    +        FileUtils.write(
    +                persistedMachineFile,
    +                origMachineXml);
    +
    +        assertTrue(origMachineXml.contains("AWSEC2TemplateOptions"), 
origMachineXml);
    +        assertTrue(origMachineXml.contains("NodeMetadataImpl"), 
origMachineXml);
    +
    +        // Rebind to the old-style persisted state, which includes the 
NodeMetadata and the Template objects.
    +        // Expect to parse that ok.
    +        TestApplication app2 = rebind();
    +        
    +        JcloudsLocation loc2 = (JcloudsLocation) 
app2.getManagementContext().getLocationManager().getLocation("lCYB3mTb");
    +        JcloudsSshMachineLocation machine2 = (JcloudsSshMachineLocation) 
app2.getManagementContext().getLocationManager().getLocation("aKEcbxKN");
    +        assertEquals(ImmutableSet.copyOf(loc2.getChildren()), 
ImmutableSet.of(machine2));
    +        
    +        String errmsg = "loc="+loc2.toVerboseString()+"; 
machine="+machine2.toVerboseString();
    +        assertEquals(machine2.getId(), "aKEcbxKN", errmsg);
    +        assertEquals(machine2.getJcloudsId(), "ap-southeast-1/i-56fd53f2", 
errmsg);
    +        assertEquals(machine2.getSshHostAndPort(), 
HostAndPort.fromParts("ec2-54-254-23-53.ap-southeast-1.compute.amazonaws.com", 
22), errmsg);
    +        assertEquals(machine2.getPrivateAddresses(), 
ImmutableSet.of("10.144.66.5"), errmsg);
    +        assertEquals(machine2.getPublicAddresses(), 
ImmutableSet.of("54.254.23.53"), errmsg);
    +        assertEquals(machine2.getPrivateAddress(), 
Optional.of("10.144.66.5"), errmsg);
    +        assertEquals(machine2.getHostname(), "ip-10-144-66-5", errmsg); // 
TODO would prefer the hostname that works inside and out
    +        assertEquals(machine2.getOsDetails().isWindows(), false, errmsg);
    +        assertEquals(machine2.getOsDetails().isLinux(), true, errmsg);
    +        assertEquals(machine2.getOsDetails().isMac(), false, errmsg);
    +        assertEquals(machine2.getOsDetails().getName(), "centos", errmsg);
    +        assertEquals(machine2.getOsDetails().getArch(), "x86_64", errmsg);
    +        assertEquals(machine2.getOsDetails().getVersion(), "6.5", errmsg);
    +        assertEquals(machine2.getOsDetails().is64bit(), true, errmsg);
    +
    +        // Force it to be persisted again. Expect to pesist without the 
NodeMetadata and Tempalte.
    --- End diff --
    
    typo `Tempalte`


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to