DaaSJavaApiCore tests

Some of these tests require the Administrator to do something. This is shown as:

Administrator: <must do this task and here are the detailed commands to be used>

Publisher tests

The below 8 tests are specifically designed to test the Publisher Object in the DaaS Java API code.

Note

These are Unit Tests and, as such, test the integrity of the Java API package in isolation._

1. hasSubscribers_returns_false_if_publisher_has_no_subscribers()

If the list of subscribers in the publisher is empty then return false. (The "subscriber" is the KX Refinery Tickerplant)

Test outcome = False to pass.

2. hasSubscribers_returns_true_if_publisher_has_subscribers()

If the list of subscribers in the publisher is not empty then return true.

Test outcome = True to pass.

3. publish_data_cannot_contain_non_char_arrays()

The publisher can only publish one row at a time, the test contains an array of 2 syms, therefore should fail.

Test outcome = Argument Exception, which results in a pass for the test.

4. publish_data_can_contain_char_arrays()

This test checks that the publisher can publish data containing char arrays (which are the equivalent of Strings in kdb+/q) Test outcome = No Exception, which results in a pass for the test.

5. table_parameter_cannot_be_empty()

The publisher has a table parameter which is the destination of the data, if this is empty ('') the publisher should not work.

Test outcome = Argument Exception, which results in a pass for the test

6. table_parameter_cannot_be_null()

The publisher has a table parameter which is the destination of the data, if this is null the publisher should not work.

Test outcome = Argument Exception, which results in a pass for the test

7. waitForSubscribers_returns_false_if_subscription_added_after_timeout()

The publisher has a wait for subscribers method that has a timeout, this test checks if a subscriber is added after the timeout is invoked.

Test outcome = False is returned as subscriber added after timeout, which results in a pass for the test.

8. waitForSubscribers_returns_true_if_subscription_added_before_timeout()

The publisher has a wait for subscribers method that has a timeout, this test checks if a subscriber is added before the timeout is invoked.

Test outcome = True is returned as subscriber added before timeout, which results in a pass for the test.

Query results tests

The below 6 tests are specifically designed to test the Query Results Object in the DaaS Java API code:

Note

These are Unit Tests and, as such, test the integrity of the Java API package in isolation._

9. cannot_pass_a_null_parameter()

The Query Result object has a flip parameter which is the representation of a table. If this is null the Query Result should not work.

Test outcome = Argument Exception, which results in a pass for the test

10. column_name_ordering_is_preserved()

The Query Result object has column names that are exposed by the flip object. This ordering should be preserved as per the flip object.

Test outcome = True (x3), which results in a pass for the test

11. column_type_ordering_is_preserved()

The Query Result object has column types that are exposed by the flip object, these types (inc ordering) should be preserved as per the flip object.

Test outcome = True (x3), which results in a pass for the test

12. getColumnType_method_works()

The Query Result object has column type method which returns the type of the column in question. This is then checked after exposure from the flip object to make sure they are the same (order is not essential).

Test outcome = True (x3), which results in a pass for the test

13. indexers_work_as_expected()

The Query Result object has Indexers which are methods of pulling out data using arrays to retrieve data in multiple ways (cell/row/etc). This test checks that the values visible dependant on passing (string, int) or (int, int) are as expected.

Test outcome = True (x4), which results in a pass for the test

14. works_with_empty_flip()

This test makes sure that if an empty flip object is returned, the API does not error.

Test Outcome = True (x2) number rows and columns = 0 and no exceptions generated, which results in a pass for the test

Service tests

The below 14 tests are specifically designed to test the Service Object in the DaaSAPICore code:

15. can_run_getTicks_query()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves the q function can be run from the API.

Test Outcome = number of rows greater than 0 and no exceptions are produced, which results in a pass for the test. Assumption is that there are >0 rows in the q Function if the HDB is working properly.

The default values supplied with the package will look for the following data in the HDB:

These may need to be changed depending on the data in the Kx Refinery system being connected to :

"symList" = "AZN.L"
"dataType" = "trade"
"startDate" = Date(1551312000000l)
"endDate" = Date(1551312000000l)
"assetClass" = "equity"

16. cannot_create_service_with_invalid_host()

The Service object has the ability to be instantiated with the details that exist in the app.config. This test is to show that if an invalid host is used, an exception is thrown.

Test Outcome = exception generated, which results in a pass for the test.

17. cannot_execute_query_with_invalid_function()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that if a runQuery is run with a q function that does not exist, an argument exception is being generated.

Test Outcome = exception generated, which results in a pass for the test.

18. cannot_execute_query_with_missing_parameters()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that if a runQuery is run with missing mandatory parameters, an argument exception is being generated.

Test Outcome = exception generated, which results in a pass for the test.

19. cannot_execute_query_with_no_timeout()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that if a runQuery is run with no timeout, an argument exception is being generated.

Test Outcome = exception generated, which results in a pass for the test.

20. cannot_execute_query_with_no_parameters()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that if a runQuery is run with missing mandatory parameters (all in this case), an argument exception is being generated.

Test Outcome = exception generated, which results in a pass for the test.

21. cannot_register_publisher_without_messaging_server()

The Service object has the ability to be instantiated with the details that exist in the app.config. This test is to show if the connection is not established then the Publisher cannot be registered and an invalid operation exception is thrown.

