You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/27 17:36:38 UTC
[2/9] JCLOUDS-758 Drop VirtualBox labs provider.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToVmSpecTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToVmSpecTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToVmSpecTest.java
deleted file mode 100644
index 606e29b..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToVmSpecTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions;
-
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.IsoImage;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.DeviceType;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IMedium;
-import org.virtualbox_4_2.IMediumAttachment;
-import org.virtualbox_4_2.IStorageController;
-import org.virtualbox_4_2.StorageBus;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.collect.Lists;
-
-@Test(groups = "unit")
-public class IMachineToVmSpecTest {
-
- private static final String PATH_TO_DVD = "/path/to/dvd";
- private static final String PATH_TO_HD = "/path/to/hd";
- private static final StorageBus CONTROLLER_BUS = StorageBus.IDE;
- private static final long MEMORY_SIZE = 512L;
- private static final String OS_TYPE_ID = "ubuntu";
- private static final String VM_NAME = "test";
- private static final String CONTROLLER_NAME = "IDE Controller";
- private static final String VM_ID = "test";
-
- @Test
- public void testConvert() throws Exception {
-
- VirtualBoxManager vbm = createNiceMock(VirtualBoxManager.class);
- IStorageController iStorageController = createNiceMock(IStorageController.class);
- IMediumAttachment iMediumAttachment = createNiceMock(IMediumAttachment.class);
- IMedium hd = createNiceMock(IMedium.class);
- IMedium dvd = createNiceMock(IMedium.class);
- IMachine vm = createNiceMock(IMachine.class);
-
- expect(vm.getStorageControllers()).andReturn(Lists.newArrayList(iStorageController)).anyTimes();
- expect(iStorageController.getName()).andReturn(CONTROLLER_NAME).anyTimes();
- expect(iStorageController.getBus()).andReturn(CONTROLLER_BUS).anyTimes();
- expect(vm.getMediumAttachmentsOfController(CONTROLLER_NAME)).andReturn(Lists.newArrayList(iMediumAttachment)).anyTimes();
- expect(iMediumAttachment.getPort()).andReturn(0).once();
- expect(iMediumAttachment.getDevice()).andReturn(0).once();
-
- expect(iMediumAttachment.getMedium()).andReturn(hd);
- expect(hd.getDeviceType()).andReturn(DeviceType.HardDisk).once();
- expect(hd.getLocation()).andReturn(PATH_TO_HD).once();
-
- expect(iMediumAttachment.getMedium()).andReturn(dvd);
- expect(dvd.getDeviceType()).andReturn(DeviceType.DVD).once();
- expect(dvd.getLocation()).andReturn(PATH_TO_DVD).once();
-
- expect(vm.getName()).andReturn(VM_NAME).anyTimes();
- expect(vm.getId()).andReturn(VM_ID).anyTimes();
- expect(vm.getOSTypeId()).andReturn(OS_TYPE_ID).anyTimes();
- expect(vm.getMemorySize()).andReturn(MEMORY_SIZE).anyTimes();
-
- replay(vbm, iStorageController, iMediumAttachment, hd, dvd, vm);
-
- VmSpec vmSpec = new IMachineToVmSpec().apply(vm);
-
- assertEquals(vmSpec.getVmName(), VM_NAME);
- assertEquals(vmSpec.getVmId(), VM_ID);
- assertEquals(vmSpec.getMemory(), MEMORY_SIZE);
- for (StorageController controller : vmSpec.getControllers()) {
- assertEquals(controller.getName(), CONTROLLER_NAME);
- assertEquals(controller.getBus(), CONTROLLER_BUS);
- for (HardDisk hardDisk : controller.getHardDisks()) {
- assertEquals(hardDisk.getDiskPath(), PATH_TO_HD);
- }
- for (IsoImage iso : controller.getIsoImages()) {
- assertEquals(iso.getSourcePath(), PATH_TO_DVD);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/LaunchMachineIfNotAlreadyRunningTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/LaunchMachineIfNotAlreadyRunningTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/LaunchMachineIfNotAlreadyRunningTest.java
deleted file mode 100644
index 456a3af..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/LaunchMachineIfNotAlreadyRunningTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import org.jclouds.virtualbox.domain.ExecutionType;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IProgress;
-import org.virtualbox_4_2.ISession;
-import org.virtualbox_4_2.SessionState;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-@Test(groups = "unit", testName = "LaunchMachineIfNotAlreadyRunningTest")
-public class LaunchMachineIfNotAlreadyRunningTest {
-
- @Test
- public void testDoNotLaunchIfAlreadyRunning() throws Exception {
-
- }
-
- // VirtualBox error: The given session is busy (0x80BB0007)
- // VirtualBox error: The machine
- // 'jclouds-image-virtualbox-iso-to-machine-test' is not registered
- // (0x8000FFFF)
-
- @Test
- public void testLaunchIfNotStarted() throws Exception {
-
- final String type = "gui";
- final String environment = "";
- ISession session = createMock(ISession.class);
- VirtualBoxManager manager = createMock(VirtualBoxManager.class);
- IMachine machine = createMock(IMachine.class);
- IProgress progress = createMock(IProgress.class);
-
- expect(manager.getSessionObject()).andReturn(session).anyTimes();
- expect(machine.launchVMProcess(session, type, environment)).andReturn(progress);
- progress.waitForCompletion(-1);
- expect(session.getState()).andReturn(SessionState.Locked);
- session.unlockMachine();
-
- replay(manager, machine, session, progress);
-
- new LaunchMachineIfNotAlreadyRunning(manager, ExecutionType.GUI, "").apply(machine);
-
- verify(manager, machine, session, progress);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/MacAddressToBSDTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/MacAddressToBSDTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/MacAddressToBSDTest.java
deleted file mode 100644
index 66a70cf..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/MacAddressToBSDTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import org.testng.annotations.Test;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-
-@Test(groups = "unit", testName = "MacAddressToBSDTest")
-public class MacAddressToBSDTest {
-
- private static final String vboxMacAddressFormat = "0800271A9806";
- private static final String bsdMacAddressFormat = "8:0:27:1a:98:6";
-
-
-@Test
- public void testTransformMacAddressToBSDFormat() {
- assertEquals(MacAddressToBSD.INSTANCE.apply(Joiner.on(":").join(Splitter.fixedLength(2).split(vboxMacAddressFormat)).toLowerCase()), bsdMacAddressFormat);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java
deleted file mode 100644
index d23407e..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions;
-
-import static org.jclouds.virtualbox.functions.RetrieveActiveBridgedInterfaces.retrieveBridgedInterfaceNames;
-import static org.testng.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jclouds.virtualbox.domain.BridgedIf;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(singleThreaded = true, testName = "RetrieveActiveBridgedInterfacesExpectTest")
-public class RetrieveActiveBridgedInterfacesExpectTest {
-
- public static final String TEST1 = "Name: eth0\n"
- + "GUID: 30687465-0000-4000-8000-00261834d0cb\n" + "Dhcp: Disabled\n"
- + "IPAddress: 209.x.x.x\n" + "NetworkMask: 255.255.255.0\n"
- + "IPV6Address: fe80:0000:0000:0000:0226:18ff:fe34:d0cb\n" + "IPV6NetworkMaskPrefixLength: 64\n"
- + "HardwareAddress: 00:26:18:34:d0:cb\n" + "MediumType: Ethernet\n" + "Status: Up\n"
- + "VBoxNetworkName: HostInterfaceNetworking-eth0\n" + "\n" + "Name: vbox0\n"
- + "GUID: 786f6276-0030-4000-8000-5a3ded993fed\n" + "Dhcp: Disabled\n"
- + "IPAddress: 192.168.56.1\n" + "NetworkMask: 255.255.255.0\n"
- + "IPV6Address: fe80:0000:0000:0000:0226:18ff:fe34:d0cb\n" + "IPV6NetworkMaskPrefixLength: 0\n"
- + "HardwareAddress: 5a:3d:ed:99:3f:ed\n" + "MediumType: Ethernet\n" + "Status: Down\n"
- + "VBoxNetworkName: HostInterfaceNetworking-vbox0\n";
-
- public static final List<BridgedIf> expectedBridgedInterfaces = ImmutableList.of(
- BridgedIf.builder().name("eth0").ip("209.x.x.x").networkMask("255.255.255.0").mediumType("Ethernet")
- .status("Up").build(),
- BridgedIf.builder().name("vbox0").ip("192.168.56.1").networkMask("255.255.255.0").mediumType("Ethernet")
- .status("Down").build());
-
- @Test
- public void retrieveBridgedInterfaceNamesTest() {
- List<BridgedIf> activeBridgedInterfaces = retrieveBridgedInterfaceNames(TEST1);
- assertEquals(activeBridgedInterfaces, expectedBridgedInterfaces);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/TakeSnapshotIfNotAlreadyAttachedTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/TakeSnapshotIfNotAlreadyAttachedTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/TakeSnapshotIfNotAlreadyAttachedTest.java
deleted file mode 100644
index 8cc05e8..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/TakeSnapshotIfNotAlreadyAttachedTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import org.jclouds.logging.Logger;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.IConsole;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IProgress;
-import org.virtualbox_4_2.ISession;
-import org.virtualbox_4_2.ISnapshot;
-import org.virtualbox_4_2.IVirtualBox;
-import org.virtualbox_4_2.MachineState;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.base.Suppliers;
-
-@Test(groups = "unit", testName = "TakeSnapshotIfNotAlreadyAttachedTest")
-public class TakeSnapshotIfNotAlreadyAttachedTest {
-
- @Test
- public void testTakeSnapshotIfNotAlreadyAttached() throws Exception {
-
- String snapshotName = "snap";
- String snapshotDesc = "snapDesc";
-
- VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
- IMachine machine = createMock(IMachine.class);
- IVirtualBox vBox = createMock(IVirtualBox.class);
- ISession session = createMock(ISession.class);
- IConsole console = createNiceMock(IConsole.class);
- IProgress progress = createNiceMock(IProgress.class);
- ISnapshot snapshot = createNiceMock(ISnapshot.class);
- expect(machine.getCurrentSnapshot()).andReturn(snapshot).anyTimes();
- expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();
-
- expect(manager.openMachineSession(machine)).andReturn(session);
-
- expect(session.getConsole()).andReturn(console);
- expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
- progress);
- expect(progress.getCompleted()).andReturn(true);
-
- session.unlockMachine();
- replay(manager, machine, vBox, session, console, progress);
-
- new TakeSnapshotIfNotAlreadyAttached(Suppliers.ofInstance(manager), snapshotName, snapshotDesc, Logger.CONSOLE)
- .apply(machine);
-
- verify(machine);
- }
-
- @Test
- public void testDoNothingIfAlreadyTakenSnapshot() throws Exception {
- String snapshotName = "snap";
- String snapshotDesc = "snapDesc";
-
- VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
- IMachine machine = createMock(IMachine.class);
- IVirtualBox vBox = createMock(IVirtualBox.class);
- ISession session = createMock(ISession.class);
- IConsole console = createNiceMock(IConsole.class);
-
- IProgress progress = createNiceMock(IProgress.class);
- expect(progress.getCompleted()).andReturn(true);
- expect(machine.getCurrentSnapshot()).andReturn(null).anyTimes();
- expect(manager.openMachineSession(machine)).andReturn(session);
- expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();
-
- expect(machine.getName()).andReturn("machine").anyTimes();
- expect(session.getConsole()).andReturn(console);
- expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
- progress);
-
- session.unlockMachine();
- replay(manager, machine, vBox, session, console, progress);
-
- new TakeSnapshotIfNotAlreadyAttached(Suppliers.ofInstance(manager), snapshotName, snapshotDesc, Logger.CONSOLE)
- .apply(machine);
-
- verify(machine);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
deleted file mode 100644
index 5b36103..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/ImageFromYamlStringTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions.admin;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Map;
-
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.virtualbox.domain.YamlImage;
-import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-@Test(groups = "unit", testName = "ImageFromYamlStringTest")
-public class ImageFromYamlStringTest {
-
- public static final Image TEST1 = new ImageBuilder()
- .id("ubuntu-12.04.1-amd64")
- .name("ubuntu-12.04.1-server-amd64")
- .description("ubuntu")
- .operatingSystem(
- OperatingSystem.builder().description("ubuntu").family(OsFamily.UBUNTU).version("12.04.1")
- .arch("amd64").build())
- .status(Image.Status.AVAILABLE).build();
-
- Map<Image, YamlImage> images;
-
- @BeforeMethod
- public void setUp() {
- images = new ImagesToYamlImagesFromYamlDescriptor(new YamlImagesFromFileConfig("/default-images.yaml")).get();
- }
-
- @Test
- public void testNodesParse() {
- assertEquals(Iterables.getFirst(images.keySet(), null), TEST1);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/StartVBoxIfNotAlreadyRunningLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/StartVBoxIfNotAlreadyRunningLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/StartVBoxIfNotAlreadyRunningLiveTest.java
deleted file mode 100644
index 524ac88..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/StartVBoxIfNotAlreadyRunningLiveTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions.admin;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import java.net.URI;
-
-import org.jclouds.compute.callables.RunScriptOnNode;
-import org.jclouds.compute.callables.RunScriptOnNode.Factory;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.virtualbox.functions.HardcodedHostToHostNodeMetadata;
-import org.jclouds.virtualbox.predicates.RetryIfSocketNotYetOpen;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-import com.google.common.base.Suppliers;
-import com.google.common.net.HostAndPort;
-
-@Test(groups = "live", singleThreaded = true, testName = "StartVBoxIfNotAlreadyRunningLiveTest")
-public class StartVBoxIfNotAlreadyRunningLiveTest {
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testStartVboxConnectsToManagerWhenPortAlreadyListening() throws Exception {
- VirtualBoxManager manager = createMock(VirtualBoxManager.class);
- Factory runScriptOnNodeFactory = createMock(Factory.class);
- RunScriptOnNode runScriptOnNode = createMock(RunScriptOnNode.class);
- RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
- HardcodedHostToHostNodeMetadata hardcodedHostToHostNodeMetadata = createMock(HardcodedHostToHostNodeMetadata.class);
- NodeMetadata host = new NodeMetadataBuilder().id("host").status(Status.RUNNING).build();
- URI provider = URI.create("http://localhost:18083/");
- expect(client.seconds(3)).andReturn(client);
- expect(client.apply(HostAndPort.fromParts(provider.getHost(), provider.getPort()))).andReturn(true).anyTimes();
- manager.connect(provider.toASCIIString(), "", "");
- expectLastCall().anyTimes();
- replay(manager, runScriptOnNodeFactory, runScriptOnNode, client);
- new StartVBoxIfNotAlreadyRunning((Function) Functions.constant(manager), runScriptOnNodeFactory, client,
- Suppliers.ofInstance(host), Suppliers.ofInstance(provider), hardcodedHostToHostNodeMetadata).start();
- verify(manager, runScriptOnNodeFactory, client);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMediaTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMediaTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMediaTest.java
deleted file mode 100644
index e62d108..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMediaTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.jclouds.virtualbox.functions.admin;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IMedium;
-import org.virtualbox_4_2.IProgress;
-import org.virtualbox_4_2.IVirtualBox;
-import org.virtualbox_4_2.StorageBus;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.collect.Lists;
-
-@Test(groups = "unit", testName = "UnregisterMachineIfExistsTest")
-public class UnregisterMachineIfExistsAndDeleteItsMediaTest {
-
- private String ideControllerName = "IDE Controller";
- private CleanupMode mode = CleanupMode.Full;
- private String vmName = "jclouds-image-example-machine-to-be-destroyed";
- private String vmId = "jclouds-image-iso-unregister";
- private String osTypeId = "";
-
- @Test
- public void testUnregisterExistingMachine() throws Exception {
- VirtualBoxManager manager = createMock(VirtualBoxManager.class);
- IVirtualBox vBox = createMock(IVirtualBox.class);
- IMachine registeredMachine = createMock(IMachine.class);
- IProgress progress = createNiceMock(IProgress.class);
- List<IMedium> media = Lists.newArrayList();
- List<IMedium> mediums = Collections.unmodifiableList(media);
-
- StorageController ideController = StorageController.builder().name(ideControllerName).bus(StorageBus.IDE)
- .attachISO(0, 0, "/tmp/ubuntu-11.04-server-i386.iso")
- .attachHardDisk(HardDisk.builder().diskpath("/tmp/testadmin.vdi").controllerPort(0).deviceSlot(1).build())
- .attachISO(1, 1, "/tmp/VBoxGuestAdditions_4.1.2.iso").build();
- VmSpec vmSpecification = VmSpec.builder().id(vmId).name(vmName).memoryMB(512).osTypeId(osTypeId)
- .controller(ideController).forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
-
- expect(manager.getVBox()).andReturn(vBox).anyTimes();
- expect(vBox.findMachine(vmName)).andReturn(registeredMachine);
-
- expect(registeredMachine.unregister(mode)).andReturn(mediums);
- expectLastCall().anyTimes();
-
- expect(registeredMachine.delete(mediums)).andReturn(progress);
- expectLastCall().anyTimes();
-
- replay(manager, vBox, registeredMachine, progress);
-
- new UnregisterMachineIfExistsAndDeleteItsMedia(vmSpecification).apply(registeredMachine);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java
deleted file mode 100644
index 92b4bf1..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.jclouds.virtualbox.predicates;
-
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.ssh.SshClient;
-import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
-import org.jclouds.virtualbox.domain.CloneSpec;
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.MasterSpec;
-import org.jclouds.virtualbox.domain.NetworkAdapter;
-import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
-import org.jclouds.virtualbox.domain.NetworkSpec;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
-import org.jclouds.virtualbox.functions.CreateAndInstallVm;
-import org.jclouds.virtualbox.functions.IMachineToSshClient;
-import org.jclouds.virtualbox.util.NetworkUtils;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.NetworkAttachmentType;
-import org.virtualbox_4_2.StorageBus;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Injector;
-
-@Test(groups = "live", singleThreaded = true, testName = "GuestAdditionsInstallerLiveTest")
-public class GuestAdditionsInstallerLiveTest extends BaseVirtualBoxClientLiveTest {
-
- private Injector injector;
- private Function<IMachine, SshClient> sshClientForIMachine;
- private Predicate<SshClient> sshResponds;
- private VmSpec instanceVmSpec;
- private NetworkSpec instanceNetworkSpec;
-
- @Override
- @BeforeClass(groups = "live")
- public void setupContext() {
- super.setupContext();
- injector = view.utils().injector();
-
- String instanceName = VIRTUALBOX_IMAGE_PREFIX
- + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
-
- StorageController ideController = StorageController
- .builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .attachISO(0, 0, operatingSystemIso)
- .attachHardDisk(
- HardDisk.builder().diskpath(adminDisk(instanceName)).controllerPort(0).deviceSlot(1)
- .autoDelete(true).build()).attachISO(1, 1, guestAdditionsIso).build();
-
- instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512)
- .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build();
-
- NetworkAdapter networkAdapter = NetworkAdapter.builder()
- .networkAttachmentType(NetworkAttachmentType.HostOnly)
- .build();
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard.builder().addNetworkAdapter(networkAdapter)
- .addHostInterfaceName("vboxnet0").slot(0L).build();
-
- instanceNetworkSpec = NetworkSpec.builder().addNIC(networkInterfaceCard).build();
- }
-
- @Test
- public void testGuestAdditionsAreInstalled() throws Exception {
- IMachine machine = null;
- try {
- machine = cloneFromMaster();
- machineController.ensureMachineIsLaunched(machine.getName());
- sshClientForIMachine = injector.getInstance(IMachineToSshClient.class);
- SshClient client = sshClientForIMachine.apply(machine);
-
- sshResponds = injector.getInstance(SshResponds.class);
- checkState(sshResponds.apply(client), "timed out waiting for guest %s to be accessible via ssh",
- machine.getName());
-
- assertTrue(NetworkUtils.isIpv4(networkUtils.getIpAddressFromNicSlot(machine.getName(), 0l)));
-
- } finally {
- if (machine != null) {
- for (String vmNameOrId : ImmutableSet.of(machine.getName())) {
- machineController.ensureMachineHasPowerDown(vmNameOrId);
- undoVm(vmNameOrId);
- }
- }
- }
- }
-
- protected IMachine cloneFromMaster() {
- IMachine source = getVmWithGuestAdditionsInstalled();
- CloneSpec cloneSpec = CloneSpec.builder()
- .vm(instanceVmSpec)
- .network(instanceNetworkSpec)
- .master(source)
- .linked(true)
- .build();
- return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
- .apply(cloneSpec);
- }
-
- private IMachine getVmWithGuestAdditionsInstalled() {
- MasterSpec masterSpecForTest = getMasterSpecForTest();
- try {
- Injector injector = view.utils().injector();
- return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest);
- } catch (IllegalStateException e) {
- // already created
- return manager.get().getVBox().findMachine(masterSpecForTest.getVmSpec().getVmId());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java
deleted file mode 100644
index 077360e..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.jclouds.virtualbox.predicates;
-
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.jclouds.virtualbox.predicates.IMachinePredicates.isLinkedClone;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
-import org.jclouds.virtualbox.domain.CloneSpec;
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.IsoSpec;
-import org.jclouds.virtualbox.domain.MasterSpec;
-import org.jclouds.virtualbox.domain.NetworkAdapter;
-import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
-import org.jclouds.virtualbox.domain.NetworkSpec;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
-import org.jclouds.virtualbox.functions.CreateAndInstallVm;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.NetworkAttachmentType;
-import org.virtualbox_4_2.StorageBus;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Injector;
-
-@Test(groups = "live", singleThreaded = true, testName = "IMachinePredicatesLiveTest")
-public class IMachinePredicatesLiveTest extends BaseVirtualBoxClientLiveTest {
-
- private MasterSpec machineSpec;
- private String instanceName;
-
- @Override
- @BeforeClass(groups = "live")
- public void setupContext() {
- super.setupContext();
- instanceName = VIRTUALBOX_IMAGE_PREFIX
- + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
-
- StorageController ideController = StorageController
- .builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .attachISO(0, 0, operatingSystemIso)
- .attachHardDisk(
- HardDisk.builder().diskpath(adminDisk(instanceName)).controllerPort(0).deviceSlot(1)
- .autoDelete(true).build()).attachISO(1, 1, guestAdditionsIso).build();
-
- VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512)
- .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build();
-
- Injector injector = view.utils().injector();
- IsoSpec isoSpec = IsoSpec
- .builder()
- .sourcePath(operatingSystemIso)
- .installationScript(keystrokeSequence).build();
-
- NetworkAdapter networkAdapter = NetworkAdapter.builder().networkAttachmentType(NetworkAttachmentType.NAT)
- .tcpRedirectRule("127.0.0.1", 2222, "", 22).build();
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard.builder().addNetworkAdapter(networkAdapter)
- .build();
-
- NetworkSpec networkSpec = NetworkSpec.builder().addNIC(networkInterfaceCard).build();
- machineSpec = MasterSpec.builder().iso(isoSpec).vm(instanceVmSpec).network(networkSpec).build();
-
- }
-
- @Test
- public void testCloneMachineFromAnotherMachine() {
- IMachine source = getVmWithGuestAdditionsInstalled();
- CloneSpec cloneSpec = CloneSpec.builder().vm(machineSpec.getVmSpec()).network(machineSpec.getNetworkSpec())
- .master(source).linked(true).build();
- IMachine clone = new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
- .apply(cloneSpec);
- assertTrue(isLinkedClone().apply(clone));
- }
-
- private IMachine getVmWithGuestAdditionsInstalled() {
- MasterSpec masterSpecForTest = super.getMasterSpecForTest();
- try {
- Injector injector = view.utils().injector();
- return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest);
- } catch (IllegalStateException e) {
- // already created
- return manager.get().getVBox().findMachine(masterSpecForTest.getVmSpec().getVmId());
- }
- }
-
- @AfterGroups(groups = "live")
- @Override
- protected void tearDownContext() {
- for (String vmName : ImmutableSet.of(instanceName)) {
- undoVm(vmName);
- }
- super.tearDownContext();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/RetryIfSocketNotYetOpenTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/RetryIfSocketNotYetOpenTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/RetryIfSocketNotYetOpenTest.java
deleted file mode 100644
index a041913..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/RetryIfSocketNotYetOpenTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.jclouds.virtualbox.predicates;
-
-import static org.jclouds.compute.predicates.SocketOpenPredicates.alwaysFail;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.concurrent.TimeUnit;
-
-import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
-import org.jclouds.logging.Logger;
-import org.testng.annotations.Test;
-
-import com.google.common.net.HostAndPort;
-
-
-/**
- * Tests timeout behavior of {@link RetryIfSocketNotYetOpen} predicate.
- */
-public class RetryIfSocketNotYetOpenTest {
-
- private static final Logger logger = Logger.NULL;
- private static final HostAndPort socket = HostAndPort.fromParts("dummy", 0);
-
- @Test
- public void fromConstructor() {
- RetryIfSocketNotYetOpen fromSeconds = new RetryIfSocketNotYetOpen(alwaysFail, logger, 2000, TimeUnit.MILLISECONDS);
- doAsserts(fromSeconds, socket, false, 2000, 3000);
- }
-
- @Test
- public void fromSeconds() {
- RetryIfSocketNotYetOpen fromSeconds = new RetryIfSocketNotYetOpen(alwaysFail, logger).seconds(2);
- doAsserts(fromSeconds, socket, false, 2000, 3000);
- }
-
- @Test
- public void fromMilliseconds() {
- RetryIfSocketNotYetOpen fromMilliseconds = new RetryIfSocketNotYetOpen(alwaysFail, logger).milliseconds(2000);
- doAsserts(fromMilliseconds, socket, false, 2000, 3000);
- }
-
- @Test
- public void fromTimeouts() {
- Timeouts timeouts = new Timeouts() { { portOpen = 2 * 1000; } };
- RetryIfSocketNotYetOpen fromTimeouts = new RetryIfSocketNotYetOpen(alwaysFail, timeouts);
- doAsserts(fromTimeouts, socket, false, 2000, 3000);
- }
-
- @Test
- public void timeoutUnset() {
- // With no timeout specified, predicate should return immediately.
- RetryIfSocketNotYetOpen uninitialised = new RetryIfSocketNotYetOpen(alwaysFail, logger);
- doAsserts(uninitialised, socket, false, 0, 500);
- }
-
- private void doAsserts(RetryIfSocketNotYetOpen predicate, HostAndPort socket, boolean expectedResult, long minMilliseconds, long maxMilliseconds) {
- long startTime = System.currentTimeMillis();
- boolean result = predicate.apply(socket);
- long elapsedTime = System.currentTimeMillis() - startTime;
-
- assertEquals(result, expectedResult);
- assertTrue(elapsedTime >= minMilliseconds && elapsedTime < maxMilliseconds,
- "apply() returned after ~" + elapsedTime + "ms, expected it to take between " +
- minMilliseconds + " and " + maxMilliseconds);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsLiveTest.java
deleted file mode 100644
index f888a45..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsLiveTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.jclouds.virtualbox.statements;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.StorageBus;
-
-@Test(testName = "InstallGuestAdditionsLiveTest", groups = "live", singleThreaded = true)
-public class InstallGuestAdditionsLiveTest extends BaseVirtualBoxClientLiveTest {
-
- public void testIsoPresent() {
- StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE)
- .attachISO(1, 0, "VBoxGuestAdditions_").build();
-
- VmSpec vmSpecification = VmSpec.builder().id("").name("").memoryMB(512).osTypeId("").controller(ideController)
- .forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
-
- InstallGuestAdditions installer = new InstallGuestAdditions(vmSpecification, "4.1.8");
- String scripts = installer.render(OsFamily.UNIX);
- assertEquals(scripts, "installModuleAssistantIfNeeded || return 1\n" + "mount -t iso9660 /dev/cdrom1 /mnt\n"
- + "/mnt/VBoxLinuxAdditions.run --nox11\n");
- }
-
- public void testIsoNotPresent() {
- StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE).build();
-
- VmSpec vmSpecification = VmSpec.builder().id("").name("").memoryMB(512).osTypeId("").controller(ideController)
- .forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
-
- InstallGuestAdditions installer = new InstallGuestAdditions(vmSpecification, "4.1.8");
- String scripts = installer.render(OsFamily.UNIX);
- assertEquals(scripts,
- "installModuleAssistantIfNeeded || return 1\n"
- + "setupPublicCurl || return 1\n"
- + "(mkdir -p /tmp/ && cd /tmp/ && [ ! -f VBoxGuestAdditions_4.1.8.iso ] && curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -C - -X GET http://download.virtualbox.org/virtualbox/4.1.8/VBoxGuestAdditions_4.1.8.iso >VBoxGuestAdditions_4.1.8.iso)\n"
- + "mount -o loop /tmp/VBoxGuestAdditions_4.1.8.iso /mnt\n"
- + "/mnt/VBoxLinuxAdditions.run --nox11\n");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsTest.java
deleted file mode 100644
index 62a97c4..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/InstallGuestAdditionsTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.jclouds.virtualbox.statements;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.StorageBus;
-
-public class InstallGuestAdditionsTest {
-
- private static final String VBOX_VERISION = "4.2.0";
-
- @Test
- public void testInstallGAWhenIsoIsPresent() {
- StorageController ideController = StorageController.builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .attachISO(1, 0, "VBoxGuestAdditions_")
- .build();
- VmSpec vmSpec = VmSpec.builder()
- .id("").name("")
- .memoryMB(512)
- .osTypeId("")
- .controller(ideController)
- .forceOverwrite(true)
- .cleanUpMode(CleanupMode.Full)
- .build();
- InstallGuestAdditions installGuestAdditions = new InstallGuestAdditions(vmSpec , VBOX_VERISION);
- assertEquals(installGuestAdditions.render(OsFamily.UNIX),
- "installModuleAssistantIfNeeded || return 1\n" +
- "mount -t iso9660 /dev/cdrom1 /mnt\n" +
- "/mnt/VBoxLinuxAdditions.run --nox11\n");
- }
-
- @Test
- public void testInstallGAWhenIsoIsNotPresent() {
- StorageController ideController = StorageController.builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .build();
- VmSpec vmSpec = VmSpec.builder()
- .id("").name("")
- .memoryMB(512)
- .osTypeId("")
- .controller(ideController)
- .forceOverwrite(true)
- .cleanUpMode(CleanupMode.Full)
- .build();
- InstallGuestAdditions installGuestAdditions = new InstallGuestAdditions(vmSpec , VBOX_VERISION);
- assertEquals(installGuestAdditions.render(OsFamily.UNIX),
- "installModuleAssistantIfNeeded || return 1\n" +
- "setupPublicCurl || return 1\n" +
- "(mkdir -p /tmp/ && cd /tmp/ && [ ! -f VBoxGuestAdditions_4.2.0.iso ] && curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -C - -X GET http://download.virtualbox.org/virtualbox/4.2.0/VBoxGuestAdditions_4.2.0.iso >VBoxGuestAdditions_4.2.0.iso)\n" +
- "mount -o loop /tmp/VBoxGuestAdditions_4.2.0.iso /mnt\n" +
- "/mnt/VBoxLinuxAdditions.run --nox11\n");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/statements/PasswordlessTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/PasswordlessTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/statements/PasswordlessTest.java
deleted file mode 100644
index 430dbe9..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/PasswordlessTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.jclouds.virtualbox.statements;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.testng.annotations.Test;
-
-public class PasswordlessTest {
-
-
- @Test
- public void testApplyPasswordlessSudo() {
- PasswordlessSudo passwordlessSudo = new PasswordlessSudo("barack");
- assertEquals(passwordlessSudo.render(OsFamily.UNIX),
- "touch /etc/sudoers.d/passwordless && echo \"barack ALL = NOPASSWD: ALL\" > /etc/sudoers.d/passwordless && chmod 0440 /etc/sudoers.d/passwordless");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/statements/SetIpAddressTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/SetIpAddressTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/statements/SetIpAddressTest.java
deleted file mode 100644
index d4be94a..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/statements/SetIpAddressTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.jclouds.virtualbox.statements;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.virtualbox.domain.NetworkAdapter;
-import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.NetworkAttachmentType;
-
-public class SetIpAddressTest {
-
- @Test
- public void testSetIpeth0() {
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard
- .builder()
- .slot(0L)
- .addNetworkAdapter(
- NetworkAdapter.builder().staticIp("127.0.0.1").networkAttachmentType(NetworkAttachmentType.NAT)
- .build()).build();
- SetIpAddress setIpAddressStmtm = new SetIpAddress(networkInterfaceCard);
- assertEquals("ifconfig eth0 127.0.0.1;", setIpAddressStmtm.render(OsFamily.UNIX));
- }
-
- @Test
- public void testSetIpeth3() {
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard
- .builder()
- .slot(3L)
- .addNetworkAdapter(
- NetworkAdapter.builder().staticIp("localhost").networkAttachmentType(NetworkAttachmentType.NAT)
- .build()).build();
- SetIpAddress setIpAddressStmtm = new SetIpAddress(networkInterfaceCard);
- assertEquals("ifconfig eth3 localhost;", setIpAddressStmtm.render(OsFamily.UNIX));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testThrowsIllegalArgumentExceptionOnWrongSlot() {
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard
- .builder()
- .slot(4L)
- .addNetworkAdapter(
- NetworkAdapter.builder().staticIp("localhost").networkAttachmentType(NetworkAttachmentType.NAT)
- .build()).build();
- new SetIpAddress(networkInterfaceCard);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java
deleted file mode 100644
index 8624e72..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.jclouds.virtualbox.util;
-
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.assertEquals;
-
-import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
-import org.jclouds.virtualbox.domain.CloneSpec;
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.IsoSpec;
-import org.jclouds.virtualbox.domain.MasterSpec;
-import org.jclouds.virtualbox.domain.NetworkAdapter;
-import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
-import org.jclouds.virtualbox.domain.NetworkSpec;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
-import org.jclouds.virtualbox.functions.CreateAndInstallVm;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.ISession;
-import org.virtualbox_4_2.NetworkAttachmentType;
-import org.virtualbox_4_2.SessionState;
-import org.virtualbox_4_2.StorageBus;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Injector;
-
-@Test(groups = "live", testName = "MachineControllerLiveTest")
-public class MachineControllerLiveTest extends BaseVirtualBoxClientLiveTest {
-
- private MasterSpec masterSpec;
- private String instanceName;
- private IMachine clonedMachine;
-
- @Override
- @BeforeClass(groups = "live")
- public void setupContext() {
- super.setupContext();
- instanceName = VIRTUALBOX_IMAGE_PREFIX
- + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
-
- StorageController ideController = StorageController
- .builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .attachISO(0, 0, operatingSystemIso)
- .attachHardDisk(
- HardDisk.builder().diskpath(adminDisk(instanceName)).controllerPort(0).deviceSlot(1).autoDelete(true)
- .build()).attachISO(1, 1, guestAdditionsIso).build();
-
- VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512)
- .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build();
-
- IsoSpec isoSpec = IsoSpec
- .builder()
- .sourcePath(operatingSystemIso)
- .installationScript(keystrokeSequence).build();
-
- NetworkAdapter networkAdapter = NetworkAdapter.builder().networkAttachmentType(NetworkAttachmentType.HostOnly)
- .build();
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard.builder().addNetworkAdapter(networkAdapter)
- .addHostInterfaceName("vboxnet0").slot(0L).build();
- NetworkSpec networkSpec = NetworkSpec.builder().addNIC(networkInterfaceCard).build();
- masterSpec = MasterSpec.builder().iso(isoSpec).vm(instanceVmSpec).network(networkSpec).build();
- clonedMachine = cloneFromMaster();
- }
-
- @Test
- public void testEnsureMachineisLaunchedAndSessionIsUnlocked() {
- ISession cloneMachineSession = machineController.ensureMachineIsLaunched(clonedMachine.getName());
- assertTrue(cloneMachineSession.getState() == SessionState.Unlocked);
- cloneMachineSession = machineController.ensureMachineHasPowerDown(clonedMachine.getName());
- SessionState state = cloneMachineSession.getState();
- assertEquals(SessionState.Unlocked, state);
- }
-
- private IMachine cloneFromMaster() {
- IMachine source = getVmWithGuestAdditionsInstalled();
- CloneSpec cloneSpec = CloneSpec.builder().vm(masterSpec.getVmSpec()).network(masterSpec.getNetworkSpec())
- .master(source).linked(true).build();
- return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
- .apply(cloneSpec);
- }
-
- private IMachine getVmWithGuestAdditionsInstalled() {
- MasterSpec masterSpecForTest = super.getMasterSpecForTest();
- try {
- Injector injector = view.utils().injector();
- return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest);
- } catch (IllegalStateException e) {
- // already created
- return manager.get().getVBox().findMachine(masterSpecForTest.getVmSpec().getVmId());
- }
- }
-
- @AfterGroups(groups = "live")
- @Override
- protected void tearDownContext() {
- for (String vmName : ImmutableSet.of(instanceName)) {
- undoVm(vmName);
- }
- super.tearDownContext();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java b/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java
deleted file mode 100644
index ff0ea3e..0000000
--- a/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.jclouds.virtualbox.util;
-
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.testng.AssertJUnit.assertEquals;
-
-import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
-import org.jclouds.virtualbox.domain.CloneSpec;
-import org.jclouds.virtualbox.domain.HardDisk;
-import org.jclouds.virtualbox.domain.IsoSpec;
-import org.jclouds.virtualbox.domain.MasterSpec;
-import org.jclouds.virtualbox.domain.NetworkAdapter;
-import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
-import org.jclouds.virtualbox.domain.NetworkSpec;
-import org.jclouds.virtualbox.domain.StorageController;
-import org.jclouds.virtualbox.domain.VmSpec;
-import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
-import org.jclouds.virtualbox.functions.CreateAndInstallVm;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.virtualbox_4_2.CleanupMode;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.ISession;
-import org.virtualbox_4_2.NetworkAttachmentType;
-import org.virtualbox_4_2.SessionState;
-import org.virtualbox_4_2.StorageBus;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Function;
-import com.google.inject.Injector;
-
-@Test(groups = "live", testName = "MachineControllerLiveTest")
-public class MachineUtilsLiveTest extends BaseVirtualBoxClientLiveTest {
-
- private MasterSpec machineSpec;
- private String instanceName;
-
- @Override
- @BeforeClass(groups = "live")
- public void setupContext() {
- super.setupContext();
- instanceName = VIRTUALBOX_IMAGE_PREFIX
- + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
-
- StorageController ideController = StorageController
- .builder()
- .name("IDE Controller")
- .bus(StorageBus.IDE)
- .attachISO(0, 0, operatingSystemIso)
- .attachHardDisk(
- HardDisk.builder().diskpath(adminDisk(instanceName)).controllerPort(0).deviceSlot(1).autoDelete(true)
- .build()).attachISO(1, 1, guestAdditionsIso).build();
-
- VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512)
- .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build();
-
- IsoSpec isoSpec = IsoSpec
- .builder()
- .sourcePath(operatingSystemIso)
- .installationScript(keystrokeSequence).build();
-
- NetworkAdapter networkAdapter = NetworkAdapter.builder().networkAttachmentType(NetworkAttachmentType.NAT)
- .tcpRedirectRule("127.0.0.1", 2222, "", 22).build();
- NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard.builder().addNetworkAdapter(networkAdapter)
- .build();
-
- NetworkSpec networkSpec = NetworkSpec.builder().addNIC(networkInterfaceCard).build();
- machineSpec = MasterSpec.builder().iso(isoSpec).vm(instanceVmSpec).network(networkSpec).build();
- }
-
- @Test(description = "write lock is acquired and released correctly")
- public void writeLockSessionOnMachine() {
- final IMachine clone = cloneFromMaster();
- ISession session = machineUtils.writeLockMachineAndApplyToSession(clone.getName(),
- new Function<ISession, ISession>() {
- @Override
- public ISession apply(ISession session) {
- assertEquals(session.getMachine().getName(), clone.getName());
- return session;
- }
- });
- checkState(session.getState().equals(SessionState.Unlocked));
- undoVm(clone.getName());
- }
-
- @Test(dependsOnMethods = "writeLockSessionOnMachine", description = "shared lock is acquired and released correctly")
- public void sharedLockSessionOnMachine() {
- final IMachine clone = cloneFromMaster();
- ISession session = machineUtils.sharedLockMachineAndApplyToSession(clone.getName(),
- new Function<ISession, ISession>() {
- @Override
- public ISession apply(ISession session) {
- assertEquals(session.getMachine().getName(), clone.getName());
- return session;
- }
- });
- checkState(session.getState().equals(SessionState.Unlocked));
- undoVm(clone.getName());
- }
-
- @Test(dependsOnMethods = "sharedLockSessionOnMachine", description = "shared lock can be acquired after a write lock")
- public void sharedLockCanBeAcquiredAfterWriteLockSessionOnMachine() {
- final IMachine clone = cloneFromMaster();
- try {
- ISession writeSession = machineUtils.writeLockMachineAndApplyToSession(clone.getName(),
- new Function<ISession, ISession>() {
- @Override
- public ISession apply(ISession writeSession) {
- checkState(writeSession.getState().equals(SessionState.Locked));
- return writeSession;
- }
- });
- checkState(writeSession.getState().equals(SessionState.Unlocked));
- } finally {
- undoVm(clone.getName());
- }
- }
-
- @Test(dependsOnMethods = "sharedLockCanBeAcquiredAfterWriteLockSessionOnMachine", description = "write lock cannot be acquired after a shared lock")
- public void writeLockCannotBeAcquiredAfterSharedLockSessionOnMachine() {
- final IMachine clone = cloneFromMaster();
- try {
- ISession sharedSession = machineUtils.sharedLockMachineAndApplyToSession(clone.getName(),
- new Function<ISession, ISession>() {
- @Override
- public ISession apply(ISession sharedSession) {
- checkState(sharedSession.getState().equals(SessionState.Locked));
- return sharedSession;
- }
- });
- checkState(sharedSession.getState().equals(SessionState.Unlocked));
- ISession writeSession = machineUtils.writeLockMachineAndApplyToSession(clone.getName(),
- new Function<ISession, ISession>() {
- @Override
- public ISession apply(ISession writeSession) {
- checkState(writeSession.getState().equals(SessionState.Locked));
- assertEquals(writeSession.getMachine().getName(), clone.getName());
- return writeSession;
- }
- });
- checkState(writeSession.getState().equals(SessionState.Unlocked));
- } finally {
- undoVm(clone.getName());
- }
- }
-
- private IMachine cloneFromMaster() {
- IMachine source = getVmWithGuestAdditionsInstalled();
- CloneSpec cloneSpec = CloneSpec.builder().vm(machineSpec.getVmSpec()).network(machineSpec.getNetworkSpec())
- .master(source).linked(true).build();
- return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, machineUtils)
- .apply(cloneSpec);
- }
-
- private IMachine getVmWithGuestAdditionsInstalled() {
- MasterSpec masterSpecForTest = super.getMasterSpecForTest();
- try {
- Injector injector = view.utils().injector();
- return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest);
- } catch (IllegalStateException e) {
- // already created
- return manager.get().getVBox().findMachine(masterSpecForTest.getVmSpec().getVmId());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/resources/.gitattributes
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/resources/.gitattributes b/virtualbox/src/test/resources/.gitattributes
deleted file mode 100644
index ba409ff..0000000
--- a/virtualbox/src/test/resources/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-*.sh -crlf
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/resources/default-images.yaml
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/resources/default-images.yaml b/virtualbox/src/test/resources/default-images.yaml
deleted file mode 100644
index aa7fd6a..0000000
--- a/virtualbox/src/test/resources/default-images.yaml
+++ /dev/null
@@ -1,151 +0,0 @@
-#
-# 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.
-#
-images:
- - id: ubuntu-12.04.1-amd64
- name: ubuntu-12.04.1-server-amd64
- description: ubuntu 12.04.1 server (amd64)
- os_arch: amd64
- os_family: ubuntu
- os_description: ubuntu
- os_version: 12.04.1
- os_64bit: true
- iso: http://releases.ubuntu.com/12.04.1/ubuntu-12.04.1-server-amd64.iso
- iso_md5: a8c667e871f48f3a662f3fbf1c3ddb17
- username: toor
- credential: password
- keystroke_sequence: <Esc><Esc><Enter> /install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL debian-installer=en_US auto locale=en_US kbd-chooser/method=us hostname=HOSTNAME fb=false debconf/frontend=noninteractive console-setup/ask_detect=false keyboard-configuration/layoutcode=us initrd=/install/initrd.gz -- <Enter>
- preseed_cfg: |
- ## Options to set on the command line
- d-i debian-installer/locale string en_US.utf8
- d-i console-setup/ask_detect boolean false
- d-i console-setup/layout string USA
- d-i netcfg/get_hostname string unassigned-hostname
- d-i netcfg/get_domain string unassigned-domain
- # Continue without a default route
- # Not working , specify a dummy in the DHCP
- #d-i netcfg/no_default_route boolean
- d-i time/zone string UTC
- d-i clock-setup/utc-auto boolean true
- d-i clock-setup/utc boolean true
- d-i kbd-chooser/method select American English
- d-i netcfg/wireless_wep string
- d-i base-installer/kernel/override-image string linux-server
- #d-i base-installer/kernel/override-image string linux-image-2.6.32-21-generic
- # Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive
- d-i debconf debconf/frontend select Noninteractive
- d-i pkgsel/install-language-support boolean false
- tasksel tasksel/first multiselect standard, ubuntu-server
- #d-i partman-auto/method string regular
- d-i partman-auto/method string lvm
- #d-i partman-auto/purge_lvm_from_device boolean true
- d-i partman-lvm/confirm boolean true
- d-i partman-lvm/device_remove_lvm boolean true
- d-i partman-auto/choose_recipe select atomic
- d-i partman/confirm_write_new_label boolean true
- d-i partman/confirm_nooverwrite boolean true
- d-i partman/choose_partition select finish
- d-i partman/confirm boolean true
- #http://ubuntu-virginia.ubuntuforums.org/showthread.php?p=9626883
- #Message: "write the changes to disk and configure lvm preseed"
- #http://serverfault.com/questions/189328/ubuntu-kickstart-installation-using-lvm-waits-for-input
- #preseed partman-lvm/confirm_nooverwrite boolean true
- # Write the changes to disks and configure LVM?
- d-i partman-lvm/confirm boolean true
- d-i partman-lvm/confirm_nooverwrite boolean true
- d-i partman-auto-lvm/guided_size string max
- ## Default user, we can get away with a recipe to change this
- d-i passwd/user-fullname string toor
- d-i passwd/username string toor
- d-i passwd/user-password password password
- d-i passwd/user-password-again password password
- d-i user-setup/encrypt-home boolean false
- d-i user-setup/allow-password-weak boolean true
- ## minimum is ssh and ntp
- # Individual additional packages to install
- d-i pkgsel/include string openssh-server ntp
- # Whether to upgrade packages after debootstrap.
- # Allowed values: none, safe-upgrade, full-upgrade
- d-i pkgsel/upgrade select full-upgrade
- d-i grub-installer/only_debian boolean true
- d-i grub-installer/with_other_os boolean true
- d-i finish-install/reboot_in_progress note
- #For the update
- d-i pkgsel/update-policy select none
- # debconf-get-selections --install
- #Use mirror
- #d-i apt-setup/use_mirror boolean true
- #d-i mirror/country string manual
- #choose-mirror-bin mirror/protocol string http
- #choose-mirror-bin mirror/http/hostname string 192.168.4.150
- #choose-mirror-bin mirror/http/directory string /ubuntu
- #choose-mirror-bin mirror/suite select maverick
- #d-i debian-installer/allow_unauthenticated string true
- choose-mirror-bin mirror/http/proxy string
- - id: centos-6.3-amd64
- name: centos-6.3-amd64
- description: centos-6.3 (amd64)
- os_arch: amd64
- os_family: RedHat
- os_description: RedHat
- os_version: 6.3
- os_64bit: true
- iso: http://www.mirrorservice.org/sites/mirror.centos.org/6.3/isos/x86_64/CentOS-6.3-x86_64-minimal.iso
- iso_md5: 087713752fa88c03a5e8471c661ad1a2
- username: toor
- credential: password
- keystroke_sequence: <Tab> <Spacebar> text ks=PRECONFIGURATION_URL <Enter>
- preseed_cfg: |
- ## Options to set on the command line
- install
- cdrom
- lang en_US.UTF-8
- keyboard us
- network --bootproto=dhcp
- rootpw --iscrypted $1$damlkd,f$UC/u5pUts5QiU3ow.CSso/
- firewall --enabled --service=ssh
- authconfig --enableshadow --passalgo=sha512
- selinux --disabled
- timezone UTC
- bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
- zerombr yes
-
- clearpart --all --drives=sda --initlabel
- autopart
- auth --useshadow --enablemd5
- #skip answers to the First Boot process
- firstboot --disable
- #reboot machine
- reboot
-
- %packages --ignoremissing
- @core
- %end
-
- %post
- /usr/bin/yum -y install sudo gcc make kernel kernel-devel openssl-devel perl wget dkms acpid
- /etc/init.d/haldaemon stop
- /etc/init.d/acpid start
- /etc/init.d/haldaemon start
- /usr/sbin/groupadd toor
- /usr/sbin/useradd toor -g toor -G wheel
- echo "password"|passwd --stdin toor
- echo "toor ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/toor
- chmod 0440 /etc/sudoers.d/toor
- sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
- %end
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/resources/default-keystroke-sequence
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/resources/default-keystroke-sequence b/virtualbox/src/test/resources/default-keystroke-sequence
deleted file mode 100644
index bcfd94b..0000000
--- a/virtualbox/src/test/resources/default-keystroke-sequence
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-#
-<Esc><Esc><Enter> /install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL debian-installer=en_US auto locale=en_US kbd-chooser/method=us hostname=hostname fb=false debconf/frontend=noninteractive console-setup/ask_detect=false keyboard-configuration/layoutcode=us " initrd=/install/initrd.gz -- <Enter>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/virtualbox/src/test/resources/logback.xml b/virtualbox/src/test/resources/logback.xml
deleted file mode 100644
index bce8c26..0000000
--- a/virtualbox/src/test/resources/logback.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0"?>
-<configuration scan="false">
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds.log</file>
-
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%d %-5p [%c] (%t) %m%n</Pattern>
- </layout>
- </appender>
-
- <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds-wire.log</file>
-
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%d %-5p [%c] (%t) %m%n</Pattern>
- </layout>
- </appender>
-
- <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds-compute.log</file>
-
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%d %-5p [%c] (%t) %m%n</Pattern>
- </layout>
- </appender>
-
- <appender name="SSHFILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds-ssh.log</file>
-
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%d %-5p [%c] (%t) %m%n</Pattern>
- </layout>
- </appender>
-
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%-4r [%thread] %-5level - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root>
- <level value="INFO" />
- <appender-ref ref="CONSOLE" />
- </root>
-
- <logger name="net.schmizz.sshj">
- <level value="INFO" />
- <appender-ref ref="CONSOLE" />
- </logger>
-
- <logger name="org.jclouds">
- <level value="DEBUG" />
- <appender-ref ref="FILE" />
- </logger>
-
- <logger name="jclouds.wire">
- <level value="DEBUG" />
- <appender-ref ref="WIREFILE" />
- </logger>
-
- <logger name="jclouds.headers">
- <level value="DEBUG" />
- <appender-ref ref="WIREFILE" />
- </logger>
-
- <logger name="jclouds.compute">
- <level value="DEBUG" />
- <appender-ref ref="COMPUTEFILE" />
- </logger>
-
- <logger name="jclouds.ssh">
- <level value="DEBUG" />
- <appender-ref ref="SSHFILE" />
- </logger>
-
-</configuration>