Skip to content

Commit

Permalink
#257: support {noformat} and {code} in upper/lower cases
Browse files Browse the repository at this point in the history
Fixed #257
  • Loading branch information
dgroup committed Nov 16, 2020
1 parent bddecda commit 597749c
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/lazylead/task/accuracy/stacktrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def frames(description)
# Detect all noformat blocks and give all text snippets in array
# @param desc The jira ticket description
def noformat(desc)
return [] unless desc.include? "{noformat}"
desc.enum_for(:scan, /(?={noformat})/)
return [] unless desc.match?(/{(n|N)(o|O)(f|F)(o|O)(r|R)(m|M)(a|A)(t|T)}/)
desc.enum_for(:scan, /(?=\{(n|N)(o|O)(f|F)(o|O)(r|R)(m|M)(a|A)(t|T)})/)
.map { Regexp.last_match.offset(0).first }
.each_slice(2).map do |f|
desc[f.first, f.last - f.first + "{noformat}".size]
Expand All @@ -56,8 +56,8 @@ def noformat(desc)
# Detect all {code:*} blocks and give all text snippets in array
# @param desc The jira ticket description
def code(desc)
return [] unless desc.include?("{code:") || desc.include?("{code}")
words = desc.gsub(/{code/, " {code")
return [] unless desc.match?(/{(c|C)(o|O)(d|D)(e|E)(:\S+)?}/)
words = desc.gsub(/{(c|C)(o|O)(d|D)(e|E)/, " {code")
.gsub("}", "} ")
.gsub("Caused by:", "Caused_by:")
.split(" ")
Expand Down
132 changes: 132 additions & 0 deletions test/lazylead/task/accuracy/stacktrace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,36 @@ class StacktraceTest < Lazylead::Test
)
end

test "java stacktrace is found in uppercase" do
assert Stacktrace.new.passed(
OpenStruct.new(
description: "
XXXXXX env: http://xxxx.xxx.com:00000/
WL log [^clust1.log]
http://xxx.xxx.com/display/xxx/SQLException+No+more+data+to+read+from+socket
During call we found in clust1.log the following error
{NoFoRmAt}
at xxx.xxx.xxx.xxx.wrapper.XxxXxxXxxxXxx.xxxxXxxxXxxx(XxxXxxXxxxXxx.java:233)
at xxx.xxx.xxx.xxx.wrapper.XxxXxxXxxxXxx.xxxxXxxxXxxx(XxxXxxXxxxXxx.java:343)
... 318 more
Caused by: javax.transaction.TransactionRolledbackException: EJB Exception: ; nested exception is:
javax.ejb.TransactionRolledbackLocalException: EJB Exception:
at weblogic.utils.StackTraceDisabled.unknownMethod()
Caused by: javax.ejb.TransactionRolledbackLocalException: EJB Exception:
... 1 more
Caused by: javax.ejb.EJBException: java.sql.SQLRecoverableException: No more data to read from socket
... 1 more
Caused by: java.sql.SQLRecoverableException: No more data to read from socket
... 1 more
{NoFoRmAt}
The investigation is required.
More details here: XXXXX-xxxxxx"
)
)
end

test "stacktrace is found" do
assert Stacktrace.new.passed(
OpenStruct.new(
Expand Down Expand Up @@ -118,6 +148,21 @@ class StacktraceTest < Lazylead::Test
)
end

test "ORA error is found in uppercase" do
assert Stacktrace.new.passed(
OpenStruct.new(
description: "
{NOFORMAT}
@XXXX/xxx/xxx/xxxx_xxx_xxxxx_xxx_xx.sql
ORA-02291: 1 integrity constraint (XXX_XXX_XXX.XX_xxx) violated - xx xxx not found for xx_xx=xx xxxxx_xx=XXXXXXX xxxxx=XXXXXXXX xxx_xx=xxx xx_xxx=xxxx.xxx.xxx.xxxxx.xxx.xxx.xxxxx
XXXX-xxx-xxxx: xxxxx xxxxx Xxxxx xxxx Xxxx
{NOFORMAT}
XXXX - XXX_XXX.X.XXXX.XXXX.XXXX.XxxxxxXX.X_xxxXXXXXX"
)
)
end

test "java error is found in code section" do
assert Stacktrace.new.passed(
OpenStruct.new(
Expand Down Expand Up @@ -195,6 +240,93 @@ class StacktraceTest < Lazylead::Test
)
end

test "java error is found in code section in uppercase" do
assert Stacktrace.new.passed(
OpenStruct.new(
description: "
{CODE}javax.servlet.ServletException: Something went wrong
at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.example.myproject.ExceptionHandlerFilter.doFilter(ExceptionHandlerFilter.java:28)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.example.myproject.OutputBufferFilter.doFilter(OutputBufferFilter.java:33)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: com.example.myproject.MyProjectServletException
at com.example.myproject.MyServlet.doPost(MyServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:30)
... 27 more
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [com.example.myproject.MyEntity]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2329)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2822)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:705)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:693)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:689)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
at $Proxy19.save(Unknown Source)
at com.example.myproject.MyEntityService.save(MyEntityService.java:59) <-- relevant call (see notes below)
at com.example.myproject.MyServlet.doPost(MyServlet.java:164)
... 32 more
Caused by: java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
... 54 more{CODE}
"
)
)
end

test "java error is found in colored code section in uppercase" do
assert Stacktrace.new.passed(
OpenStruct.new(
description: "
{CODE:red}
Caused by: java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
... 54 more{CODE}
"
)
)
end

test "pair detected" do
assert_equal [[1, 4]],
Stacktrace.new.pairs(%w[aa tag bb cc tag dd], "tag")
Expand Down

0 comments on commit 597749c

Please sign in to comment.