Test Outcome = exception generated, which results in a pass for the test.

22. empty_results_do_not_cause_an_exception()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that if a runQuery is run and the result set is empty then the system will not result in an exception.

Test Outcome = no exception generated, which results in a pass for the test.

The default values supplied with the package will look for the following data in the HDB:

"symList" = "NOTASYMBOL"
"dataType" = "trade"
"startDate" = Date(1551312000000l)
"endDate" = Date(1551312000000l)
"assetClass" = "equity"

23. get_compatible_types_for_eqTrade_table()

The Service object has a getCompatibleTypes method. This is run against a table and a dictionary is generated to show the user what are the available types that can be used on the table.

Test Outcome = returned dictionary, which results in a pass for the test.

24. publish_to_fiTrade_table()

Using the Publisher object and the Service object, the connection is established and a new row is published to the fiTrade table. There is no return on this. The new row can only be checked within the Data Refinery since the Data Refinery does not pass messages back on successful publications.

Test Outcome = no exception generated, which results in a pass for the test.

The default values supplied with the package will publish the following data:

"time" = <now in UTC>
"sym" = "VOD"
"exchTime" = <now in UTC>
"price" = "1000.0"
"volume" = "1"
"conditions" = "U||XLON|U||||POP|SET1|||"
"normalisedCondition" = "AU"
"tickDirection" = "1"
"tradedExchange" = "XLON"
"sequenceNumber" = 1L
"accVol" = 1L
"tickCount" = 1L
"tradeId" = "1822058950427310"

25. streaming_analytics_parameter_order_does_not_matter()

The Service object has a subscribeToStreamingAnalytic method. The test passes a dictionary of arguments to the subscribe method. The outcome is that this dictionary can be in any order internally and the subscribe will work as expected.

Test Outcome = no exception generated and running total of rows returned > 0, which results in a pass for the test.

The default values supplied with the package will require the following data to be ingested real-time into Kx Refinery.

These may need to be changed depending on the data in the Kx Refinery system being connected to :

"symList" = ""_(i.e. any)
"dataType" = "trade"
"assetClass" = "equity"

26. streaming_analytics_unsubscribe_method_works()

The Service object has a unSubscribeToStreamingAnalytic method. The test subscribes to the streaming source, counts the number of rows returned, then unsubscribes and tracks the number of rows returned.

Test Outcome = no exception generated and running total of rows returned = 0 from when the unsubscribe is actioned, which results in a pass for the test.

27. streaming_analytics_works()

The Service object has a subscribeToStreamingAnalytic method. The test starts the subscribe method. The outcome is that the subscribe will work as expected.

Test Outcome = no exception generated and running total of rows returned > 0, which results in a pass for the test.

The default values supplied with the package will require the following data to be ingested real-time into Kx Refinery.

These may need to be changed depending on the data in the Kx Refinery system being connected to :

"symList" = "" (i.e. any)
"dataType" = "trade"
"assetClass" = "equity"

28. check_nanosecond_output()

The Service object has a runQuery method to run basic q functions that are available in the Gateway. This test proves that runQuery can be executed by with Timestamps using nanosecond granularity.

Test Outcome = no exception generated, which results in a pass for the test.
These may need to be changed depending on the data in the Kx Refinery system being connected to :

Timestamp startTime = new Timestamp(1559127620000l);
startTime.setNanos(69053033);
Timestamp endTime = new Timestamp(1559127706000l);
endTime.setNanos(577400010);
"symList" = "VOD.L"
"dataType" = "trade"
"startTime" = startTime
"endTime" = endTime
"startDate" = Date(1559088000000l)
"endDate" = Date(1559088000000l)
"assetClass" = "equity"

29. Failover Test

Note

This is a manual test (there is no code associated for this test)_

Checks the ability to switch from one process ( primary /A-side/Prod) to another ( secondary /B-side/DR/backup) if primary fails:

The following primary processes were shut down:

  • emea_gw_0_a.1
  • emea_qp_0_a.1
  • emea_qr_0_a.1

The getTicks test (test #15) was then re-run and checked to see that it passed.

The Java API Log extract below shows that in Data Refinery the getTicks query was executed on the emea_qr_0_* b*process (the 'b' signifies that the process is running on secondary/B-side/DR/backup)

Note

The actual content is logger specific:_

2018-12-2014:03:26,306 [12] DEBUGDaaSJavaApiCore.Service - Running 'getTicks' query
2018-12-2014:03:26,307 [12] DEBUGDaaSJavaApiCore.Service - Checking that API dictionary on the DeltaApiService has been set. This method will wait up to 00:00:05 for the dictionary to be set.
2018-12-2014:03:26,311 [12] WARN  DeltaApiCore.DeltaApi.Service.DeltaApiService - Strict type checking on api getTicks disabled
2018-12-2014:03:26,325 [12] INFO  DeltaApiCore.QueryRouter.DefaultDeltaQueryRouter - Submitting query with runID 17474285715
2018-12-2014:03:26,326 [12] DEBUGDeltaApiCore.QueryRouter.Connection.Async.DeltaQrConnection - executing as Administrator on emea_qr_0_b:s626207nj2sl02.uswhwk6.savvis.net:24110

Test outcome = failover works, which results in a pass for the test.