summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src/test
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-02-14 19:11:35 +0100
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2020-02-14 19:11:35 +0100
commit04e4bddccc4e06a126f3c6ee2878502323c7116e (patch)
tree716253f4c03cf8dc6754430a5f63d0a57061d795 /opendc/opendc-compute/src/test
parentcd293b79ef2066ffcb605b9c625d6ab0a9af1d16 (diff)
parentb13ba01e967e1a281d58b37cb57986b47ec99dd8 (diff)
Merge branch 'feat/cpu-sharing' into 'feat/2.x'
Add basis for VM modeling and fractional space-sharing See merge request opendc/opendc-simulator!23
Diffstat (limited to 'opendc/opendc-compute/src/test')
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt70
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt73
2 files changed, 143 insertions, 0 deletions
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
new file mode 100644
index 00000000..c57d6eca
--- /dev/null
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
@@ -0,0 +1,70 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.atlarge.opendc.compute.metal.driver
+
+import com.atlarge.odcsim.SimulationEngineProvider
+import com.atlarge.opendc.compute.core.ProcessingUnit
+import com.atlarge.opendc.compute.core.Server
+import com.atlarge.opendc.compute.core.ServerFlavor
+import com.atlarge.opendc.compute.core.ServerState
+import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
+import com.atlarge.opendc.compute.core.monitor.ServerMonitor
+import com.atlarge.opendc.compute.metal.PowerState
+import java.util.ServiceLoader
+import java.util.UUID
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.runBlocking
+import org.junit.jupiter.api.Test
+
+internal class SimpleBareMetalDriverTest {
+ /**
+ * A smoke test for the bare-metal driver.
+ */
+ @Test
+ fun smoke() {
+ val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
+ val system = provider({ ctx ->
+ val flavor = ServerFlavor(listOf(ProcessingUnit("Intel", "Xeon", "amd64", 2300.0, 4)))
+ val image = FlopsApplicationImage(1000, 2)
+ val monitor = object : ServerMonitor {
+ override suspend fun onUpdate(server: Server, previousState: ServerState) {
+ println(server)
+ }
+ }
+ val driver = SimpleBareMetalDriver(UUID.randomUUID(), "test", flavor)
+
+ driver.init(monitor)
+ driver.setImage(image)
+ driver.setPower(PowerState.POWER_ON)
+ delay(5)
+ println(driver.refresh())
+ }, name = "sim")
+
+ runBlocking {
+ system.run()
+ system.terminate()
+ }
+ }
+}
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt
new file mode 100644
index 00000000..0f9cbd7f
--- /dev/null
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt
@@ -0,0 +1,73 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.atlarge.opendc.compute.metal.service
+
+import com.atlarge.odcsim.SimulationEngineProvider
+import com.atlarge.opendc.compute.core.ProcessingUnit
+import com.atlarge.opendc.compute.core.Server
+import com.atlarge.opendc.compute.core.ServerFlavor
+import com.atlarge.opendc.compute.core.ServerState
+import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
+import com.atlarge.opendc.compute.core.monitor.ServerMonitor
+import com.atlarge.opendc.compute.metal.driver.SimpleBareMetalDriver
+import java.util.ServiceLoader
+import java.util.UUID
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.runBlocking
+import org.junit.jupiter.api.Test
+
+/**
+ * Test suite for the [SimpleProvisioningService].
+ */
+internal class SimpleProvisioningServiceTest {
+ /**
+ * A basic smoke test.
+ */
+ @Test
+ fun smoke() {
+ val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
+ val system = provider({ ctx ->
+ val flavor = ServerFlavor(listOf(ProcessingUnit("Intel", "Xeon", "amd64", 2300.0, 4)))
+ val image = FlopsApplicationImage(1000, 2)
+ val monitor = object : ServerMonitor {
+ override suspend fun onUpdate(server: Server, previousState: ServerState) {
+ println(server)
+ }
+ }
+ val driver = SimpleBareMetalDriver(UUID.randomUUID(), "test", flavor)
+
+ val provisioner = SimpleProvisioningService()
+ provisioner.create(driver)
+ delay(5)
+ val nodes = provisioner.nodes()
+ provisioner.deploy(nodes.first(), image, monitor)
+ }, name = "sim")
+
+ runBlocking {
+ system.run()
+ system.terminate()
+ }
+ }
+}