Skip to content

Commit

Permalink
Merge branch 'develop' into offlineStoragePOC
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR authored Jan 31, 2024
2 parents a87bd97 + b22af29 commit e35b3fa
Show file tree
Hide file tree
Showing 47 changed files with 3,407 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CMakeFiles/
Makefile
Testing/
build/
examples/cocoapods/CocoapodsExample/Pods/

# idea project files
# Xcode
Expand Down Expand Up @@ -87,4 +88,3 @@ fastlane/test_output

iOSInjectionProject/
.DS_Store

71 changes: 62 additions & 9 deletions Agent/Harvester/DataStore/NRMAHarvesterConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,70 @@ - (id) initWithDictionary:(NSDictionary*)dict
self = [super init];
if (self) {
self.application_token = [dict valueForKey:kNRMA_LICENSE_KEY];
self.collect_network_errors = [[dict valueForKey:kNRMA_COLLECT_NETWORK_ERRORS] boolValue];

if ([dict objectForKey:kNRMA_COLLECT_NETWORK_ERRORS]) {
self.collect_network_errors = [[dict valueForKey:kNRMA_COLLECT_NETWORK_ERRORS] boolValue];
}
else {
self.collect_network_errors = NRMA_DEFAULT_COLLECT_NETWORK_ERRORS;
}

self.cross_process_id = [dict valueForKey:kNRMA_CROSS_PROCESS_ID];
self.data_report_period = [[dict valueForKey:kNRMA_DATA_REPORT_PERIOD] intValue];

if ([dict objectForKey:kNRMA_DATA_REPORT_PERIOD]) {
self.data_report_period = [[dict valueForKey:kNRMA_DATA_REPORT_PERIOD] intValue];
}
else {
self.data_report_period = NRMA_DEFAULT_REPORT_PERIOD;
}

self.data_token = [[NRMADataToken alloc] init];
self.data_token.clusterAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:0] longLongValue];
self.data_token.realAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:1] longLongValue];
self.error_limit = [[dict valueForKey:kNRMA_ERROR_LIMIT] intValue];
self.report_max_transaction_age = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE] intValue];
self.report_max_transaction_count = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]intValue];
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];

if ([dict objectForKey:kNRMA_ERROR_LIMIT]) {
self.error_limit = [[dict valueForKey:kNRMA_ERROR_LIMIT] intValue];
}
else {
self.error_limit = NRMA_DEFAULT_ERROR_LIMIT;
}

if ([dict objectForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE]) {

self.report_max_transaction_age = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE] intValue];
}
else {
self.report_max_transaction_age = NRMA_DEFAULT_MAX_TRANSACTION_AGE;
}
if ([dict objectForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]) {
self.report_max_transaction_count = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]intValue];
}
else {
self.report_max_transaction_count = NRMA_DEFAULT_MAX_TRANSACTION_COUNT;
}

if ([dict objectForKey:kNRMA_RESPONSE_BODY_LIMIT]) {
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
}
else {
self.response_body_limit = NRMA_DEFAULT_RESPONSE_BODY_LIMIT;
}

self.server_timestamp = [[dict valueForKey:kNRMA_SERVER_TIMESTAMP] longLongValue];
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];

if ([dict objectForKey:kNRMA_STACK_TRACE_LIMIT]) {
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
}
else {
self.stack_trace_limit = NRMA_DEFAULT_STACK_TRACE_LIMIT;
}
if ([dict objectForKey:kNRMA_AT_MAX_SIZE]) {
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];
}
else {
self.activity_trace_max_size = NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE;
}

self.at_capture = [[NRMATraceConfigurations alloc] initWithArray:[dict valueForKey:kNRMA_AT_CAPTURE]];
self.activity_trace_min_utilization = [[dict valueForKey:KNRMA_AT_MIN_UTILIZATION] doubleValue];
self.encoding_key = [dict valueForKey:kNRMA_ENCODING_KEY];
Expand Down Expand Up @@ -145,7 +196,9 @@ - (NSUInteger) hash
result = 31 * result + (unsigned int)self.account_id;
result = 31 * result + (unsigned int)self.application_id;
result = 31 * result + self.encoding_key.hash;

// Is this a chill addition?
result = 31 * result + self.trusted_account_key.hash;

return result;
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ - (void) testHarvestConfiguration
XCTAssertTrue([config isEqual:[[NRMAHarvesterConfiguration alloc] initWithDictionary:[config asDictionary]]], @"test asDictionary and initWithDictionary is correct");
}

- (void) testBadHarvestConfiguration {

// Test what happens if any value is missing from passed dictionary

NRMAHarvesterConfiguration* config = [[NRMAHarvesterConfiguration alloc] initWithDictionary:[NSDictionary dictionary]];
XCTAssertEqual(NRMA_DEFAULT_REPORT_PERIOD, config.data_report_period, @"A bad dictionary should parse default report period to its default.");
// if kNRMA_COLLECT_NETWORK_ERRORS is missing.
XCTAssertEqual(true, config.collect_network_errors, @"A bad dictionary should parse default report period to its default.");
// if kNRMA_ERROR_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_ERROR_LIMIT, config.error_limit, @"A bad dictionary should parse default error limit to its default.");
// if kNRMA_REPORT_MAX_TRANSACTION_AGE is missing
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_AGE, config.report_max_transaction_age, @"A bad dictionary should parse default max transaction aget limit to its default.");
// if kNRMA_REPORT_MAX_TRANSACTION_COUNT is missing
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_COUNT, config.report_max_transaction_count, @"A bad dictionary should parse max transactions to its default.");
// if kNRMA_RESPONSE_BODY_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_RESPONSE_BODY_LIMIT, config.response_body_limit, @"A bad dictionary should parse response body limit to its default.");
// if kNRMA_STACK_TRACE_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_STACK_TRACE_LIMIT, config.stack_trace_limit, @"A bad dictionary should parse response body limit to its default.");
// if kNRMA_AT_MAX_SIZE is missing
XCTAssertEqual(NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE, config.activity_trace_max_size, @"A bad dictionary should parse activity trace max size limit to its default.");
}

- (void) testActivityTraceConfiguration
{
NSArray* at_capture;
Expand Down
Loading

0 comments on commit e35b3fa

Please sign in to comment.