I have a simple Rules data service with a few simple stages it executes. An issue I have found with rules services is that you can easily unit test each individual action you implement, but testing the pipeline as a whole is troublesome.
The reason is that you need to start the data service in order to initialize and start the Rules service and most data services have dependencies on running instances of kafka/mongo.
To try and alleviate this, I have attempted to setup a unit test that configures the service to run with the transient data type and local event type:
System.setProperty("DATA_SERVICE_TYPE", "transient");
System.setProperty("EVENT_SERVICE_TYPE", "local");
I set the above as part of the static @BeforeAll annotated method in my unit test.
Beyond that, the Rules service Constructor accepts a IStreamDataReader actionInputStream. I have set that to use a StreamDataManagerNonPersisted.newBuilder().build(); as a test.
When I run my test, the data service starts without error, but when I attempt to publish StreamData to the “actionInputStream” I cannot seem to get that to work.
I am attempting to publish data to the “actionInputStream” in my unit test as follows:
StreamData data = StreamData.newBuilder()
.withDiscriminator("<my_discriminator>")
.putData(FalconPersistRule.DATA_KEY, <my_dataobject_ref>)
.build();
Flowable.just(data).concatWith(Flowable.fromPublisher(<actionInputStream>.getPublisher(Context.makeSystemContext())));
Seeing that the service starts up without error using the “transient” data type, “local” event type, as well as the “StreamDataManagerNonPersisted actionInputStream” leads me to believe that my issue is with how I am publishing the data in my test. But please let me know if what I am trying to do is even possible.
My main questions:
- Can you configure a Rules data service to run without an external mongo/kafka instance as I have configured?
- How can I publish data to the actionInputStream such that the Rules service will process that data?
- Is there a different way to execute these types of tests that I am missing? (I want to avoid the requirement of running external dependencies. I have already thought about using testcontainers, but that requires docker-in-docker with our CI pipelines, which I also want to avoid.)