This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/flume.git
The following commit(s) were added to refs/heads/trunk by this push:
new 89ddb2a Fix unit tests
89ddb2a is described below
commit 89ddb2a18380af0576531af69d6a48ce44f264a8
Author: rgoers <[email protected]>
AuthorDate: Sat Oct 30 23:10:20 2021 -0700
Fix unit tests
---
.../java/org/apache/flume/node/HttpConfigurationSource.java | 4 ++++
.../org/apache/flume/node/TestHttpConfigurationSource.java | 7 +++++--
.../java/org/apache/flume/test/agent/TestSpooldirSource.java | 10 +++++++++-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git
a/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java
b/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java
index 6beafe3..0c2896a 100644
---
a/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java
+++
b/flume-ng-node/src/main/java/org/apache/flume/node/HttpConfigurationSource.java
@@ -36,6 +36,7 @@ public class HttpConfigurationSource implements
ConfigurationSource {
private static final Logger LOGGER =
LoggerFactory.getLogger(HttpConfigurationSource.class);
private static final int NOT_MODIFIED = 304;
+ private static final int NOT_AUTHORIZED = 401;
private static final int OK = 200;
private static final int BUF_SIZE = 1024;
@@ -118,6 +119,9 @@ public class HttpConfigurationSource implements
ConfigurationSource {
throw new ConfigurationException("Unable to access " +
uri.toString(), e);
}
}
+ case NOT_AUTHORIZED: {
+ throw new ConfigurationException("Authorization failed");
+ }
default: {
if (code < 0) {
LOGGER.info("Invalid response code returned");
diff --git
a/flume-ng-node/src/test/java/org/apache/flume/node/TestHttpConfigurationSource.java
b/flume-ng-node/src/test/java/org/apache/flume/node/TestHttpConfigurationSource.java
index b128116..c6b607a 100644
---
a/flume-ng-node/src/test/java/org/apache/flume/node/TestHttpConfigurationSource.java
+++
b/flume-ng-node/src/test/java/org/apache/flume/node/TestHttpConfigurationSource.java
@@ -78,7 +78,7 @@ public class TestHttpConfigurationSource {
@Test(expected = ConfigurationException.class)
public void testBadCrdentials() throws Exception {
- URI confFile = new URI("http://localhost/flume-conf.properties");
+ URI confFile = new URI("http://localhost:1080/flume-conf.properties");
AuthorizationProvider authProvider = new BasicAuthorizationProvider("foo",
"bar");
ConfigurationSource source = new HttpConfigurationSource(confFile,
authProvider, true);
}
@@ -118,7 +118,10 @@ public class TestHttpConfigurationSource {
String authData = headers.nextElement();
Assert.assertTrue("Not a Basic auth header",
authData.startsWith(BASIC));
String credentials = new
String(decoder.decode(authData.substring(BASIC.length())));
- Assert.assertEquals(expectedCreds, credentials);
+ if (!expectedCreds.equals(credentials)) {
+ response.sendError(401, "Invalid credentials");
+ return;
+ }
}
if (request.getServletPath().equals("/flume-conf.properties")) {
File file = new File("target/test-classes/flume-conf.properties");
diff --git
a/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestSpooldirSource.java
b/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestSpooldirSource.java
index 3801745..96089c9 100644
---
a/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestSpooldirSource.java
+++
b/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestSpooldirSource.java
@@ -41,6 +41,14 @@ import org.junit.Test;
import static org.junit.Assert.*;
+/**
+ * This test creates NUM_SOURCES directories with NUM_FILES_PER_DIRE files in
each
+ * directory. It then starts the agent and waits 10 seconds to check that all
+ * the files have been consumed. Depending on the speed of the system either
+ * the wait interval may need to be increased or the number of files reduced.
+ * This would be better if the test could be signaled when the files have been
+ * processed.
+ */
public class TestSpooldirSource {
private static final Logger LOGGER =
@@ -63,7 +71,7 @@ public class TestSpooldirSource {
assertTrue("Unable to create sink output dir: " + spoolParentDir.getPath(),
spoolParentDir.mkdir());
- final int NUM_SOURCES = 100;
+ final int NUM_SOURCES = 30;
agentProps = new Properties();
List<String> spooldirSrcNames = Lists.newArrayList();