ADD: add posibility to start a pod with multiple containers

This commit is contained in:
Henry Winkel
2024-03-12 15:23:37 +01:00
parent e38214f4d0
commit 263aaa6a71
4 changed files with 102 additions and 12 deletions

View File

@@ -3,6 +3,8 @@
#include "kubecontrol/PodController.hpp"
#include "nlohmann/json_fwd.hpp"
#include <memory>
#include <string>
#include <thread>
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
@@ -16,7 +18,8 @@ SCENARIO("Testing the SimCore Sensor")
// kubecontrol::PodController podc("docs/config");
kubecontrol::KubernetesAPI api(YAML::LoadFile("docs/config"));
std::string name = "hamburg";
std::string name = "componenttest1";
std::string uuid = name;
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest","simulator");
@@ -45,8 +48,39 @@ LOG_S(INFO)<<"Starting";
ShipPod1.start(api);
LOG_S(INFO)<<"started";
std::string name2 = "componenttest2";
kubecontrol::KubePod ShipPod2("controller",name2,"CMS","ship:latest","simulator");
nlohmann::json vars1;
vars1["ENTITY_ID"] = name2;
vars1["ENTITY_NAME"] = "FGS Hamburg";
vars1["ENTITY_SIDE"] = "Neutral";
vars1["POSITION"]["LAT"] = "55";
vars1["POSITION"]["LON"] = "8";
vars1["POSITION"]["Height"] = "0";
vars1["COURSE"] = "0";
vars1["SPEED"] = "0";
vars1["GROUNDTRUTH_PORT"] = std::to_string(10000);
vars1["GROUNDTRUTH_ADDR"] = "239.0.0.1";
vars1["COMMAND_PORT"] = "5555";
vars1["ENTITY_RCS"] = std::to_string(850);
vars["ENTITY_SENSORS"].push_back("radar:latest");
ShipPod2.setEnvironmentVar("CONFIG", vars1.dump());
auto envmaps2 = std::make_shared<std::map<std::string, std::string>>();
envmaps2->emplace("CONFIG", vars1.dump());
ShipPod2.addContainer("CMS", "systemprototype:latest",envmaps2);
ShipPod2.setEnvironmentVar("CONFIG", vars.dump());
LOG_S(INFO)<<"Starting multi container pod";
ShipPod2.start(api);
LOG_S(INFO)<<"started multi container pod";
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
GIVEN("different Attributes for a Track in different forms")
{
@@ -55,7 +89,8 @@ std::this_thread::sleep_for(std::chrono::milliseconds(5000));
THEN("check if Track attributes are correct")
{
REQUIRE(ShipPod1.getUUID() == "hamburg");
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
REQUIRE(ShipPod1.getUUID() == name);
REQUIRE(ShipPod1.getName() == name);
REQUIRE(ShipPod1.getComponent() == "ship");
@@ -69,6 +104,7 @@ std::this_thread::sleep_for(std::chrono::milliseconds(5000));
ShipPod1.stop(api);
ShipPod2.stop(api);