Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
simulators
server
Commits
899503ed
Commit
899503ed
authored
Sep 27, 2019
by
hengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debugging test
parent
bfcd41a5
Pipeline
#188325
failed with stage
in 6 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
40 deletions
+33
-40
docker/run_test.sh
docker/run_test.sh
+1
-1
restful/src/test/java/server/restful/service/SimulationServiceTest.java
...st/java/server/restful/service/SimulationServiceTest.java
+32
-39
No files found.
docker/run_test.sh
View file @
899503ed
...
...
@@ -62,7 +62,7 @@ cd ${CURR_DIR}
docker run
\
--rm
--network
=
"simulation-network"
\
-e
"ZOO_SERVERS=zookeeper"
\
montisim-server-builder sh
-c
"cd restful && mvn test -
Dtest=MapServiceTest -
s ../settings.xml"
\
montisim-server-builder sh
-c
"cd restful && mvn test -s ../settings.xml"
\
2>&1 |
tee
result.txt
dockerCleanUp
...
...
restful/src/test/java/server/restful/service/SimulationServiceTest.java
View file @
899503ed
...
...
@@ -3,19 +3,12 @@ package server.restful.service;
import
junit.framework.TestCase
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
server.restful.dao.MapDAO
;
import
server.restful.dao.ScenarioDAO
;
import
server.restful.dao.SimulationDAO
;
import
server.restful.model.Dataframe
;
import
server.restful.model.ScenarioModel
;
import
server.restful.registry.RegistryFactory
;
import
server.restful.util.Util
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.util.List
;
import
java.util.Properties
;
public
class
SimulationServiceTest
extends
TestCase
{
...
...
@@ -30,38 +23,38 @@ public class SimulationServiceTest extends TestCase {
*
* @throws FileNotFoundException
*/
@Test
public
void
testSimulation
()
throws
Exception
{
Logger
logger
=
LoggerFactory
.
getLogger
(
SimulationServiceTest
.
class
);
ScenarioModel
scenario
=
ScenarioService
.
saveScenario
(
new
FileInputStream
(
getClass
().
getResource
(
"/chargingstation.sim"
).
getPath
()),
"uploaded.sim"
);
int
mapID
=
MapDAO
.
create
(
"chargingstation.osm"
,
getClass
().
getResource
(
"/chargingstation.osm"
).
getPath
());
int
simID
=
SimulationDAO
.
create
(
scenario
.
getId
(),
1
);
SimulationService
sim
=
new
SimulationService
(
simID
);
sim
.
startSimulation
(
RegistryFactory
.
getZookeeperRegistry
());
// wait for battery to be charged from 19% to 100%, it will take some time...
// if we can set the charging battery target to a lower value rather than 100%,
// it will be much quicker.
while
(!
sim
.
isSimulationFinished
()){
logger
.
info
(
"Waiting for simulation result..."
);
Thread
.
sleep
(
5000
);
}
List
<
Dataframe
>
frames
=
sim
.
getResult
().
get
(
0
).
getFrames
();
// expect 1 vehicle
assertEquals
(
1
,
sim
.
getResult
().
size
());
assertTrue
(
frames
.
size
()
>
0
);
double
initialBattery
=
frames
.
get
(
0
).
getBattery
();
double
finalBattery
=
frames
.
get
(
frames
.
size
()
-
1
).
getBattery
();
// after charging, final battery percentage should be higher than initial
assertTrue
(
finalBattery
>
initialBattery
);
}
//
@Test
//
public void testSimulation() throws Exception {
//
Logger logger = LoggerFactory.getLogger(SimulationServiceTest.class);
//
ScenarioModel scenario = ScenarioService.saveScenario(
//
new FileInputStream(getClass().getResource("/chargingstation.sim").getPath()),
//
"uploaded.sim"
//
);
//
int mapID = MapDAO.create("chargingstation.osm", getClass().getResource("/chargingstation.osm").getPath());
//
int simID = SimulationDAO.create(scenario.getId(), 1);
//
SimulationService sim = new SimulationService(simID);
//
//
sim.startSimulation(RegistryFactory.getZookeeperRegistry());
//
//
// wait for battery to be charged from 19% to 100%, it will take some time...
//
// if we can set the charging battery target to a lower value rather than 100%,
//
// it will be much quicker.
//
while(!sim.isSimulationFinished()){
//
logger.info("Waiting for simulation result...");
//
Thread.sleep(5000);
//
}
//
//
List<Dataframe> frames = sim.getResult().get(0).getFrames();
//
//
// expect 1 vehicle
//
assertEquals(1, sim.getResult().size());
//
assertTrue(frames.size() > 0);
//
//
double initialBattery = frames.get(0).getBattery();
//
double finalBattery = frames.get(frames.size() - 1).getBattery();
//
// after charging, final battery percentage should be higher than initial
//
assertTrue(finalBattery > initialBattery);
//
}
@Test
public
void
testConfig
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment