diff options
2 files changed, 88 insertions, 28 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostMemoryTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostMemoryTest.kt index c80d6843..dc6d6a32 100644 --- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostMemoryTest.kt +++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostMemoryTest.kt @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2026 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 org.opendc.compute.simulator.host import io.mockk.every @@ -24,25 +46,33 @@ class SimHostMemoryTest { val engine = mockk<FlowEngine>(relaxed = true) val cpuModel = CpuModel(0, 4, 2600.0, "vendor", "model", "arch") val memoryUnit = MemoryUnit("vendor", "model", 3200.0, 1024) // 1024 MB memory - val machineModel = MachineModel(cpuModel, memoryUnit, null, FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS) + val machineModel = + MachineModel( + cpuModel, + memoryUnit, + null, + FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, + FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, + ) val powerModel = mockk<PowerModel>(relaxed = true) val distributor = mockk<FlowDistributor>(relaxed = true) val simMachine = mockk<SimMachine>(relaxed = true) every { simMachine.canFit(any()) } returns true - val host = SimHost( - name = "H01", - type = "host", - clusterName = "C01", - clock = clock, - engine = engine, - machineModel = machineModel, - cpuPowerModel = powerModel, - gpuPowerModel = null, - embodiedCarbon = 0.0, - expectedLifetime = 0.0, - powerDistributor = distributor - ) + val host = + SimHost( + name = "H01", + type = "host", + clusterName = "C01", + clock = clock, + engine = engine, + machineModel = machineModel, + cpuPowerModel = powerModel, + gpuPowerModel = null, + embodiedCarbon = 0.0, + expectedLifetime = 0.0, + powerDistributor = distributor, + ) // Use reflection to set simMachine if needed, but SimHost.launch() sets it. // Actually SimHost has it as private var simMachine: SimMachine? = null diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostTelemetryTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostTelemetryTest.kt index 2f8496d0..b743dc0e 100644 --- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostTelemetryTest.kt +++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/host/SimHostTelemetryTest.kt @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2026 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 org.opendc.compute.simulator.host import io.mockk.mockk @@ -20,23 +42,31 @@ class SimHostTelemetryTest { val engine = mockk<FlowEngine>(relaxed = true) val cpuModel = CpuModel(0, 4, 2600.0, "vendor", "model", "arch") val memoryUnit = MemoryUnit("vendor", "model", 3200.0, 1024) - val machineModel = MachineModel(cpuModel, memoryUnit, null, FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS) + val machineModel = + MachineModel( + cpuModel, + memoryUnit, + null, + FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, + FlowDistributorFactory.DistributionPolicy.MAX_MIN_FAIRNESS, + ) val powerModel = mockk<PowerModel>(relaxed = true) val distributor = mockk<FlowDistributor>(relaxed = true) - val host = SimHost( - name = "H01", - type = "host", - clusterName = "C01", - clock = clock, - engine = engine, - machineModel = machineModel, - cpuPowerModel = powerModel, - gpuPowerModel = null, - embodiedCarbon = 0.0, - expectedLifetime = 0.0, - powerDistributor = distributor - ) + val host = + SimHost( + name = "H01", + type = "host", + clusterName = "C01", + clock = clock, + engine = engine, + machineModel = machineModel, + cpuPowerModel = powerModel, + gpuPowerModel = null, + embodiedCarbon = 0.0, + expectedLifetime = 0.0, + powerDistributor = distributor, + ) val task = mockk<ServiceTask>(relaxed = true) io.mockk.every { task.name } returns "T01" |
