Skip to content

Commit c6bd53f

Browse files
authored
Fix FileSettingsRoleMappingUpgradeIT assertions (#115422)
Fixes some faulty assertions in an upgrade test. Test failures only manifest on the 8.16 branch since 9.x does not qualify for these upgrade tests, and the change is not backported to 8.17 yet (unrelated CI failures). I validated this works by running it locally from the 8.16 branch. Resolves: #115410 Resolves: #115411
1 parent 1ca3978 commit c6bd53f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsRoleMappingUpgradeIT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525

2626
import java.io.IOException;
2727
import java.util.List;
28-
import java.util.Map;
2928
import java.util.function.Supplier;
3029

31-
import static org.hamcrest.Matchers.contains;
3230
import static org.hamcrest.Matchers.equalTo;
33-
import static org.hamcrest.Matchers.instanceOf;
31+
import static org.hamcrest.Matchers.hasItem;
3432
import static org.hamcrest.Matchers.is;
3533
import static org.hamcrest.Matchers.not;
3634
import static org.hamcrest.Matchers.nullValue;
@@ -104,15 +102,17 @@ public void testRoleMappingsAppliedOnUpgrade() throws IOException {
104102
// the nodes have all been upgraded. Check they re-processed the role mappings in the settings file on
105103
// upgrade
106104
Request clusterStateRequest = new Request("GET", "/_cluster/state/metadata");
107-
List<Object> roleMappings = new XContentTestUtils.JsonMapView(entityAsMap(client().performRequest(clusterStateRequest))).get(
108-
"metadata.role_mappings.role_mappings"
105+
List<Object> clusterStateRoleMappings = new XContentTestUtils.JsonMapView(
106+
entityAsMap(client().performRequest(clusterStateRequest))
107+
).get("metadata.role_mappings.role_mappings");
108+
assertThat(clusterStateRoleMappings, is(not(nullValue())));
109+
assertThat(clusterStateRoleMappings.size(), equalTo(1));
110+
111+
assertThat(
112+
entityAsMap(client().performRequest(new Request("GET", "/_security/role_mapping"))).keySet(),
113+
// TODO change this to `contains` once the clean-up migration work is merged
114+
hasItem("everyone_kibana-read-only-operator-mapping")
109115
);
110-
assertThat(roleMappings, is(not(nullValue())));
111-
assertThat(roleMappings.size(), equalTo(1));
112-
assertThat(roleMappings, is(instanceOf(Map.class)));
113-
@SuppressWarnings("unchecked")
114-
Map<String, Object> roleMapping = (Map<String, Object>) roleMappings;
115-
assertThat(roleMapping.keySet(), contains("everyone_kibana-read-only-operator-mapping"));
116116
}
117117
}
118118
}

0 commit comments

Comments
 (0)