Adds tests for the path bug for various algos + minor fix in GIPS migration algo

This commit is contained in:
Maximilian Kratz 2024-04-11 14:29:43 +02:00
parent 70fc23962d
commit 17ce1d6fb8
7 changed files with 241 additions and 65 deletions

View file

@ -0,0 +1,83 @@
package test.algorithms.generic;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import model.SubstrateNetwork;
import model.VirtualNetwork;
/**
* Abstract test class for a VNE algorithm implementation to trigger the minimum
* path/link bandwidth bug. This test is based on a scenario created by Marco
* Volle in his master's thesis.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public abstract class AVneAlgorithmPathBandwidthBugTest extends AAlgorithmTest {
/**
* Substrate network.
*/
SubstrateNetwork sNet;
/**
* Virtual network.
*/
VirtualNetwork vNet;
@Override
public abstract void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets);
@AfterEach
public abstract void resetAlgo();
@BeforeEach
public void resetModel() {
facade.resetAll();
}
//
// Tests
//
@Test
public void testScenario34() {
// Load the model file
facade.loadModel("resources/triggerPathResidualBwBug.xmi");
assertNotNull(facade.getNetworkById("sub"));
assertFalse(facade.getAllPathsOfNetwork("sub").isEmpty());
assertThrows(InternalError.class, () -> {
facade.validateModel();
});
facade.updateAllPathsResidualBandwidth("sub");
// validation must not fail before the embedding
facade.validateModel();
sNet = (SubstrateNetwork) facade.getNetworkById("sub");
vNet = (VirtualNetwork) facade.getNetworkById("v4");
// Sanity check
assertNotNull(sNet);
assertNotNull(vNet);
assertNull(vNet.getHost());
initAlgo(sNet, Set.of(vNet));
assertTrue(algo.execute());
// validation must not fail
facade.validateModel();
}
}

View file

@ -1,44 +1,23 @@
package test.algorithms.gips;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.gips.VneGipsAlgorithm;
import model.SubstrateLink;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.generic.AAlgorithmTest;
import test.algorithms.generic.AVneAlgorithmPathBandwidthBugTest;
/**
* Test class for the VNE GIPS algorithm implementation to trigger the minimum
* path/link bandwidth bug. This test is based on a scenario created by Marco
* Volle in his master's thesis.
* path/link bandwidth bug.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
//@Disabled
public class VneGipsAlgorithmPathBandwidthBugTest extends AAlgorithmTest {
/**
* Substrate network.
*/
SubstrateNetwork sNet;
/**
* Virtual network.
*/
VirtualNetwork vNet;
public class VneGipsAlgorithmPathBandwidthBugTest extends AVneAlgorithmPathBandwidthBugTest {
@Override
public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
@ -55,45 +34,5 @@ public class VneGipsAlgorithmPathBandwidthBugTest extends AAlgorithmTest {
((VneGipsAlgorithm) algo).dispose();
}
}
@BeforeEach
public void resetModel() {
facade.resetAll();
}
//
// Tests
//
@Test
public void testScenario34() {
// Load the model file
facade.loadModel("resources/triggerPathResidualBwBug.xmi");
assertNotNull(facade.getNetworkById("sub"));
assertFalse(facade.getAllPathsOfNetwork("sub").isEmpty());
assertThrows(InternalError.class, () -> {
facade.validateModel();
});
facade.updateAllPathsResidualBandwidth("sub");
// validation must not fail before the embedding
facade.validateModel();
sNet = (SubstrateNetwork) facade.getNetworkById("sub");
vNet = (VirtualNetwork) facade.getNetworkById("v4");
// Sanity check
assertNotNull(sNet);
assertNotNull(vNet);
assertNull(vNet.getHost());
initAlgo(sNet, Set.of(vNet));
assertTrue(algo.execute());
// validation must not fail
facade.validateModel();
}
}

View file

