-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support Resource Configuration #20
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
303a5e8
partial: initial draft of model with config
jeqo fe376e0
feat: add ask pattern to get config
jeqo b341288
Merge branch 'master' into config
jeqo 10cd046
fix: topic manager spec
jeqo 3ceb213
fix: broker manager spec
jeqo 9b1d6b9
fix: parser spec
jeqo 98e5809
refactor: introduce configdescribed event
jeqo 2898d7b
feat: test config
jeqo 47e87a4
fix: stabilize tests
jeqo 653662c
refactor: comments and tailrec
jeqo 1aadc75
docs: None cases on event handling
jeqo 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
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 |
---|---|---|
|
@@ -4,17 +4,18 @@ import java.time.Duration | |
|
||
import akka.actor.ActorSystem | ||
import akka.stream.ActorMaterializer | ||
import akka.testkit.{ ImplicitSender, TestKit, TestProbe } | ||
import akka.testkit.{ImplicitSender, TestKit, TestProbe} | ||
import net.manub.embeddedkafka.EmbeddedKafkaConfig | ||
import no.sysco.middleware.kafka.event.collector.internal.EventRepository.CollectTopics | ||
import no.sysco.middleware.kafka.event.collector.model.{ TopicDescription, _ } | ||
import no.sysco.middleware.kafka.event.collector.internal.EventRepository.{CollectTopics, DescribeConfig, DescribeTopic, ResourceType} | ||
import no.sysco.middleware.kafka.event.collector.model.{TopicDescription, _} | ||
import no.sysco.middleware.kafka.event.collector.topic.TopicManager.ListTopics | ||
import no.sysco.middleware.kafka.event.proto | ||
import no.sysco.middleware.kafka.event.proto.collector._ | ||
import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } | ||
import no.sysco.middleware.kafka.event.proto.collector.{TopicCreated, TopicDeleted, TopicEvent, TopicUpdated} | ||
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} | ||
|
||
import scala.concurrent.ExecutionContext | ||
import scala.concurrent.duration._ | ||
import scala.language.postfixOps | ||
|
||
class TopicManagerSpec | ||
extends TestKit(ActorSystem("test-topic-manager")) | ||
|
@@ -69,12 +70,16 @@ class TopicManagerSpec | |
manager ! TopicEvent("topic-2", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-3", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
|
||
// then, current state should have 3 topics | ||
// then, 3 topics should be ask to be described | ||
eventRepository.expectMsg(DescribeTopic("topic-1")) | ||
eventRepository.expectMsg(DescribeTopic("topic-2")) | ||
eventRepository.expectMsg(DescribeTopic("topic-3")) | ||
|
||
// and, current state should not have 3 topics, as empty topics are not returned | ||
manager ! ListTopics() | ||
|
||
val topicsV0 = expectMsgType[Topics] | ||
assert(topicsV0.topics.size == 3) | ||
//FIXME assert(topicsV0.topicsAndDescription.count(_._2.isEmpty) == 3) | ||
assert(topicsV0.topics.isEmpty) | ||
|
||
// if a topic is updated | ||
manager ! | ||
|
@@ -87,21 +92,31 @@ class TopicManagerSpec | |
internal = false, | ||
List(proto.collector.TopicDescription.TopicPartitionInfo(0, Some(proto.collector.Node(0, "localhost", 9092, "1"))))))))) | ||
|
||
manager ! | ||
TopicEvent( | ||
"topic-2", | ||
TopicEvent.Event.TopicUpdated( | ||
TopicUpdated( | ||
Some( | ||
proto.collector.TopicDescription( | ||
internal = false, | ||
List(proto.collector.TopicDescription.TopicPartitionInfo(0, Some(proto.collector.Node(0, "localhost", 9092, "1"))))))))) | ||
|
||
|
||
// then, current state should reflect topic updated | ||
manager ! ListTopics() | ||
val topicsV1 = expectMsgType[Topics] | ||
//FIXME assert(topicsV1.topicsAndDescription.count(_._2.isEmpty) == 2) | ||
//FIXME assert(!topicsV1.topicsAndDescription("topic-1").get.internal) | ||
//FIXME assert(topicsV1.topicsAndDescription("topic-1").get.partitions.size == 1) | ||
assert(topicsV1.topics.size == 2) | ||
assert(!topicsV1.topics.find(s => s.name.equals("topic-1")).get.description.internal) | ||
assert(topicsV1.topics.find(s => s.name.equals("topic-1")).get.description.partitions.size == 1) | ||
|
||
// finally, if topic is deleted | ||
manager ! TopicEvent("topic-2", TopicEvent.Event.TopicDeleted(TopicDeleted())) | ||
|
||
// then, current state should have just 2 topics. | ||
manager ! ListTopics() | ||
val topicsV2 = expectMsgType[Topics] | ||
//FIXME assert(topicsV2.topicsAndDescription.count(_._2.isEmpty) == 1) | ||
//FIXME assert(topicsV2.topicsAndDescription.get("topic-2").isEmpty) | ||
assert(topicsV2.topics.size == 1) | ||
} | ||
} | ||
|
||
|
@@ -117,18 +132,19 @@ class TopicManagerSpec | |
eventRepository = eventRepositoryProbe.ref, | ||
eventProducer = eventProducerProbe.ref)) | ||
|
||
// collect 3 topics | ||
manager ! TopicEvent("topic-1", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-2", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-3", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
|
||
// describe 2 internal | ||
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. Dont forget also comments :) As I see now, U describe 2 NON-internal topic |
||
manager ! TopicDescribed(("topic-1", TopicDescription(internal = true, List.empty))) | ||
manager ! TopicDescribed(("topic-1", TopicDescription(internal = false, List.empty))) | ||
eventRepositoryProbe.expectMsg(DescribeConfig(ResourceType.Topic, "topic-1")) | ||
eventRepositoryProbe.reply(Config()) | ||
eventProducerProbe.expectMsgType[TopicEvent] | ||
manager ! TopicDescribed(("topic-2", TopicDescription(internal = true, List.empty))) | ||
manager ! TopicDescribed(("topic-2", TopicDescription(internal = false, List.empty))) | ||
eventRepositoryProbe.expectMsg(DescribeConfig(ResourceType.Topic, "topic-2")) | ||
eventRepositoryProbe.reply(Config()) | ||
eventProducerProbe.expectMsgType[TopicEvent] | ||
// describe 1 NOT internal | ||
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. And opposite here U describe 1 INTERNAL topic |
||
manager ! TopicDescribed(("topic-3", TopicDescription(internal = false, List.empty))) | ||
manager ! TopicDescribed(("topic-3", TopicDescription(internal = true, List.empty))) | ||
eventRepositoryProbe.expectMsg(DescribeConfig(ResourceType.Topic, "topic-3")) | ||
eventRepositoryProbe.reply(Config()) | ||
eventProducerProbe.expectMsgType[TopicEvent] | ||
} | ||
} | ||
|
@@ -142,24 +158,23 @@ class TopicManagerSpec | |
system.actorOf( | ||
TopicManager.props( | ||
pollInterval = Duration.ofSeconds(100), | ||
includeInternalTopics = false, | ||
eventRepository = eventRepositoryProbe.ref, | ||
eventProducer = eventProducerProbe.ref)) | ||
|
||
// collect 3 topics | ||
manager ! TopicEvent("topic-1", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-2", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-3", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
eventProducer = eventProducerProbe.ref, | ||
includeInternalTopics = false)) | ||
|
||
// describe 2 internal | ||
manager ! TopicDescribed(("topic-1", TopicDescription(internal = true, List.empty))) | ||
manager ! TopicDescribed(("topic-2", TopicDescription(internal = true, List.empty))) | ||
|
||
eventProducerProbe.expectNoMessage(500 millis) | ||
|
||
// describe 1 NOT internal | ||
manager ! TopicDescribed(("topic-3", TopicDescription(internal = false, List.empty))) | ||
manager ! TopicDescribed(("topic-1", TopicDescription(internal = false, List.empty))) | ||
eventRepositoryProbe.expectMsg(DescribeConfig(ResourceType.Topic, "topic-1")) | ||
eventRepositoryProbe.reply(Config()) | ||
eventProducerProbe.expectMsgType[TopicEvent] | ||
manager ! TopicDescribed(("topic-2", TopicDescription(internal = false, List.empty))) | ||
eventRepositoryProbe.expectMsg(DescribeConfig(ResourceType.Topic, "topic-2")) | ||
eventRepositoryProbe.reply(Config()) | ||
eventProducerProbe.expectMsgType[TopicEvent] | ||
// describe 1 NOT internal | ||
manager ! TopicDescribed(("topic-3", TopicDescription(internal = true, List.empty))) | ||
eventRepositoryProbe.expectNoMessage() | ||
eventProducerProbe.expectNoMessage() | ||
} | ||
} | ||
|
||
|
@@ -253,9 +268,33 @@ class TopicManagerSpec | |
eventProducer = eventProducerProbe.ref)) | ||
|
||
// collect 3 topics | ||
manager ! TopicEvent("topic-1", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-2", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! TopicEvent("topic-3", TopicEvent.Event.TopicCreated(TopicCreated())) | ||
manager ! | ||
TopicEvent( | ||
"topic-1", | ||
TopicEvent.Event.TopicUpdated( | ||
TopicUpdated( | ||
Some( | ||
proto.collector.TopicDescription( | ||
internal = false, | ||
List(proto.collector.TopicDescription.TopicPartitionInfo(0, Some(proto.collector.Node(0, "localhost", 9092, "1"))))))))) | ||
manager ! | ||
TopicEvent( | ||
"topic-2", | ||
TopicEvent.Event.TopicUpdated( | ||
TopicUpdated( | ||
Some( | ||
proto.collector.TopicDescription( | ||
internal = false, | ||
List(proto.collector.TopicDescription.TopicPartitionInfo(0, Some(proto.collector.Node(0, "localhost", 9092, "1"))))))))) | ||
manager ! | ||
TopicEvent( | ||
"topic-3", | ||
TopicEvent.Event.TopicUpdated( | ||
TopicUpdated( | ||
Some( | ||
proto.collector.TopicDescription( | ||
internal = false, | ||
List(proto.collector.TopicDescription.TopicPartitionInfo(0, Some(proto.collector.Node(0, "localhost", 9092, "1"))))))))) | ||
|
||
// if topic-3 is not collected | ||
manager ! TopicsCollected(List("topic-1", "topic-2")) | ||
|
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 u add to javadoc info about timeout and why 5 secs? It is implicit value, so it used somewhere here in class (I guess its time out for
Future
completion).