Skip to content

Commit

Permalink
fix problem with passing a dir that containts another dir for topolog…
Browse files Browse the repository at this point in the history
…ies (#269)
  • Loading branch information
purbon authored Apr 28, 2021
1 parent ab30d76 commit b2745f8
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private static List<Topology> parseListOfTopologies(
if (isDir) {
Files.list(Paths.get(fileOrDir))
.sorted()
.filter(p -> !Files.isDirectory(p))
.map(path -> parser.deserialise(path.toFile()))
.forEach(subTopology -> topologies.add(subTopology));
} else {
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/com/purbon/kafka/topology/JulieOpsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,32 @@ public void buiderRunTest() throws Exception {
verify(topicManager, times(1)).apply(anyObject(), anyObject());
verify(accessControlManager, times(1)).apply(anyObject(), anyObject());
}

@Test
public void builderRunTestAsFromDirectoryWithSchema() throws Exception {
String fileOrDirPath = TestUtils.getResourceFilename("/dir_with_subdir");

Configuration builderConfig = new Configuration(cliOps, props);

JulieOps builder =
JulieOps.build(
fileOrDirPath,
builderConfig,
topologyAdminClient,
accessControlProvider,
bindingsBuilderProvider);

builder.setTopicManager(topicManager);
builder.setAccessControlManager(accessControlManager);

doNothing().when(topicManager).apply(anyObject(), anyObject());

doNothing().when(accessControlManager).apply(anyObject(), anyObject());

builder.run();
builder.close();

verify(topicManager, times(1)).apply(anyObject(), anyObject());
verify(accessControlManager, times(1)).apply(anyObject(), anyObject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.testcontainers.shaded.com.google.common.eventbus.AllowConcurrentEvents;

@RunWith(MockitoJUnitRunner.class)
public class RBACPRoviderRbacIT extends MDSBaseTest {
Expand Down
55 changes: 55 additions & 0 deletions src/test/resources/dir_with_subdir/descriptor-with-others.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
context: "contextOrg"
source: "source"
foo: "foo"
bar: "bar"
zet: "zet"
projects:
- name: "foo"
zookeepers: []
consumers:
- principal: "User:App0"
- principal: "User:App1"
producers: []
streams:
- principal: "User:App0"
topics:
read:
- "topicA"
- "topicB"
write:
- "topicC"
- "topicD"
connectors:
- principal: "User:Connect1"
topics:
read:
- "topicA"
- "topicB"
- principal: "User:Connect2"
topics:
write:
- "topicC"
- "topicD"
topics:
- name: "foo"
config:
replication.factor: "1"
num.partitions: "1"
- dataType: "avro"
name: "bar"
config:
replication.factor: "1"
num.partitions: "1"
- name: "bar"
zookeepers: []
consumers: []
producers: []
streams: []
connectors: []
topics:
- dataType: "avro"
name: "bar"
config:
replication.factor: "1"
num.partitions: "1"
61 changes: 61 additions & 0 deletions src/test/resources/dir_with_subdir/descriptor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
context: "contextOrg"
source: "source"
projects:
- name: "foo"
zookeepers: []
consumers:
- principal: "User:App0"
- principal: "User:App1"
producers: []
streams:
- principal: "User:App0"
topics:
read:
- "topicA"
- "topicB"
write:
- "topicC"
- "topicD"
connectors:
- principal: "User:Connect1"
topics:
read:
- "topicA"
- "topicB"
- principal: "User:Connect2"
topics:
write:
- "topicC"
- "topicD"
topics:
- name: "foo"
config:
replication.factor: "1"
num.partitions: "1"
- dataType: "avro"
name: "bar"
config:
replication.factor: "1"
num.partitions: "1"
- name: "bar"
zookeepers: []
consumers: []
producers: []
streams: []
connectors: []
topics:
- dataType: "avro"
name: "bar"
config:
replication.factor: "1"
num.partitions: "1"
platform:
schema_registry:
instances:
- principal: "User:SchemaRegistry01"
- principal: "User:SchemaRegistry02"
control_center:
instances:
- principal: "User:ControlCenter"
appId: "controlcenter"
1 change: 1 addition & 0 deletions src/test/resources/dir_with_subdir/schemas/bar-key.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "string"}
1 change: 1 addition & 0 deletions src/test/resources/dir_with_subdir/schemas/bar-value.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "string"}

0 comments on commit b2745f8

Please sign in to comment.