mirror of
https://github.com/maxkratz/iflye.git
synced 2024-09-16 11:28:43 +00:00
Merge pull request #69 from Echtzeitsysteme/hotfix/path-underlying-link-validate-ignore-flag
Adds a test case for the recent ModelFacade bugfix on path updating underlying links
This commit is contained in:
commit
c85ff6dc23
2 changed files with 196 additions and 0 deletions
131
test.suite/resources/pathLoadModel_embedding.xmi
Normal file
131
test.suite/resources/pathLoadModel_embedding.xmi
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<network.model:Root
|
||||
xmi:version="2.0"
|
||||
xmlns:xmi="http://www.omg.org/XMI"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:network.model="platform:/resource/network.model/model/Model.ecore">
|
||||
<networks
|
||||
xsi:type="network.model:SubstrateNetwork"
|
||||
name="net">
|
||||
<nodes xsi:type="network.model:SubstrateSwitch"
|
||||
name="sw"
|
||||
outgoingLinks="//@networks.0/@links.2 //@networks.0/@links.3"
|
||||
incomingLinks="//@networks.0/@links.0 //@networks.0/@links.1"
|
||||
guestSwitches="//@networks.1/@nodes.1"
|
||||
paths="//@networks.0/@paths.0 //@networks.0/@paths.1 //@networks.0/@paths.2 //@networks.0/@paths.3 //@networks.0/@paths.4 //@networks.0/@paths.5"
|
||||
outgoingPaths="//@networks.0/@paths.3 //@networks.0/@paths.5"
|
||||
incomingPaths="//@networks.0/@paths.2 //@networks.0/@paths.4"/>
|
||||
<nodes xsi:type="network.model:SubstrateServer"
|
||||
name="srv1"
|
||||
depth="1"
|
||||
outgoingLinks="//@networks.0/@links.0"
|
||||
incomingLinks="//@networks.0/@links.2"
|
||||
paths="//@networks.0/@paths.0 //@networks.0/@paths.1 //@networks.0/@paths.2 //@networks.0/@paths.3"
|
||||
outgoingPaths="//@networks.0/@paths.0 //@networks.0/@paths.2"
|
||||
incomingPaths="//@networks.0/@paths.1 //@networks.0/@paths.3"
|
||||
guestServers="//@networks.1/@nodes.0"/>
|
||||
<nodes xsi:type="network.model:SubstrateServer"
|
||||
name="srv2"
|
||||
depth="1"
|
||||
outgoingLinks="//@networks.0/@links.1"
|
||||
incomingLinks="//@networks.0/@links.3"
|
||||
paths="//@networks.0/@paths.0 //@networks.0/@paths.1 //@networks.0/@paths.4 //@networks.0/@paths.5"
|
||||
outgoingPaths="//@networks.0/@paths.1 //@networks.0/@paths.4"
|
||||
incomingPaths="//@networks.0/@paths.0 //@networks.0/@paths.5"/>
|
||||
<links xsi:type="network.model:SubstrateLink"
|
||||
name="ln1"
|
||||
bandwidth="1"
|
||||
source="//@networks.0/@nodes.1"
|
||||
target="//@networks.0/@nodes.0"
|
||||
residualBandwidth="1"
|
||||
paths="//@networks.0/@paths.0 //@networks.0/@paths.2"/>
|
||||
<links xsi:type="network.model:SubstrateLink"
|
||||
name="ln2"
|
||||
bandwidth="2"
|
||||
source="//@networks.0/@nodes.2"
|
||||
target="//@networks.0/@nodes.0"
|
||||
residualBandwidth="2"
|
||||
paths="//@networks.0/@paths.1 //@networks.0/@paths.4"/>
|
||||
<links xsi:type="network.model:SubstrateLink"
|
||||
name="ln3"
|
||||
bandwidth="1"
|
||||
source="//@networks.0/@nodes.0"
|
||||
target="//@networks.0/@nodes.1"
|
||||
residualBandwidth="-9"
|
||||
paths="//@networks.0/@paths.1 //@networks.0/@paths.3"/>
|
||||
<links xsi:type="network.model:SubstrateLink"
|
||||
name="ln4"
|
||||
bandwidth="2"
|
||||
source="//@networks.0/@nodes.0"
|
||||
target="//@networks.0/@nodes.2"
|
||||
residualBandwidth="2"
|
||||
paths="//@networks.0/@paths.0 //@networks.0/@paths.5"/>
|
||||
<paths name="path-srv1-sw-srv2"
|
||||
source="//@networks.0/@nodes.1"
|
||||
target="//@networks.0/@nodes.2"
|
||||
nodes="//@networks.0/@nodes.1 //@networks.0/@nodes.0 //@networks.0/@nodes.2"
|
||||
links="//@networks.0/@links.0 //@networks.0/@links.3"
|
||||
bandwidth="1"
|
||||
hops="2"
|
||||
residualBandwidth="1"/>
|
||||
<paths name="path-srv2-sw-srv1"
|
||||
source="//@networks.0/@nodes.2"
|
||||
target="//@networks.0/@nodes.1"
|
||||
nodes="//@networks.0/@nodes.2 //@networks.0/@nodes.0 //@networks.0/@nodes.1"
|
||||
links="//@networks.0/@links.1 //@networks.0/@links.2"
|
||||
bandwidth="1"
|
||||
hops="2"
|
||||
residualBandwidth="1"/>
|
||||
<paths name="path-srv1-sw"
|
||||
guestLinks="//@networks.1/@links.0"
|
||||
source="//@networks.0/@nodes.1"
|
||||
target="//@networks.0/@nodes.0"
|
||||
nodes="//@networks.0/@nodes.1 //@networks.0/@nodes.0"
|
||||
links="//@networks.0/@links.0"
|
||||
bandwidth="1"
|
||||
hops="1"
|
||||
residualBandwidth="1"/>
|
||||
<paths name="path-sw-srv1"
|
||||
source="//@networks.0/@nodes.0"
|
||||
target="//@networks.0/@nodes.1"
|
||||
nodes="//@networks.0/@nodes.0 //@networks.0/@nodes.1"
|
||||
links="//@networks.0/@links.2"
|
||||
bandwidth="1"
|
||||
hops="1"
|
||||
residualBandwidth="-9"/>
|
||||
<paths name="path-srv2-sw"
|
||||
source="//@networks.0/@nodes.2"
|
||||
target="//@networks.0/@nodes.0"
|
||||
nodes="//@networks.0/@nodes.2 //@networks.0/@nodes.0"
|
||||
links="//@networks.0/@links.1"
|
||||
bandwidth="2"
|
||||
hops="1"
|
||||
residualBandwidth="2"/>
|
||||
<paths name="path-sw-srv2"
|
||||
source="//@networks.0/@nodes.0"
|
||||
target="//@networks.0/@nodes.2"
|
||||
nodes="//@networks.0/@nodes.0 //@networks.0/@nodes.2"
|
||||
links="//@networks.0/@links.3"
|
||||
bandwidth="2"
|
||||
hops="1"
|
||||
residualBandwidth="2"/>
|
||||
</networks>
|
||||
<networks
|
||||
xsi:type="network.model:VirtualNetwork"
|
||||
name="virt">
|
||||
<nodes xsi:type="network.model:VirtualServer"
|
||||
name="vsrv1"
|
||||
outgoingLinks="//@networks.1/@links.0"
|
||||
host="//@networks.0/@nodes.1"/>
|
||||
<nodes xsi:type="network.model:VirtualSwitch"
|
||||
name="vsw1"
|
||||
incomingLinks="//@networks.1/@links.0"
|
||||
host="//@networks.0/@nodes.0"/>
|
||||
<links xsi:type="network.model:VirtualLink"
|
||||
name="vl1"
|
||||
bandwidth="10"
|
||||
source="//@networks.1/@nodes.0"
|
||||
target="//@networks.1/@nodes.1"
|
||||
host="//@networks.0/@paths.2"/>
|
||||
</networks>
|
||||
</network.model:Root>
|
|
@ -0,0 +1,65 @@
|
|||
package test.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import facade.ModelFacade;
|
||||
import facade.config.ModelFacadeConfig;
|
||||
import model.SubstratePath;
|
||||
|
||||
/**
|
||||
* Test class for the ModelFacade that tests the correct behavior in regards to
|
||||
* the bandwidth ignoring flag.
|
||||
*
|
||||
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
|
||||
*/
|
||||
public class ModelFacadePathResidualBandwidthIgnoreTest {
|
||||
|
||||
private final String referenceModelFile = "resources/pathLoadModel_embedding.xmi";
|
||||
|
||||
private boolean oldIgnoreBandwidth = false;
|
||||
|
||||
@BeforeEach
|
||||
public void resetModel() {
|
||||
ModelFacade.getInstance().resetAll();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void restoreModelFacadeConfig() {
|
||||
ModelFacadeConfig.IGNORE_BW = oldIgnoreBandwidth;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllPathsFromFile() {
|
||||
oldIgnoreBandwidth = ModelFacadeConfig.IGNORE_BW;
|
||||
ModelFacadeConfig.IGNORE_BW = true;
|
||||
|
||||
// Pre-test: no paths present
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> {
|
||||
ModelFacade.getInstance().getAllPathsOfNetwork("net");
|
||||
});
|
||||
|
||||
// Load the model file
|
||||
ModelFacade.getInstance().loadModel(referenceModelFile);
|
||||
|
||||
final List<SubstratePath> allPaths = ModelFacade.getInstance().getAllPathsOfNetwork("net");
|
||||
|
||||
// Check total number of paths
|
||||
assertFalse(allPaths.isEmpty());
|
||||
assertEquals(6, allPaths.size());
|
||||
|
||||
// Test update of all path's residual bandwidths
|
||||
assertDoesNotThrow(() -> {
|
||||
ModelFacade.getInstance().updateAllPathsResidualBandwidth("net");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue