ADD: added central kubernetes api class

This commit is contained in:
Henry Winkel
2023-12-21 17:15:28 +01:00
parent d1024de907
commit 351cf9ec69
12 changed files with 514 additions and 128 deletions

View File

@@ -3,17 +3,20 @@
#include "kubecontrol/KubePod.hpp"
#include "nlohmann/json_fwd.hpp"
#include <string>
#include <thread>
#include <vector>
#include <future>
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <kubecontrol/PodController.hpp>
#include <crossguid/guid.hpp>
void startShip(kubecontrol::PodController* podc,std::string Name, std::string lat, std::string lon)
void startShip(kubecontrol::PodController* podc,std::string uuid,std::string Name, std::string lat, std::string lon)
{
std::string uuid = xg::newGuid().str();
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest","simulator");
nlohmann::json vars;
@@ -36,14 +39,14 @@ std::string uuid = xg::newGuid().str();
podc->startPod(ShipPod1);
}
void createScenario(kubecontrol::PodController* podc)
void createScenario(kubecontrol::PodController* podc,std::vector<std::string> *uuidList)
{
// GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
double lat = 54, lon = 1;
int counter = 0;
double distance = 10000;
int rasterSize = 2;
int rasterSize = 5;
for (int i = 0; i < rasterSize; i++ )
{
@@ -58,8 +61,10 @@ void createScenario(kubecontrol::PodController* podc)
lat2= lat+10;
// SimCore::Identifier id;
// ids->push_back(id.getUUID());
startShip( podc,name, std::to_string(lat2), std::to_string(lon2));
std::string uuid = xg::newGuid().str();
uuidList->push_back(uuid);
// startShip( podc,uuid,name, std::to_string(lat2), std::to_string(lon2));
auto retrurn = std::async(std::launch::async, &startShip,podc,uuid,name, std::to_string(lat2), std::to_string(lon2));
// SimCore::Position pos;
// pos.setGeodesicPos(lat2, lon2, 0);
@@ -86,13 +91,24 @@ SCENARIO("Testing the SimCore Sensor")
{
kubecontrol::PodController podc("docs/config");
// kubecontrol::PodController podc("docs/config");
auto podc = new kubecontrol::PodController("docs/config");
std::vector<std::string> uuidList;
createScenario(&podc);
createScenario(podc, &uuidList);
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
LOG_S(INFO)<<"Amount Parent Pods: " << uuidList.size();
std::this_thread::sleep_for(std::chrono::milliseconds(20000));
// podc.stopPod(std::string Label)
podc.stopAllPods();
for (auto i: uuidList)
{
auto retrurn = std::async(std::launch::async, &kubecontrol::PodController::stopPod,podc,i);
}
// std::this_thread::sleep_for(std::chrono::milliseconds(20000));
podc->stopAllPods();
GIVEN("different Attributes for a Track in different forms")
{