Refresh system index immediately when create/update/delete notification configs
Is your feature request related to a problem?
When create, update and delete notification configs, currently we do not refresh the system index .opensearch-notification-config in this plugin, so the operations cannot be seen immediately util the automatic refresh happens within the index(the default value of refresh_interval is 1s, which means the operations can be seen after 1s at most).
However, we can refresh the index when doing those operations to make the result visible immediately, one benefit is that users may use the notifications API to create/update/delete configs so they need to see the realtime result, another benefit is that in the integration test methods, we do not need to use Thread.sleep() or waitFor to wait some time to get the result after creating/updating/deleting the notification configs.
Too many refresh may cause problems, but in our case, creating/updating/deleting operations don't happen frequently, so it's not a problem that we refresh the system index for every operation.
What solution would you like?
Add refresh=true parameter when calling the index/update/delete API against the system index .opensearch-notification-config.
Here is the index operation code which needs to be changed:
https://github.com/opensearch-project/notifications/blob/0a7a5f99e71248cce9d5c15b0b99f9f270261d21/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/NotificationConfigIndex.kt#L185
, adding .setRefreshPolicy(RefreshPolicy.IMMEDIATE) maybe enough.
After changing this, we'd better modify our unit test to remove refreshAllIndices and Thread.sleep
I'll work on this