Skip to content

Commit

Permalink
Some test fixes
Browse files Browse the repository at this point in the history
I did a half hearted attempt running the tests.
But in short, they are not well documented.
And they are not included in CI, so will likely fail again.
  • Loading branch information
erikbosch authored and SebastianSchildt committed Jul 26, 2023
1 parent 1eac2db commit 1f426ca
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
8 changes: 4 additions & 4 deletions kuksa-val-server/test/stresstest/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
ip=127.0.0.1
port=8090
insecure=false
token=../../kuksa_certificates/jwt/all-read-write.json.token
token=../../../kuksa_certificates/jwt/all-read-write.json.token
timeout=0.1
certificate=../../kuksa_certificates/Client.pem
key=../../kuksa_certificates/Client.key
cacertificate=../../kuksa_certificates/CA.pem
certificate=../../../kuksa_certificates/Client.pem
#key=../../../kuksa_certificates/Client.key
root_ca_path=../../../kuksa_certificates/CA.pem
19 changes: 11 additions & 8 deletions kuksa-val-server/test/stresstest/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
import stressClient

vissClient = stressClient.StressClient()
count=0
count = 0

print("VSS Server : {}".format(vissClient.commThread.serverIP+':'+str(vissClient.commThread.serverPort)))
print("JWT token file : {}".format(vissClient.commThread.tokenfile))
print("VSS Server : {}".format(vissClient.commThread.backend.serverIP + ':' +
str(vissClient.commThread.backend.serverPort)))
print("JWT token file : {}".format(vissClient.commThread.backend.token_or_tokenfile))
print("Timeout [s] : {}".format(vissClient.commThread.timeout))

while True:
vissClient.commThread.setValue("Vehicle.OBD.EngineLoad", (count%110)+1,timeout=vissClient.commThread.timeout)
vissClient.commThread.setValue("Vehicle.Speed", count,timeout=vissClient.commThread.timeout)
vissClient.commThread.setValue("Vehicle.Cabin.Door.Row1.Right.Shade.Switch", "Open",timeout=vissClient.commThread.timeout)
vissClient.commThread.getValue("Vehicle.Speed",vissClient.commThread.timeout)

vissClient.commThread.setValue("Vehicle.OBD.EngineLoad", str((count % 110)+1),
timeout=vissClient.commThread.timeout)
vissClient.commThread.setValue("Vehicle.Speed", str(count), timeout=vissClient.commThread.timeout)
vissClient.commThread.setValue("Vehicle.Cabin.Door.Row1.Right.Shade.Switch", "Open",
timeout=vissClient.commThread.timeout)
vissClient.commThread.getValue("Vehicle.Speed", vissClient.commThread.timeout)

time.sleep(vissClient.commThread.timeout)
22 changes: 10 additions & 12 deletions kuksa-val-server/test/stresstest/stressClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

import configparser
import sys
import argparse
import time
from pickle import FALSE

from kuksa_client import *
from kuksa_client import KuksaClientThread


class StressClient():

Expand All @@ -34,25 +32,25 @@ def getConfig(self):
config = configparser.ConfigParser()
config.read('config.ini')

vsscfg = config['vss'] #get data from config file
vsscfg = config['vss'] # get data from config file

return vsscfg

def connect(self,cfg):
def connect(self, cfg):
"""Connect to the VISS Server"""
if hasattr(self, "commThread"):
if self.commThread != None:
if self.commThread is not None:
self.commThread.stop()
self.commThread = None
self.commThread = KuksaClientThread(self.cfg) #make new thread
self.commThread.start() #start thread
self.commThread = KuksaClientThread(self.cfg) # make new thread
self.commThread.start() # start thread

def __init__(self):
self.cfg = self.getConfig()
try:
self.connect(self.cfg)
self.commThread.timeout = self.cfg.getfloat("timeout", fallback=0.1) #get necessary timeout for stresstest
self.commThread.authorize(token=self.commThread.tokenfile)
except:
self.commThread.authorize()
self.commThread.timeout = self.cfg.getfloat("timeout", fallback=0.1) # get necessary timeout for stresstest
except Exception:
print("Could not connect successfully")
sys.exit(-1)
17 changes: 9 additions & 8 deletions kuksa-val-server/test/unit-test/SubscriptionHandlerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Robert Bosch GmbH
**********************************************************************/

#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test.hpp>

#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#include <turtle/mock.hpp>
Expand All @@ -34,8 +34,9 @@
#include <set>
#include <list>
#include <thread>
#include <fstream>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>

Expand Down Expand Up @@ -136,7 +137,7 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_SubscribeRequestOnDifferentPaths_Sh
VSSPath::fromVSSGen1("Vehicle.Acceleration"),
VSSPath::fromVSSGen1("Vehicle.Media"),
VSSPath::fromVSSGen1("Vehicle.Acceleration.Lateral") };


// expectations

Expand Down Expand Up @@ -204,7 +205,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_SubscribeRequestOnSinglePath_Sha
MOCK_EXPECT(dbMock->pathIsReadable)
.exactly(clientNum)
.with(vsspath)
.returns(true);
.returns(true);
MOCK_EXPECT(accCheckMock->checkReadAccess)
.exactly(clientNum)
.with(mock::any, vsspath)
Expand Down Expand Up @@ -321,7 +322,7 @@ BOOST_AUTO_TEST_CASE(Given_SingleClient_When_UnsubscribeRequestOnDifferentPaths_
MOCK_EXPECT(dbMock->pathIsReadable)
.once()
.with(vsspath[index])
.returns(true);
.returns(true);
MOCK_EXPECT(accCheckMock->checkReadAccess)
.once()
.with(mock::any, vsspath[index])
Expand Down Expand Up @@ -380,7 +381,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_Unsubscribe_Shall_UnsubscribeAll
MOCK_EXPECT(dbMock->pathIsReadable)
.exactly(clientNum)
.with(vsspath)
.returns(true);
.returns(true);
MOCK_EXPECT(accCheckMock->checkReadAccess)
.exactly(clientNum)
.with(mock::any, vsspath)
Expand Down Expand Up @@ -529,7 +530,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda
MOCK_EXPECT(dbMock->pathIsReadable)
.exactly(channelCount)
.with(vsspath[index])
.returns(true);
.returns(true);
MOCK_EXPECT(accCheckMock->checkReadAccess)
.exactly(channelCount)
.with(mock::any, vsspath[index])
Expand Down Expand Up @@ -627,7 +628,7 @@ BOOST_AUTO_TEST_CASE(Given_MultipleClients_When_MultipleSignalsSubscribedAndUpda
MOCK_EXPECT(dbMock->pathIsReadable)
.exactly(channelCount)
.with(vsspath[index])
.returns(true);
.returns(true);
MOCK_EXPECT(accCheckMock->checkReadAccess)
.exactly(channelCount)
.with(mock::any, vsspath[index])
Expand Down

0 comments on commit 1f426ca

Please sign in to comment.