Skip to content
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

[Draft] upgrade versions #421

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ lazy val `csw-params` = crossProject(JSPlatform, JVMPlatform)
fork := false
)
.jsSettings(
libraryDependencies += Libs.`scala-java-time`.value
libraryDependencies += Libs.`scala-java-time`.value,
libraryDependencies += Libs.`scalajs-java-securerandom`.value
)
.jvmSettings(
libraryDependencies ++= Dependencies.ParamsJvm.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ case class DemandMatcher(demand: DemandState, withUnits: Boolean = false, timeou
def check(current: CurrentState): Boolean = {
demand.paramSet.forall { di =>
val foundItem: Option[Parameter[_]] = current.find(di)
foundItem.fold(false)(if (withUnits) _ == di else _.values.sameElements(di.values))
foundItem.fold(false)(if (withUnits) _ == di else _.values.sameElements[Any](di.values))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import csw.params.events.Event;
import csw.params.events.Event$;
import csw.params.events.EventKey;
import csw.prefix.models.Prefix;
import csw.prefix.javadsl.JSubsystem;
import csw.prefix.models.Prefix;
import csw.time.core.models.UTCTime;
import org.scalatestplus.testng.TestNGSuite;
import org.testng.Assert;
Expand All @@ -37,8 +37,6 @@
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import csw.event.client.internal.kafka.KafkaTestProps;

//DEOPSCSW-331: Event Service Accessible to all CSW component builders
//DEOPSCSW-334: Publish an event
//DEOPSCSW-335: Model for EventName that encapsulates the topic(or channel ) name
Expand All @@ -50,28 +48,28 @@
public class JEventPublisherTest extends TestNGSuite {

private RedisTestProps redisTestProps;
private KafkaTestProps kafkaTestProps;
// private KafkaTestProps kafkaTestProps;

private int counter = -1;
private Cancellable cancellable;

@BeforeSuite
public void beforeAll() {
redisTestProps = RedisTestProps.jCreateRedisProperties();
kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
// kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
redisTestProps.start();
kafkaTestProps.start();
// kafkaTestProps.start();
}

@AfterSuite
public void afterAll() {
redisTestProps.shutdown();
kafkaTestProps.shutdown();
// kafkaTestProps.shutdown();
}

@DataProvider(name = "event-service-provider")
public Object[][] pubsubProvider() {
return new Object[][]{{redisTestProps}, {kafkaTestProps}};
return new Object[][]{{redisTestProps}, /*{kafkaTestProps}*/};
}

//DEOPSCSW-345: Publish events irrespective of subscriber existence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import csw.event.api.javadsl.IEventSubscription;
import csw.event.api.scaladsl.SubscriptionModes;
import csw.event.client.helpers.Utils;
import csw.event.client.internal.kafka.KafkaTestProps;
import csw.event.client.internal.redis.RedisTestProps;
import csw.event.client.internal.wiring.BaseProperties;
import csw.logging.client.utils.Eventually;
Expand Down Expand Up @@ -46,14 +45,14 @@
public class JEventSubscriberTest extends TestNGSuite {

private RedisTestProps redisTestProps;
private KafkaTestProps kafkaTestProps;
// private KafkaTestProps kafkaTestProps;

@BeforeSuite
public void beforeAll() {
redisTestProps = RedisTestProps.jCreateRedisProperties();
kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
// kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
redisTestProps.start();
kafkaTestProps.start();
// kafkaTestProps.start();
}

public List<Event> getEvents() {
Expand All @@ -74,12 +73,12 @@ private Supplier<Optional<Event>> eventGenerator() {
@AfterSuite
public void afterAll() {
redisTestProps.shutdown();
kafkaTestProps.shutdown();
// kafkaTestProps.shutdown();
}

@DataProvider(name = "event-service-provider")
public Object[][] pubsubProvider() {
return new Object[][]{{redisTestProps}, {kafkaTestProps}};
return new Object[][]{{redisTestProps}, /*{kafkaTestProps}*/};
}

@DataProvider(name = "redis-provider")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import csw.event.api.javadsl.IEventSubscription;
import csw.event.api.scaladsl.SubscriptionModes;
import csw.event.client.helpers.Utils;
import csw.event.client.internal.kafka.KafkaTestProps;
import csw.event.client.internal.redis.RedisTestProps;
import csw.event.client.internal.wiring.BaseProperties;
import csw.params.events.Event;
Expand Down Expand Up @@ -40,14 +39,14 @@
public class JEventSubscriptionFrequencyTest extends TestNGSuite {

private RedisTestProps redisTestProps;
private KafkaTestProps kafkaTestProps;
// private KafkaTestProps kafkaTestProps;

@BeforeSuite
public void beforeAll() {
redisTestProps = RedisTestProps.jCreateRedisProperties();
kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
// kafkaTestProps = KafkaTestProps.jCreateKafkaProperties();
redisTestProps.start();
kafkaTestProps.start();
// kafkaTestProps.start();
}

private List<Event> getEventsWithName(EventName eventName) {
Expand Down Expand Up @@ -84,12 +83,12 @@ Supplier<Optional<Event>> generator() {
@AfterSuite
public void afterAll() {
redisTestProps.shutdown();
kafkaTestProps.shutdown();
// kafkaTestProps.shutdown();
}

@DataProvider(name = "event-service-provider")
public Object[][] pubsubProvider() {
return new Object[][]{{redisTestProps}, {kafkaTestProps}};
return new Object[][]{{redisTestProps}, /*{kafkaTestProps}*/};
}

@DataProvider(name = "redis-provider")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ import akka.actor.testkit.typed.scaladsl.TestProbe
import akka.stream.scaladsl.{Keep, Sink, Source}
import csw.event.client.helpers.TestFutureExt.RichFuture
import csw.event.client.helpers.Utils.{makeDistinctEvent, makeEvent, makeEventWithPrefix}
import csw.params.core.generics.{Key, Parameter}
import csw.event.client.internal.redis.{InitializationEvent, RedisTestProps}
import csw.event.client.internal.wiring.*
import csw.params.core.generics.KeyType.ByteKey
import csw.params.events.{EventName, SystemEvent}
import csw.params.core.generics.{Key, Parameter}
import csw.params.events.{Event, EventKey, EventName, SystemEvent}
import csw.prefix.models.{Prefix, Subsystem}
import csw.event.client.internal.kafka.KafkaTestProps
import csw.event.client.internal.redis.{InitializationEvent, RedisTestProps}
import csw.event.client.internal.wiring._
import csw.params.events.{Event, EventKey}
import csw.time.core.models.UTCTime
import io.github.embeddedkafka.EmbeddedKafka
import org.scalatest.concurrent.Eventually
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.testng.TestNGSuite
import org.testng.annotations._
import org.testng.annotations.*

import scala.collection.{immutable, mutable}
import scala.concurrent.Future
import scala.concurrent.duration.DurationLong
import scala.util.Random
import org.scalatest.matchers.should.Matchers

//DEOPSCSW-331: Event Service Accessible to all CSW component builders
//DEOPSCSW-334: Publish an event
Expand All @@ -43,27 +41,27 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
implicit val patience: PatienceConfig = PatienceConfig(5.seconds, 10.millis)

var redisTestProps: RedisTestProps = _
var kafkaTestProps: KafkaTestProps = _
// var kafkaTestProps: KafkaTestProps = _

@BeforeSuite
def beforeAll(): Unit = {
redisTestProps = RedisTestProps.createRedisProperties()
kafkaTestProps = KafkaTestProps.createKafkaProperties()
// kafkaTestProps = KafkaTestProps.createKafkaProperties()
redisTestProps.start()
kafkaTestProps.start()
// kafkaTestProps.start()
}

@AfterSuite
def afterAll(): Unit = {
redisTestProps.shutdown()
kafkaTestProps.shutdown()
// kafkaTestProps.shutdown()
}

@DataProvider(name = "event-service-provider")
def pubSubProvider: Array[Array[_ <: BaseProperties]] =
Array(
Array(redisTestProps),
Array(kafkaTestProps)
Array(redisTestProps)
// Array(kafkaTestProps)
)

// DEOPSCSW-659: Investigate initial latency in event service pub sub API for single publish
Expand All @@ -81,7 +79,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_and_subscribe_an_event__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516_DEOPSCSW_345(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

val event1 = makeDistinctEvent(Random.nextInt())
val eventKey: EventKey = event1.eventKey
Expand All @@ -108,7 +106,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_an_event_with_duration__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516_DEOPSCSW_345(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

var counter = -1
val events: immutable.Seq[Event] = for (i <- 1 to 10) yield makeEvent(i)
Expand Down Expand Up @@ -140,7 +138,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_concurrently_to_the_different_channel__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516_DEOPSCSW_341(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

val queue: mutable.Queue[Event] = new mutable.Queue[Event]()
val events: immutable.Seq[Event] = for (i <- 101 to 110) yield makeDistinctEvent(i)
Expand All @@ -163,7 +161,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_an_event_with_block_generating_future_of_event__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

var counter = -1
val events: immutable.Seq[Event] = for (i <- 31 to 41) yield makeEventWithPrefix(i, Prefix("csw.move"))
Expand Down Expand Up @@ -196,7 +194,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_maintain_ordering_while_publish__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516_DEOPSCSW_595(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

val prefix = Prefix("csw.ordering.prefix")
val event1 = makeEventWithPrefix(1, prefix)
Expand Down Expand Up @@ -235,7 +233,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_event_via_event_generator_with_start_time__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

val eventKey: EventKey = EventKey("csw.publish.system")
var counter = 0
Expand Down Expand Up @@ -287,7 +285,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def should_be_able_to_publish_event_via_asynchronous_event_generator_with_start_time__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

var counter = -1
val events: immutable.Seq[Event] = for (i <- 31 to 41) yield makeEventWithPrefix(i, Prefix("csw.publishAsync"))
Expand Down Expand Up @@ -323,7 +321,7 @@ class EventPublisherTest extends TestNGSuite with Matchers with Eventually with
def large_event_test__DEOPSCSW_331_DEOPSCSW_334_DEOPSCSW_335_DEOPSCSW_337_DEOPSCSW_349_DEOPSCSW_395_DEOPSCSW_515_DEOPSCSW_516(
baseProperties: BaseProperties
): Unit = {
import baseProperties._
import baseProperties.*

val payloadKey: Key[Byte] = ByteKey.make("payloadKey")
val payload: Array[Byte] = ("0" * 1024 * 2).getBytes("utf-8")
Expand Down
Loading