3 * Copyright (C) 2009-2017 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.platform.monitoring.cluster;
22 import java.util.Collection;
23 import org.junit.Rule;
24 import org.junit.Test;
25 import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
26 import org.sonar.server.es.EsTester;
27 import org.sonar.server.es.FakeIndexDefinition;
29 import static org.assertj.core.api.Assertions.assertThat;
31 public class SearchNodesInfoLoaderImplTest {
34 public EsTester es = new EsTester(new FakeIndexDefinition());
36 private SearchNodesInfoLoaderImpl underTest = new SearchNodesInfoLoaderImpl(es.client());
39 public void return_info_from_elasticsearch_api() {
40 Collection<NodeInfo> nodes = underTest.load();
42 assertThat(nodes).hasSize(1);
43 NodeInfo node = nodes.iterator().next();
44 assertThat(node.getName()).isNotEmpty();
45 assertThat(node.getSections()).hasSize(1);
46 ProtobufSystemInfo.Section stateSection = node.getSections().get(0);
48 assertThat(stateSection.getAttributesList())
49 .extracting(ProtobufSystemInfo.Attribute::getKey)
51 "Disk Available", "Store Size",
52 "JVM Heap Usage", "JVM Heap Used", "JVM Heap Max", "JVM Non Heap Used",
54 "Field Data Memory", "Field Data Circuit Breaker Limit", "Field Data Circuit Breaker Estimation",
55 "Request Circuit Breaker Limit", "Request Circuit Breaker Estimation",
56 "Query Cache Memory", "Request Cache Memory");