Skip to content

Commit

Permalink
Fix TR logging when cqhv field is absent (#7340)
Browse files Browse the repository at this point in the history
* Fix TR logging when cqhv field is absent

* fix changelog

* code review
  • Loading branch information
srijeet0406 authored Feb 3, 2023
1 parent 709fd18 commit 3aca837
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7044](https://github.com/apache/trafficcontrol/issues/7044) *CDN in a Box* [CDN in a Box, the t3c integration tests, and the tc health client integration tests now use Apache Traffic Server 9.1.

### Fixed
- [#7340](https://github.com/apache/trafficcontrol/pull/7340) *Traffic Router* Fixed TR logging for the `cqhv` field when absent.
- [#5557](https://github.com/apache/trafficcontrol/issues/5557) *Traffic Portal* Moved `Fair Queueing Pacing Rate Bps` DS field to `Cache Configuration Settings` section.
- [#7252](https://github.com/apache/trafficcontrol/issues/7252) *Traffic Router* Fixed integer overflow for `czCount`, by resetting the count to max value when it overflows.
- [#7221](https://github.com/apache/trafficcontrol/issues/7221) *Docs* Fixed request structure spec in cdn locks description in APIv4.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static String formatRequest(final HttpServletRequest request) {
}

private static String formatObject(final Object o) {
return (o == null) ? "-" : o.toString();
return (o == null || o.toString().equals("")) ? "-" : o.toString();
}

private static String formatRequestHeaders(final Map<String, String> requestHeaders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,21 @@ public void itGeneratesAccessEvents() throws Exception {
HTTPAccessRecord httpAccessRecord = builder.build();

String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);

assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rurls=\"-\" uas=\"null\" svc=\"-\" rh=\"-\""));
}

@Test
public void itGeneratesAccessEventsWithCorrectCqhvDefaultValues() throws Exception {
HTTPAccessRecord.Builder builder = new HTTPAccessRecord.Builder(new Date(144140678000L), request);
HTTPAccessRecord httpAccessRecord = builder.build();
when(request.getProtocol()).thenReturn(null);
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=- rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rurls=\"-\" uas=\"null\" svc=\"-\" rh=\"-\""));
when(request.getProtocol()).thenReturn("");
httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=- rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rurls=\"-\" uas=\"null\" svc=\"-\" rh=\"-\""));
}

@Test
public void itAddsResponseData() throws Exception {
Answer<Long> nanoTimeAnswer = new Answer<Long>() {
Expand Down

0 comments on commit 3aca837

Please sign in to comment.