Commit 04fa4be2 authored by Lais Frigerio's avatar Lais Frigerio

SCRUM#142 - Repair messages errors from windows test

Signed-off-by: 's avatarLais Frigerio <laaisfrigerio@gmail.com>
parent 8cc26d7f
Pipeline #12613 passed with stages
in 22 minutes and 4 seconds
......@@ -72,7 +72,6 @@ testDebian:
- cd ../test
- ./create_users.sh
- last -F
- cat /opt/agentC3SL/conf/datasid-conf.json
- ./returnTest.bats
dependencies:
- compileUnix
......@@ -88,7 +87,6 @@ testUbuntu:
- cd test
- ./create_users.sh
- last -F
- cat /opt/agentC3SL/conf/datasid-conf.json
- ./returnTest.bats
dependencies:
- compileUnix
......@@ -107,7 +105,6 @@ testOpensuse:
- cd test
- ./create_users.sh
- last -F
- cat /opt/agentC3SL/conf/datasid-conf.json
- ./returnTest.bats
dependencies:
- compileUnix
......@@ -117,12 +114,9 @@ testWin7:
tags:
- windows
script:
- DIR C:\
- if exist C:\agentC3SL rmdir C:\agentC3SL /s /q
- agent-1234.exe /SILENT /VERYSILENT
- if not exist C:\agentC3SL exit 1;
- DIR C:\agentC3SL
- DIR C:\agentC3SL\bin
- copy C:\jq-win32.exe .\test
- cd .\test
- C:\agentC3SL\bin\agent-v0.0.exe --once --print > test.json
......
......@@ -56,7 +56,7 @@
#endif
#ifndef prj
#define prj 'simmc-agent'
#define prj 'simmc'
#endif
#ifndef outputName
......
......@@ -25,6 +25,8 @@
* <br><br>
*/
extern std::string path_to_agent;
class Connection; // forward declarations
class Conf; // forward declarations
class Proxy; // forward declarations
......@@ -51,6 +53,7 @@ class Agent{
void setPathLogDir(std::string);
void setPathLogFile(std::string);
void setPrefix(std::string, int);
void setPrefix();
void setInstallerName(std::string);
void setConnection(Connection*);
void setConf(Conf*);
......
......@@ -29,7 +29,7 @@ namespace fs = boost::filesystem;
#ifdef __linux__
std::string path_to_agent_tmp = // NOLINT(runtime/string)
"/opt/agentC3SL/tmp/"; // NOLINT(runtime/string)
std::string path_to_agent = "/opt/"; // NOLINT(runtime/string)
std::string path_to_agent = "/opt/agentC3SL/"; // NOLINT(runtime/string)
//std::string path_to_agent_conf = // NOLINT(runtime/string)
//"/opt/agentC3SL/conf/"; // NOLINT(runtime/string)
std::string path_to_agent_conf = "/home/teste/Imagens/agent/conf/";
......@@ -38,7 +38,7 @@ namespace fs = boost::filesystem;
std::string path_to_agent_tmp = "C:\\agentC3SL\\tmp\\";
std::string path_to_agent = "C:\\agentC3SL\\";
std::string path_to_agent_conf = // NOLINT(runtime/string)
"C:\\agentC3SL\\conf\\"; // NOLINT(runtime/string)
"C:\\agentC3SL\\teste\\"; // NOLINT(runtime/string)
#endif
bool agent_send_inventory = false;
......@@ -65,7 +65,7 @@ int main(int, char**);
* - print - set print JSON to true - show inventory
* - uninstall - uninstall agent and all associated files
*/
int parse_command_line(int, char*, int*, int*, bool*);
int parse_command_line(int, char*, int*, int*, bool*, bool*);
bool read_config_files(Agent*);
......
......@@ -60,6 +60,11 @@ void Agent::setPrefix(std::string p, int tot) {
this->prefix = p.substr(0, i);
}
/** Set the absolute path from agent */
void Agent::setPrefix() {
this->prefix = path_to_agent;
}
/** Set the name to agent installer (.run (linux) or .exe (windows)) file */
void Agent::setInstallerName(std::string i) {
this->installerName = i;
......
......@@ -108,13 +108,14 @@ void config_agent() {
* - uninstall - uninstall agent and all associated files
*/
int parse_command_line(int ac, char* av[], int *increment, int *lim,
bool *print) {
bool *print, bool *dev) {
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("once", "run agent only once")
("print", "set print JSON to true")
("uninstall", "uninstall agent and all associated files");
("uninstall", "uninstall agent and all associated files")
("dev", "development environment");
po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
......@@ -132,6 +133,8 @@ int parse_command_line(int ac, char* av[], int *increment, int *lim,
} else {
*print = false;
}
if (vm.count("dev"))
*dev = true;
#ifdef __unix__
if (vm.count("uninstall")) {
......@@ -181,19 +184,25 @@ int main(int argc, char* argv[]) {
agent.setConf(&conf);
agent.setProxy(&proxy);
/* Set agent prefix (agent folder) */
agent.setPrefix(__FILE__, 3);
agent.setPathLogFile("/log/datasid-agent.log");
agent.logFile.open(agent.getPathLogFile().c_str(), std::fstream::app);
int increment = 0;
int lim = 1;
bool print;
bool dev = false;
pt::ptime begin;
if (parse_command_line(argc, argv, &increment, &lim, &print)) {
if (parse_command_line(argc, argv, &increment, &lim, &print, &dev)) {
return (1);
}
/* Set agent prefix (agent folder) */
if (dev) // __FILE__ macro get the path on compiler time
agent.setPrefix(__FILE__, 3);
else
agent.setPrefix();
agent.setPathLogFile("/log/datasid-agent.log");
agent.logFile.open(agent.getPathLogFile().c_str(), std::fstream::app);
config_agent();
set_begin(begin);
......
......@@ -74,6 +74,7 @@ FOR /f "delims=" %%a IN (test.json) DO (
REM Verificando o data_inventory json ...
ECHO Verificando o data_inventory json ...
type result.json
REM Check agent version
jq-win32.exe ".data_inventory.agent_version==\"1.0.0\"" result.json > result.txt
......@@ -117,7 +118,7 @@ set /p var=<result.txt
if %var%==false ( exit 1 ) else ( echo extra hds ok )
REM Check id point
jq-win32.exe ".data_inventory.id_point==\"1234\"" result.json > result.txt
jq-win32.exe ".data_inventory.id_point==1234" result.json > result.txt
set /p var=<result.txt
if %var%==false ( exit 1 ) else ( echo id point ok )
......@@ -225,4 +226,8 @@ if %var%==false ( exit 1 ) else ( echo packets tranmitted ok )
del result.txt
del result.json
del test.json
\ No newline at end of file
del test.json
REM uninstall agent
start C:\agentC3SL\uninstall_agent.exe /SILENT /VERYSILENT
dir /b /a "C:\agentC3SL\*" | >nul findstr "^" && (echo Agent has been uninstalled) || (exit 1);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment