55 */
66package org .elasticsearch .xpack .ml .integration ;
77
8+ import com .carrotsearch .hppc .cursors .ObjectCursor ;
89import org .elasticsearch .Version ;
910import org .elasticsearch .action .DocWriteRequest ;
1011import org .elasticsearch .action .index .IndexRequest ;
4748
4849import java .io .IOException ;
4950import java .io .InputStream ;
51+ import java .util .ArrayList ;
5052import java .util .Arrays ;
5153import java .util .Collections ;
5254import java .util .HashSet ;
5355import java .util .List ;
56+ import java .util .Objects ;
5457import java .util .Set ;
5558import java .util .SortedMap ;
5659import java .util .TreeMap ;
@@ -148,9 +151,13 @@ public void testMigrateConfigs() throws InterruptedException, IOException {
148151 .routingTable (routingTable .build ())
149152 .build ();
150153 when (clusterService .state ()).thenReturn (clusterState );
151-
154+ List < MetaData . Custom > customs = new ArrayList <>();
152155 doAnswer (invocation -> {
153156 ClusterStateUpdateTask listener = (ClusterStateUpdateTask ) invocation .getArguments ()[1 ];
157+ ClusterState result = listener .execute (clusterState );
158+ for (ObjectCursor <MetaData .Custom > value : result .metaData ().customs ().values ()){
159+ customs .add (value .value );
160+ }
154161 listener .clusterStateProcessed ("source" , mock (ClusterState .class ), mock (ClusterState .class ));
155162 return null ;
156163 }).when (clusterService ).submitStateUpdateTask (eq ("remove-migrated-ml-configs" ), any ());
@@ -164,6 +171,9 @@ public void testMigrateConfigs() throws InterruptedException, IOException {
164171 blockingCall (actionListener -> mlConfigMigrator .migrateConfigs (clusterState , actionListener ),
165172 responseHolder , exceptionHolder );
166173
174+ // Verify that we have custom values in the new cluster state and that none of them is null
175+ assertThat (customs .size (), greaterThan (0 ));
176+ assertThat (customs .stream ().anyMatch (Objects ::isNull ), is (false ));
167177 assertNull (exceptionHolder .get ());
168178 assertTrue (responseHolder .get ());
169179 assertSnapshot (mlMetadata .build ());
0 commit comments