@@ -659,24 +659,32 @@ class RollupActionIT : IndexStateManagementRestTestCase() {
659659 )
660660
661661 createPolicy(tier1Policy, tier1PolicyID)
662- createIndex(tier1IndexName, tier1PolicyID, mapping = sourceIndexMappingString)
662+ // Create index WITHOUT policy first to avoid race condition where ISM starts
663+ // rollup before data is indexed
664+ createIndex(tier1IndexName, policyID = null , mapping = sourceIndexMappingString)
663665
664666 // Insert test data with varying timestamps and categories
665667 val bulkRequest = StringBuilder ()
666668 for (i in 1 .. 100 ) {
667- val timestamp = " 2024-01-01T${String .format(" %02d" , i % 24 )} :00:00Z"
669+ // Use Locale.ROOT to ensure ASCII digits regardless of test locale
670+ val timestamp = " 2024-01-01T${String .format(Locale .ROOT , " %02d" , i % 24 )} :00:00Z"
668671 val category = if (i % 2 == 0 ) " electronics" else " books"
669672 val userId = " user_${(i - 1 ) / 10 + 1 } " // Creates user_1 to user_10
670673 val value = i * 10.0
671674 bulkRequest.append(""" {"index":{"_index":"$tier1IndexName "}}""" ).append(" \n " )
672675 bulkRequest.append(""" {"timestamp":"$timestamp ","category":"$category ","user_id":"$userId ","value":$value }""" ).append(" \n " )
673676 }
674- client().makeRequest(
677+ val bulkResponse = client().makeRequest(
675678 " POST" ,
676679 " /_bulk?refresh=true" ,
677680 emptyMap(),
678681 StringEntity (bulkRequest.toString(), ContentType .APPLICATION_JSON ),
679682 )
683+ val bulkResponseMap = bulkResponse.asMap()
684+ assertFalse(" Bulk request should not have errors: $bulkResponseMap " , bulkResponseMap[" errors" ] as Boolean )
685+
686+ // Now add policy after data is indexed to ensure rollup sees all data
687+ addPolicyToIndex(tier1IndexName, tier1PolicyID)
680688
681689 // Execute Tier-1 rollup
682690 assertIndexRolledUp(tier1IndexName, tier1PolicyID, tier1Rollup)
0 commit comments