@ -0,0 +1,38 @@
package test.algorithms.gips.migration;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.gips.VneGipsMigrationAlgorithm;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.generic.AVneAlgorithmPathBandwidthBugTest;
/**
* Test class for the VNE GIPS migration algorithm implementation to trigger the
* minimum path/link bandwidth bug.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VneGipsMigrationAlgorithmPathBandwidthBugTest extends AVneAlgorithmPathBandwidthBugTest {
@Override
public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
// The algorithm is only able to use the total communication objective C because
// it is hard-coded in GIPSL
AlgorithmConfig.obj = Objective.TOTAL_COMMUNICATION_OBJECTIVE_C;
algo = VneGipsMigrationAlgorithm.prepare(sNet, vNets);
}
@AfterEach
public void resetAlgo() {
facade.resetAll();
if (algo != null) {
((VneGipsMigrationAlgorithm) algo).dispose();
}
}
}

View file

@ -0,0 +1,38 @@
package test.algorithms.gips.seq;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.gips.VneGipsSeqAlgorithm;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.generic.AVneAlgorithmPathBandwidthBugTest;
/**
* Test class for the VNE GIPS sequence algorithm implementation to trigger the
* minimum path/link bandwidth bug.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VneGipsSeqAlgorithmPathBandwidthBugTest extends AVneAlgorithmPathBandwidthBugTest {
@Override
public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
// The algorithm is only able to use the total communication objective C because
// it is hard-coded in GIPSL
AlgorithmConfig.obj = Objective.TOTAL_COMMUNICATION_OBJECTIVE_C;
algo = VneGipsSeqAlgorithm.prepare(sNet, vNets);
}
@AfterEach
public void resetAlgo() {
facade.resetAll();
if (algo != null) {
((VneGipsSeqAlgorithm) algo).dispose();
}
}
}

View file

@ -0,0 +1,37 @@
package test.algorithms.pm;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithm;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.generic.AVneAlgorithmPathBandwidthBugTest;
/**
* Test class to trigger the minimum path/link bandwidth bug.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VnePmMdvneAlgorithmPathBandwidthBugTest extends AVneAlgorithmPathBandwidthBugTest {
@Override
public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
// The algorithm is only able to use the total communication objective C because
// it is hard-coded in GIPSL
AlgorithmConfig.obj = Objective.TOTAL_COMMUNICATION_OBJECTIVE_C;
algo = VnePmMdvneAlgorithm.prepare(sNet, vNets);
}
@AfterEach
public void resetAlgo() {
facade.resetAll();
if (algo != null) {
((VnePmMdvneAlgorithm) algo).dispose();
}
}
}

View file

@ -0,0 +1,37 @@
package test.algorithms.pm.migration;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithmMigration;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.generic.AVneAlgorithmPathBandwidthBugTest;
/**
* Test class to trigger the minimum path/link bandwidth bug.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VnePmMdvneAlgorithmMigrationPathBandwidthBugTest extends AVneAlgorithmPathBandwidthBugTest {
@Override
public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
// The algorithm is only able to use the total communication objective C because
// it is hard-coded in GIPSL
AlgorithmConfig.obj = Objective.TOTAL_COMMUNICATION_OBJECTIVE_C;
algo = VnePmMdvneAlgorithmMigration.prepare(sNet, vNets);
}
@AfterEach
public void resetAlgo() {
facade.resetAll();
if (algo != null) {
((VnePmMdvneAlgorithmMigration) algo).dispose();
}
}
}

View file

@ -54,6 +54,10 @@ public class VneGipsMigrationAlgorithm extends AbstractAlgorithm {
}
}
}
// Sanity check
ModelFacade.getInstance().validateModel();
ModelFacade.getInstance().updateAllPathsResidualBandwidth(sNet.getName());
final ResourceSet model = ModelFacade.getInstance().getResourceSet();
final boolean gipsSuccess = MdvneMigrationGipsIflyeAdapter.execute(model);