Skip to content

Commit

Permalink
Orion-LD added to the version output (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli authored Jan 16, 2020
1 parent 1803661 commit 095b691
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 127 deletions.
7 changes: 4 additions & 3 deletions src/app/orionld/orionld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ void exitFunc(void)
*/
const char* description =
"\n"
"Orion context broker version details:\n"
" version: " ORION_VERSION "\n"
"Orion-LD context broker version details:\n"
" orionld version: " ORIONLD_VERSION "\n"
" orion version: " ORION_VERSION "\n"
" git hash: " GIT_HASH "\n"
" compile time: " COMPILE_TIME "\n"
" compiled by: " COMPILED_BY "\n"
Expand Down Expand Up @@ -849,7 +850,7 @@ int main(int argC, char* argV[])
paConfig("man synopsis", (void*) "[options]");
paConfig("man shortdescription", (void*) "Options:");
paConfig("man description", (void*) description);
paConfig("man author", (void*) "Telefonica I+D");
paConfig("man author", (void*) "Telefonica I+D and FIWARE Foundation");
paConfig("man version", (void*) versionString.c_str());
paConfig("log to file", (void*) true);
paConfig("log file line format", (void*) LOG_FILE_LINE_FORMAT);
Expand Down
8 changes: 8 additions & 0 deletions src/lib/orionld/common/orionldState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ extern "C"



// -----------------------------------------------------------------------------
//
// orionldVersion -
//
const char* orionldVersion = ORIONLD_VERSION;



// -----------------------------------------------------------------------------
//
// orionldState - the state of the connection
Expand Down
41 changes: 25 additions & 16 deletions src/lib/orionld/common/orionldState.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ extern "C"



// -----------------------------------------------------------------------------
//
// ORIONLD_VERSION -
//
#define ORIONLD_VERSION "v0.1.0-alpha"



// -----------------------------------------------------------------------------
//
// Forward declarations -
Expand Down Expand Up @@ -224,22 +232,23 @@ extern __thread OrionldConnectionState orionldState;
//
// Global state
//
extern char orionldHostName[128];
extern int orionldHostNameLen;
extern char kallocBuffer[32 * 1024];
extern int requestNo; // Never mind protecting with semaphore. Just a debugging help
extern KAlloc kalloc;
extern Kjson kjson;
extern Kjson* kjsonP;
extern uint16_t portNo;
extern char dbName[]; // From orionld.cpp
extern int dbNameLen;
extern char dbUser[]; // From orionld.cpp
extern char dbPwd[]; // From orionld.cpp
extern bool multitenancy; // From orionld.cpp
extern char* tenant; // From orionld.cpp
extern int contextDownloadAttempts; // From orionld.cpp
extern int contextDownloadTimeout; // From orionld.cpp
extern char orionldHostName[128];
extern int orionldHostNameLen;
extern char kallocBuffer[32 * 1024];
extern int requestNo; // Never mind protecting with semaphore. Just a debugging help
extern KAlloc kalloc;
extern Kjson kjson;
extern Kjson* kjsonP;
extern uint16_t portNo;
extern char dbName[]; // From orionld.cpp
extern int dbNameLen;
extern char dbUser[]; // From orionld.cpp
extern char dbPwd[]; // From orionld.cpp
extern bool multitenancy; // From orionld.cpp
extern char* tenant; // From orionld.cpp
extern int contextDownloadAttempts; // From orionld.cpp
extern int contextDownloadTimeout; // From orionld.cpp
extern const char* orionldVersion;



Expand Down
19 changes: 14 additions & 5 deletions src/lib/orionld/serviceRoutines/orionldGetVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ extern "C"
#include "logMsg/traceLevels.h" // Lmt*

#include "rest/ConnectionInfo.h" // ConnectionInfo
#include "orionld/common/orionldState.h" // orionldState
#include "serviceRoutines/versionTreat.h" // versionGet
#include "orionld/common/orionldState.h" // orionldState, orionldVersion
#include "orionld/common/branchName.h" // ORIONLD_BRANCH
#include "orionld/serviceRoutines/orionldGetVersion.h" // Own Interface

Expand Down Expand Up @@ -79,16 +80,20 @@ void mhdVersionGet(char* buff, int buflen, int iVersion)
//
bool orionldGetVersion(ConnectionInfo* ciP)
{
KjNode* nodeP;
char mhdVersion[32];
KjNode* nodeP;
char mhdVersion[32];
curl_version_info_data* curlVersionP;

mhdVersionGet(mhdVersion, sizeof(mhdVersion), MHD_VERSION);

orionldState.responseTree = kjObject(orionldState.kjsonP, NULL);

// Branch
nodeP = kjString(orionldState.kjsonP, "branch", ORIONLD_BRANCH);
// Orion-LD version
nodeP = kjString(orionldState.kjsonP, "Orion-LD version", orionldVersion);
kjChildAdd(orionldState.responseTree, nodeP);

// Orion version
nodeP = kjString(orionldState.kjsonP, "based on orion", versionGet());
kjChildAdd(orionldState.responseTree, nodeP);

// K-Lib versions
Expand Down Expand Up @@ -124,6 +129,10 @@ bool orionldGetVersion(ConnectionInfo* ciP)
nodeP = kjString(orionldState.kjsonP, "libuuid version", "UNKNOWN");
kjChildAdd(orionldState.responseTree, nodeP);

// Branch
nodeP = kjString(orionldState.kjsonP, "branch", ORIONLD_BRANCH);
kjChildAdd(orionldState.responseTree, nodeP);

//
// Opening and closing an arbitrary file (/etc/passwd) only to see the next non-open
// file descriptor.
Expand Down
22 changes: 12 additions & 10 deletions src/lib/serviceRoutines/versionTreat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "common/tag.h"
#include "common/compileInfo.h"
#include "common/defaultValues.h"
#include "orionld/common/orionldState.h"
#include "rest/HttpHeaders.h"
#include "rest/rest.h"

Expand All @@ -59,6 +60,8 @@ void versionSet(const char* version)
strncpy(versionString, version, sizeof(versionString));
}



/* ****************************************************************************
*
* versionGet -
Expand Down Expand Up @@ -108,16 +111,15 @@ std::string versionTreat
#endif

out += "{\n";
out += "\"orion\" : {\n";
out += " \"version\" : \"" + std::string(versionString) + "\",\n";
out += " \"uptime\" : \"" + std::string(uptime) + "\",\n";
out += " \"git_hash\" : \"" + std::string(GIT_HASH) + "\",\n";
out += " \"compile_time\" : \"" + std::string(COMPILE_TIME) + "\",\n";
out += " \"compiled_by\" : \"" + std::string(COMPILED_BY) + "\",\n";
out += " \"compiled_in\" : \"" + std::string(COMPILED_IN) + "\",\n";
out += " \"release_date\" : \"" + std::string(RELEASE_DATE) + "\",\n";
out += " \"doc\" : \"" + std::string(API_DOC) + "\"\n";
out += "}\n";
out += " \"orionld version\": \"" + std::string(orionldVersion) + "\",\n";
out += " \"orion version\": \"" + std::string(versionString) + "\",\n";
out += " \"uptime\": \"" + std::string(uptime) + "\",\n";
out += " \"git_hash\": \"" + std::string(GIT_HASH) + "\",\n";
out += " \"compile_time\": \"" + std::string(COMPILE_TIME) + "\",\n";
out += " \"compiled_by\": \"" + std::string(COMPILED_BY) + "\",\n";
out += " \"compiled_in\": \"" + std::string(COMPILED_IN) + "\",\n";
out += " \"release_date\": \"" + std::string(RELEASE_DATE) + "\",\n";
out += " \"doc\": \"" + std::string(API_DOC) + "\"\n";
out += "}\n";

ciP->httpStatusCode = SccOk;
Expand Down
2 changes: 1 addition & 1 deletion test/functionalTest/cases/0000_cli/version.test
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
General Public License for more details.

Telefonica I+D
Telefonica I+D and FIWARE Foundation
--TEARDOWN--
38 changes: 18 additions & 20 deletions test/functionalTest/cases/0000_ipv6_support/ipv4_ipv6_both.test
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"orion" : {
"version" : "REGEX(.*)",
"uptime" : "REGEX(.*)",
"git_hash" : "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time" : "REGEX(.*)",
"compiled_by" : "REGEX(.*)",
"compiled_in" : "REGEX(.*)",
"release_date" : "REGEX(.*)",
"doc" : "REGEX(.*)
}
"orionld version": "REGEX(.*)",
"orion version": "REGEX(.*)",
"uptime": "REGEX(.*)",
"git_hash": "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time": "REGEX(.*)",
"compiled_by": "REGEX(.*)",
"compiled_in": "REGEX(.*)",
"release_date": "REGEX(.*)",
"doc": "REGEX(.*)
}

2: ++++++++++++++++++++
Expand All @@ -156,16 +155,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"orion" : {
"version" : "REGEX(.*)",
"uptime" : "REGEX(.*)",
"git_hash" : "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time" : "REGEX(.*)",
"compiled_by" : "REGEX(.*)",
"compiled_in" : "REGEX(.*)",
"release_date" : "REGEX(.*)",
"doc" : "REGEX(.*)
}
"orionld version": "REGEX(.*)",
"orion version": "REGEX(.*)",
"uptime": "REGEX(.*)",
"git_hash": "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time": "REGEX(.*)",
"compiled_by": "REGEX(.*)",
"compiled_in": "REGEX(.*)",
"release_date": "REGEX(.*)",
"doc": "REGEX(.*)
}

3: ++++++++++++++++++++
Expand Down
19 changes: 9 additions & 10 deletions test/functionalTest/cases/0000_ngsild/ngsild_issue_0044.test
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"orion": {
"compile_time": "REGEX(.*)",
"compiled_by": "REGEX(.*)",
"compiled_in": "REGEX(.*)",
"doc": "https://fiware-orion.readthedocs.org/en/master/",
"git_hash": "REGEX(.*)",
"release_date": "REGEX(.*)",
"uptime": "REGEX(.*)",
"version": "REGEX(.*)"
}
"compile_time": "REGEX(.*)",
"compiled_by": "REGEX(.*)",
"compiled_in": "REGEX(.*)",
"doc": "https://fiware-orion.readthedocs.org/en/master/",
"git_hash": "REGEX(.*)",
"orion version": "REGEX(.*)"
"orionld version": "REGEX(.*)"
"release_date": "REGEX(.*)",
"uptime": "REGEX(.*)"
}


Expand Down
2 changes: 2 additions & 0 deletions test/functionalTest/cases/0000_ngsild/ngsild_issue_0065.test
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Date: REGEX(.*)

{
"Next File Descriptor": REGEX(\d+),
"Orion-LD version": "REGEX(.*)",
"based on orion": "REGEX(.*)",
"boost version": "REGEX(.*)",
"branch": "REGEX(.*)",
"kalloc version": "REGEX(.*)",
Expand Down
6 changes: 4 additions & 2 deletions test/functionalTest/cases/0000_ngsild/ngsild_version.test
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ echo

echo "02. Make sure the branch output from Step 01 is the same as current branch"
echo "=========================================================================="
branchAccordingToBroker=$(echo $_response | awk -F\" '{ print $4 }')
branchAccordingToBroker=$(echo $_response | awk -F\"branch\" '{ print $2 }' | awk -F\" '{ print $2 }')
branchAccordingToGit=$(git branch | grep ^\* | awk '{ print $2 }')
if [ "$branchAccordingToBroker" != "$branchAccordingToGit" ]
then
Expand All @@ -67,7 +67,8 @@ Content-Type: application/json
Date: REGEX(.*)

{
"branch": "REGEX(.*)",
"Orion-LD version": "REGEX(.*)",
"based on orion": "REGEX(.*)",
"kbase version": "0.2",
"kalloc version": "0.2",
"kjson version": "0.2",
Expand All @@ -78,6 +79,7 @@ Date: REGEX(.*)
"rapidjson version": "REGEX(.*)",
"libcurl version": "REGEX(.*)",
"libuuid version": "UNKNOWN",
"branch": "REGEX(.*)",
"Next File Descriptor": REGEX(\d+)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"orion" : {
"version" : "REGEX(.*)",
"uptime" : "REGEX(.*)",
"git_hash" : "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time" : "REGEX(.*)",
"compiled_by" : "REGEX(.*)",
"compiled_in" : "REGEX(.*)",
"release_date" : "REGEX(.*)",
"doc" : "REGEX(.*)"
}
"orionld version": "REGEX(.*)",
"orion version": "REGEX(.*)",
"uptime": "REGEX(.*)",
"git_hash": "REGEX(([0-9a-f]{40}|nogitversion))",
"compile_time": "REGEX(.*)",
"compiled_by": "REGEX(.*)",
"compiled_in": "REGEX(.*)",
"release_date": "REGEX(.*)",
"doc": "REGEX(.*)"
}

--TEARDOWN--
Expand Down
Loading

0 comments on commit 095b691

Please sign in to comment.