-
Notifications
You must be signed in to change notification settings - Fork 14
SDAP-161 MUDROD embedded unit test #35
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
base: master
Are you sure you want to change the base?
Conversation
|
Can one of the admins verify this patch? |
|
@fgreg @lewismc Could you please take a look at the code. As I mentioned in the last meeting, the EmbeddedElasticsearchServer can not work in the code and I can not fix it. Could anyone help me to figure out what the problem is? If you compile the code, please use command "mvn clean install -Dskiptests", or the unit test will fail. I run these unit test cases with eclipses and a elasticsearch engine installed on my computer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quintinali please please please remember. The source code is formatted at 2 space indents not 4. Please ensure that your code is formatted to 2 space indents.
Please see my comments... there is a lot we need to improve here before we can go forward.
| LOG.info("Processing logs dated {}", anInputList); | ||
|
|
||
| DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, this.spark); | ||
| /* DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, this.spark); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the issue SDAP-161 is described as being MUDROD embedded unit test there should therefore be no code other than en embedded Unit test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, if you are going to comment out code that you do not intend to use... just remove it.
|
|
||
| DiscoveryStepAbstract hg = new HistoryGenerator(this.props, this.es, this.spark); | ||
| hg.execute(); | ||
| /*DiscoveryStepAbstract hg = new HistoryGenerator(this.props, this.es, this.spark); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here...
| } catch (Exception e) { | ||
| HelpFormatter formatter = new HelpFormatter(); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is buggy. We just want to throw the Exception... not continuously print the help arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quintinali please address this. It should not throw help. It should through the Exception e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lewismc In my computer, the old code (
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true)) comes with an error “The method printHelp(String, Options) in the type HelpFormatter is not applicable for the arguments (String, boolean)”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK what I am saying is that this code should be changed to the following
} catch (Exception e) {
throw new RuntimeException(e)
}
...or something similar.
core/src/main/java/org/apache/sdap/mudrod/weblog/pre/SessionStatistic.java
Show resolved
Hide resolved
|
|
||
| public class RequestUrlTest { | ||
|
|
||
| // @BeforeClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never leave code commented out like this it is extremely untidy.
| @Test | ||
| public void testuRLRequest() { | ||
| RequestUrl url = new RequestUrl(); | ||
| String strURL = "https://podaac.jpl.nasa.gov/datasetlist?ids=Collections:Measurement:SpatialCoverage:Platform:Sensor&values=SCAT_BYU_L3_OW_SIGMA0_ENHANCED:Sea%20Ice:Bering%20Sea:ERS-2:AMI&view=list"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not a constant?
core/src/test/java/org/apache/sdap/mudrod/weblog/structure/log/GeoIpTest.java
Show resolved
Hide resolved
| @@ -0,0 +1,18 @@ | |||
| package org.apache.sdap.mudrod.weblog.structure.log; | |||
|
|
|||
| import static org.junit.Assert.*; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never use wildcard imports.
| Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot ship binary code inside of source code management... the resources below should be decompressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is there any reason we are using logs from 2015? Why not 2018?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot understand which resource do you mean should be decompressed? There is not a specific reason for choosing logs from 2015.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/FTP.201502.w1.gz and
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/WWW.201502.w1.gz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have not addressed this issue. The files should not be in the compressed form... you need to decompress them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered that @fgreg has added a function of decompressing zip log file for MUDROD. And the test code can parse the two gz. file. If you need, I can depress them for you. Is it necessary?
1. formatter 2. remove useless import
|
@lewismc I revised the code as you required. Could you please take a look at the unit test cases and please let me know whether they are the test case your team needs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quintinali thanks for making some updates. Please see the remainder of my comments.
| } catch (Exception e) { | ||
| HelpFormatter formatter = new HelpFormatter(); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quintinali please address this. It should not throw help. It should through the Exception e
core/src/main/java/org/apache/sdap/mudrod/weblog/pre/SessionStatistic.java
Show resolved
Hide resolved
| String viewquery = ""; | ||
| try { | ||
| String infoStr = requestURL.getSearchInfo(viewnode.getRequest()); | ||
| //String infoStr = requestURL.getSearchInfo(viewnode.getRequest()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to resolve this.
|
|
||
| @AfterClass | ||
| public static void tearDown() { | ||
| // TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove TODO and method if nothing happens here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve most issued metioned above except the first one. In my computer, the old code (
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true)) comes with an error “The method printHelp(String, Options) in the type HelpFormatter is not applicable for the arguments (String, boolean)”
| public void testDeleteAllByQuery() { | ||
| es.deleteAllByQuery("mudrod", "MetadataLinkage", QueryBuilders.matchAllQuery()); | ||
|
|
||
| // String res = es.searchByQuery("mudrod", "MetadataLinkage", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| /* | ||
| * @Test public void testMakeClient() { | ||
| * | ||
| * try { Client client = es.makeClient(mudrodEngine.loadConfig()); assert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove if not used. Why is it not being used?
| /* | ||
| * @Test public void testSetClient() { | ||
| * | ||
| * try { Client client = es.makeClient(mudrodEngine.loadConfig()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove if not being used... why is it not being used?
| * tests are implemented, this is merely in place to get the JaCoCo test reporting to | ||
| * work. | ||
| * Initial test case for {@link org.apache.sdap.mudrod.main.MudrodEngine}, | ||
| * currently no tests are implemented, this is merely in place to get the JaCoCo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no tests are implemented then this is a TODO and a JIRA issue should be logged such that someone knows that a test needs to be written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I delete the test class for MudrodEngine and will add it in the future
| Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/FTP.201502.w1.gz and
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/WWW.201502.w1.gz
|
@lewismc I solved most issued based on your comments. Could you please take a look at my explanation when you have time, especially for this one #35 (comment) Besides, sorry that I missed some comments before since some conversations were displayed in a hidden mode and I didn't notice that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for update @quintinali please see my new comments.
| } catch (Exception e) { | ||
| HelpFormatter formatter = new HelpFormatter(); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true); | ||
| formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK what I am saying is that this code should be changed to the following
} catch (Exception e) {
throw new RuntimeException(e)
}
...or something similar.
| } | ||
|
|
||
| private static String getTestDataPath() { | ||
| File resourcesDirectory = new File("src/test/resources/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be addressed using the ClassLoader. Something like
getClass().getClassLoader().getResource... or getResourceAsStream...
You need to make this change rather than passing around File objects OK.
| return node.client(); | ||
| } | ||
|
|
||
| public void shutdown() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this method if it has no content and you are not overriding anything.
| import org.junit.BeforeClass; | ||
|
|
||
| /** | ||
| * This is a helper class the starts an embedded elasticsearch server for each |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you have addressed the comments here fully I will test the code locally and provide input as to why it is not working.
|
|
||
| @Test | ||
| public void testCustomAnalyzingStringString() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
|
|
||
| @Test | ||
| public void testGenerateUpdateRequestStringStringStringMapOfStringObject() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
|
|
||
| @Test | ||
| public void testGetDocCountStringStringArray() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
|
|
||
| @Test | ||
| public void testGetDocCountStringArrayStringArray() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
|
|
||
| @Test | ||
| public void testGetDocCountStringArrayStringArrayQueryBuilder() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
| Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have not addressed this issue. The files should not be in the compressed form... you need to decompress them.
|
@lewismc I revised code based on your comments. Please take a look at the embedded elasticsearch engine when you have time. Thanks. For the compressed logs, MUDROD has the capability to decompress them. Please check the attached figure. |
Fitting bugs
# Conflicts: # core/src/main/java/org/apache/sdap/mudrod/main/MudrodEngine.java # core/src/test/java/org/apache/sdap/mudrod/weblog/structure/TestApacheAccessLog.java

test case for log ingestion and preprocessing