Add unittest to IXSentryClient to lua backtrace parsing code
This commit is contained in:
parent
bbfa76a2c9
commit
081dd2c4bb
@ -1 +1 @@
|
|||||||
7.2.0
|
7.2.1
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [7.2.1] - 2019-10-26
|
||||||
|
|
||||||
|
- Add unittest to IXSentryClient to lua backtrace parsing code
|
||||||
|
|
||||||
## [7.2.0] - 2019-10-24
|
## [7.2.0] - 2019-10-24
|
||||||
|
|
||||||
- Add cobra_metrics_to_redis sub-command to create streams for each cobra metric event being received.
|
- Add cobra_metrics_to_redis sub-command to create streams for each cobra metric event being received.
|
||||||
|
@ -17,7 +17,7 @@ namespace ix
|
|||||||
SentryClient::SentryClient(const std::string& dsn)
|
SentryClient::SentryClient(const std::string& dsn)
|
||||||
: _dsn(dsn)
|
: _dsn(dsn)
|
||||||
, _validDsn(false)
|
, _validDsn(false)
|
||||||
, _luaFrameRegex("\t([^/]+):([0-9]+): in function '([^/]+)'")
|
, _luaFrameRegex("\t([^/]+):([0-9]+): in function ['<]([^/]+)['>]")
|
||||||
{
|
{
|
||||||
const std::regex dsnRegex("(http[s]?)://([^:]+):([^@]+)@([^/]+)/([0-9]+)");
|
const std::regex dsnRegex("(http[s]?)://([^:]+):([^@]+)@([^/]+)/([0-9]+)");
|
||||||
std::smatch group;
|
std::smatch group;
|
||||||
|
@ -21,14 +21,14 @@ namespace ix
|
|||||||
|
|
||||||
std::pair<HttpResponsePtr, std::string> send(const Json::Value& msg, bool verbose);
|
std::pair<HttpResponsePtr, std::string> send(const Json::Value& msg, bool verbose);
|
||||||
|
|
||||||
|
Json::Value parseLuaStackTrace(const std::string& stack);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t getTimestamp();
|
int64_t getTimestamp();
|
||||||
std::string computeAuthHeader();
|
std::string computeAuthHeader();
|
||||||
std::string getIso8601();
|
std::string getIso8601();
|
||||||
std::string computePayload(const Json::Value& msg);
|
std::string computePayload(const Json::Value& msg);
|
||||||
|
|
||||||
Json::Value parseLuaStackTrace(const std::string& stack);
|
|
||||||
|
|
||||||
std::string _dsn;
|
std::string _dsn;
|
||||||
bool _validDsn;
|
bool _validDsn;
|
||||||
std::string _url;
|
std::string _url;
|
||||||
|
@ -2,28 +2,38 @@
|
|||||||
* IXSentryClientTest.cpp
|
* IXSentryClientTest.cpp
|
||||||
* Author: Benjamin Sergeant
|
* Author: Benjamin Sergeant
|
||||||
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
||||||
|
*
|
||||||
|
* (cd .. ; make) && ../build/test/ixwebsocket_unittest sentry
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IXTest.h"
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <ixsentry/IXSentryClient.h>
|
||||||
|
|
||||||
using namespace ix;
|
using namespace ix;
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
TEST_CASE("sentry", "[sentry]")
|
TEST_CASE("sentry", "[sentry]")
|
||||||
{
|
{
|
||||||
SECTION("Attempt to perform nil")
|
SECTION("Attempt to index nil")
|
||||||
{
|
{
|
||||||
#if 0
|
SentryClient sentryClient("");
|
||||||
SentryClient sentryClient;
|
std::string stack = "Attempt to index nil[overlay]!\nstack traceback:\n\tfoo.lua:2661: in function 'getFoo'\n\tfoo.lua:1666: in function 'onUpdate'\n\tfoo.lua:1751: in function <foo.lua:1728>";
|
||||||
std::string stack = "";
|
|
||||||
auto frames = sentryClient.parseLuaStackTrace(stack);
|
auto frames = sentryClient.parseLuaStackTrace(stack);
|
||||||
|
|
||||||
REQUIRE(frames.size() > 0);
|
REQUIRE(frames.size() == 3);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
SECTION("Attempt to perform nil")
|
||||||
|
{
|
||||||
|
SentryClient sentryClient("");
|
||||||
|
std::string stack = "Attempt to perform nil - 1572111278.299\nstack traceback:\n\tfoo.lua:57: in function <foo.lua:53>";
|
||||||
|
auto frames = sentryClient.parseLuaStackTrace(stack);
|
||||||
|
|
||||||
|
REQUIRE(frames.size() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user