This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 512
METRON-672: SolrIndexingIntegrationTest fails intermittently #424
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,10 @@ | |
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.google.common.base.Function; | ||
import com.google.common.collect.Iterables; | ||
import org.apache.curator.framework.CuratorFramework; | ||
import org.apache.metron.TestConstants; | ||
import org.apache.metron.common.Constants; | ||
import org.apache.metron.common.configuration.ConfigurationsUtils; | ||
import org.apache.metron.common.interfaces.FieldNameConverter; | ||
import org.apache.metron.common.spout.kafka.SpoutConfig; | ||
import org.apache.metron.common.utils.JSONUtils; | ||
|
@@ -37,13 +39,18 @@ | |
import org.apache.metron.integration.components.ZKServerComponent; | ||
import org.apache.metron.integration.utils.TestUtils; | ||
import org.apache.storm.hdfs.bolt.rotation.TimedRotationPolicy; | ||
import org.apache.zookeeper.KeeperException; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import javax.annotation.Nullable; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.*; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static org.apache.metron.common.configuration.ConfigurationsUtils.getClient; | ||
|
||
public abstract class IndexingIntegrationTest extends BaseIntegrationTest { | ||
protected String hdfsDir = "target/indexingIntegrationTest/hdfs"; | ||
|
@@ -139,11 +146,22 @@ public void test() throws Exception { | |
inputDocs.add(m); | ||
|
||
} | ||
final AtomicBoolean isLoaded = new AtomicBoolean(false); | ||
ConfigUploadComponent configUploadComponent = new ConfigUploadComponent() | ||
.withTopologyProperties(topologyProperties) | ||
.withGlobalConfigsPath(TestConstants.SAMPLE_CONFIG_PATH) | ||
.withEnrichmentConfigsPath(TestConstants.SAMPLE_CONFIG_PATH) | ||
.withIndexingConfigsPath(TestConstants.SAMPLE_CONFIG_PATH) | ||
.withPostStartCallback(component -> { | ||
try { | ||
waitForIndex(component.getTopologyProperties().getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
isLoaded.set(true); | ||
return null; | ||
} | ||
); | ||
; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you kill the extra semicolon? |
||
FluxTopologyComponent fluxComponent = new FluxTopologyComponent.Builder() | ||
.withTopologyLocation(new File(fluxPath)) | ||
|
@@ -166,10 +184,11 @@ public void test() throws Exception { | |
runner.start(); | ||
|
||
try { | ||
while(!isLoaded.get()) { | ||
Thread.sleep(100); | ||
} | ||
fluxComponent.submitTopology(); | ||
|
||
kafkaComponent.writeMessages(Constants.INDEXING_TOPIC, inputMessages); | ||
StringBuffer buffer = new StringBuffer(); | ||
List<Map<String, Object>> docs = cleanDocs(runner.process(getProcessor(inputMessages))); | ||
Assert.assertEquals(docs.size(), inputMessages.size()); | ||
//assert that our input docs are equivalent to the output docs, converting the input docs keys based | ||
|
@@ -184,6 +203,26 @@ public void test() throws Exception { | |
} | ||
} | ||
|
||
private void waitForIndex(String zookeeperQuorum) throws Exception { | ||
try(CuratorFramework client = getClient(zookeeperQuorum)) { | ||
client.start(); | ||
byte[] bytes = null; | ||
do { | ||
try { | ||
bytes = ConfigurationsUtils.readSensorIndexingConfigBytesFromZookeeper(testSensorType, client); | ||
Thread.sleep(1000); | ||
} | ||
catch(KeeperException.NoNodeException nne) { | ||
//kindly ignore because the path might not exist just yet. | ||
} | ||
} | ||
while(bytes == null || bytes.length == 0); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the return, since it's a void method. |
||
} | ||
|
||
|
||
} | ||
|
||
public List<Map<String, Object>> cleanDocs(ProcessorResult<List<Map<String, Object>>> result) { | ||
List<Map<String,Object>> docs = result.getResult(); | ||
StringBuffer buffer = new StringBuffer(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could this just use Consumer instead of Function? Since the second type parameter is Void, it seems like the Function is just being a Consumer anyway