Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Memory Appender, Log assertions in OpSparkListner #62

Closed
wants to merge 1 commit into from
Closed

Added Memory Appender, Log assertions in OpSparkListner #62

wants to merge 1 commit into from

Conversation

ajayborra
Copy link
Contributor

  • Added Memory Appender, Log assertions for OpSparkListner

@codecov
Copy link

codecov bot commented Aug 16, 2018

Codecov Report

Merging #62 into master will decrease coverage by <.01%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
- Coverage   85.79%   85.79%   -0.01%     
==========================================
  Files         298      299       +1     
  Lines        9760     9771      +11     
  Branches      326      533     +207     
==========================================
+ Hits         8374     8383       +9     
- Misses       1386     1388       +2
Impacted Files Coverage Δ
...cala/com/salesforce/op/test/TestSparkContext.scala 86.2% <100%> (+2.87%) ⬆️
.../scala/com/salesforce/op/test/MemoryAppender.scala 66.66% <66.66%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78a68a0...d889fa1. Read the comment docs.

import scala.collection.mutable

class MemoryAppender extends AppenderSkeleton {
private val _logs = new mutable.HashSet[spi.LoggingEvent]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. no need to prefix with _
  2. make this an ArrayBuffer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was using hash sets for constant inset and lookup times. Array buf's seems to be a good choice as well, will change it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashset would dedup and loose order, thereforce we cannot use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@@ -0,0 +1,74 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define this appender in the same file as OpSparkListenerTest - we dont need to expose it as it's currently only useful in one test.

@@ -44,6 +44,15 @@ trait TestSparkContext extends TempDirectoryTest with TestCommon {
classOf[com.salesforce.op.test.PassengerCSV]
)

val sparkLogAppender: MemoryAppender = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need this in every test. let's only use it in OpSparkListenerTest

@@ -12,3 +12,4 @@ log4j.logger.org.eclipse.jetty=ERROR

# TransmogrifAI logging
log4j.logger.com.salesforce.op=ERROR
log4j.logger.com.salesforce.op.utils.spark.OpSparkListener=INFO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can set this log4j.logger.com.salesforce.op.utils.spark.OpSparkListener=INFO programmatically in OpSparkListenerTest

* @param logMessage The log message
* @return Boolean of log existence
*/
def logExists(logLevel: Level, logMessage: String): Boolean = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit redundant. you can simply do this check in the test itself.

@ajayborra
Copy link
Contributor Author

Closing this PR in favor of #69. As the link b/w this PR and the branch on old fork broke, post making repo public.

@ajayborra ajayborra closed this Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants