-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HAWKULAR-1153 Initial support enable/disable/update collection interv…
…als (#290) - Add command to handle new cmdgw request/response for updating metric collection intervals - this command will return the server-refresh indicator but will not itself activate the flag - this should be EAP6 compatible - Change start command to perform everything async - add optional delay attribute for deferred re/start - add optional refresh attribute to restart with the latest runtime config - Add ITest to ensure immutable agents block attribute update (standalone and domain) - Update ExportJdrCommand to workaround https://issues.jboss.org/browse/WFLY-8161, which would break any future agent subsystem adds - Fix bug in MonitorService start logic, need to treat RELOAD_REQUIRED and RESTART_REQUIRED like RUNNING in certain conditionals - (from mazz) try a different approach to synchronize starting and stopping
- Loading branch information
1 parent
3af44fa
commit dcc93eb
Showing
26 changed files
with
868 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...ar-wildfly-agent-cmdgw-itest/src/test/java/org/hawkular/agent/ws/test/ImmutableITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.agent.ws.test; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.ExpectedEvent; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.ExpectedEvent.ExpectedMessage; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.PatternMatcher; | ||
import org.hawkular.dmrclient.Address; | ||
import org.hawkular.inventory.api.model.Resource; | ||
import org.hawkular.inventory.paths.CanonicalPath; | ||
import org.jboss.as.controller.client.ModelControllerClient; | ||
import org.jboss.dmr.ModelNode; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import okhttp3.ws.WebSocket; | ||
|
||
/** | ||
* @author <a href="https://github.com/jshaughn">Jay Shaughnessy</a> | ||
*/ | ||
public class ImmutableITest extends AbstractCommandITest { | ||
public static final String GROUP = "ImmutableITest"; | ||
|
||
// because this test will update the agent to be immutable, it must RUN AFTER THE OTHER ITESTS! | ||
@Test(groups = { GROUP }, dependsOnGroups = { | ||
DatasourceCommandITest.GROUP, | ||
ExecuteOperationCommandITest.GROUP, | ||
ExportJdrCommandITest.GROUP, | ||
JdbcDriverCommandITest.GROUP, | ||
StandaloneDeployApplicationITest.GROUP, | ||
StatisticsControlCommandITest.GROUP, | ||
UpdateCollectionIntervalsCommandITest.GROUP | ||
}) | ||
public void testImmutableUpdate() throws Throwable { | ||
waitForAccountsAndInventory(); | ||
|
||
CanonicalPath wfPath = getHawkularWildFlyServerResourcePath(); | ||
|
||
try (ModelControllerClient mcc = newHawkularModelControllerClient()) { | ||
|
||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/metric-set-dmr=WildFly Memory Metrics/metric-dmr=Heap Max") | ||
.getAddressNode(), | ||
"interval", | ||
"1"); | ||
|
||
ModelNode agentAddress = Address.parse("/subsystem=hawkular-wildfly-agent").getAddressNode(); | ||
assertNodeAttributeEquals(mcc, agentAddress, "immutable", "${hawkular.agent.immutable:false}"); | ||
writeNodeAttribute(mcc, agentAddress, "immutable", "true"); | ||
assertNodeAttributeEquals(mcc, agentAddress, "immutable", "true"); | ||
|
||
Assert.assertTrue(waitForAgent(mcc), "Expected agent to be started."); | ||
|
||
Resource agent = getResource( | ||
"/traversal/f;" + hawkularFeedId + "/type=rt;" | ||
+ "id=Hawkular%20WildFly%20Agent/rl;defines/type=r", | ||
(r -> r.getId() != null)); | ||
|
||
String req = "UpdateCollectionIntervalsRequest={\"authentication\":" + authentication + ", " | ||
+ "\"resourcePath\":\"" + agent.getPath().toString() + "\"," | ||
+ "\"metricTypes\":{\"WildFly Memory Metrics~Heap Max\":\"77\"}" | ||
+ "}"; | ||
String response = ".*\"status\":\"ERROR\"" | ||
+ ".*\"message\":\"Could not perform.*Command not allowed because the agent is immutable.*"; | ||
|
||
ExpectedEvent expectedEvent = new ExpectedMessage(new PatternMatcher(response), | ||
CoreMatchers.equalTo(WebSocket.TEXT), TestWebSocketClient.Answer.CLOSE); | ||
|
||
try (TestWebSocketClient testClient = TestWebSocketClient.builder() | ||
.url(baseGwUri + "/ui/ws") | ||
.expectWelcome(req) | ||
.expectGenericSuccess(wfPath.ids().getFeedId()) | ||
.expectMessage(expectedEvent) | ||
.expectClose() | ||
.build()) { | ||
testClient.validate(10000); | ||
} | ||
|
||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/metric-set-dmr=WildFly Memory Metrics/metric-dmr=Heap Max") | ||
.getAddressNode(), | ||
"interval", | ||
"1"); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...itest/src/test/java/org/hawkular/agent/ws/test/UpdateCollectionIntervalsCommandITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.agent.ws.test; | ||
|
||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient; | ||
import org.hawkular.dmrclient.Address; | ||
import org.hawkular.inventory.api.model.Resource; | ||
import org.hawkular.inventory.paths.CanonicalPath; | ||
import org.jboss.as.controller.client.ModelControllerClient; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author <a href="https://github.com/jshaughn">Jay Shaughnessy</a> | ||
*/ | ||
public class UpdateCollectionIntervalsCommandITest extends AbstractCommandITest { | ||
public static final String GROUP = "UpdateCollectionIntervalsCommandITest"; | ||
|
||
@Test(groups = { GROUP }) | ||
public void testUpdateCollectionIntervals() throws Throwable { | ||
waitForAccountsAndInventory(); | ||
|
||
CanonicalPath wfPath = getHawkularWildFlyServerResourcePath(); | ||
|
||
try (ModelControllerClient mcc = newHawkularModelControllerClient()) { | ||
|
||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/avail-set-dmr=Server Availability/avail-dmr=Server Availability") | ||
.getAddressNode(), | ||
"interval", | ||
"30"); | ||
|
||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/metric-set-dmr=WildFly Memory Metrics/metric-dmr=NonHeap Used") | ||
.getAddressNode(), | ||
"interval", | ||
"30"); | ||
|
||
Resource agent = getResource( | ||
"/traversal/f;" + hawkularFeedId + "/type=rt;" | ||
+ "id=Hawkular%20WildFly%20Agent/rl;defines/type=r", | ||
(r -> r.getId() != null)); | ||
|
||
String req = "UpdateCollectionIntervalsRequest={\"authentication\":" + authentication + ", " | ||
+ "\"resourcePath\":\"" + agent.getPath().toString() + "\"," | ||
+ "\"metricTypes\":{\"WildFly Memory Metrics~NonHeap Used\":\"0\",\"Unknown~Metric\":\"666\"}," | ||
+ "\"availTypes\":{\"Server Availability~Server Availability\":\"0\",\"Unknown~Avail\":\"666\"}" | ||
+ "}"; | ||
String response = "UpdateCollectionIntervalsResponse={" | ||
+ "\"resourcePath\":\"" + agent.getPath() + "\"," | ||
+ "\"destinationSessionId\":\"{{sessionId}}\"," | ||
+ "\"status\":\"OK\"," | ||
+ "\"message\":\"Performed [Update Collection Intervals] on a [DMR Nodes] given by Inventory path [" | ||
+ agent.getPath() + "]\"" | ||
+ "}"; | ||
|
||
try (TestWebSocketClient testClient = TestWebSocketClient.builder() | ||
.url(baseGwUri + "/ui/ws") | ||
.expectWelcome(req) | ||
.expectGenericSuccess(wfPath.ids().getFeedId()) | ||
.expectText(response, TestWebSocketClient.Answer.CLOSE) | ||
.expectClose() | ||
.build()) { | ||
testClient.validate(10000); | ||
} | ||
|
||
// Make sure the agent reboots before executing other itests | ||
Assert.assertTrue(waitForAgent(mcc), "Expected agent to be started."); | ||
|
||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/avail-set-dmr=Server Availability/avail-dmr=Server Availability") | ||
.getAddressNode(), | ||
"interval", | ||
"0"); | ||
assertNodeAttributeEquals(mcc, | ||
Address.parse( | ||
"/subsystem=hawkular-wildfly-agent/metric-set-dmr=WildFly Memory Metrics/metric-dmr=NonHeap Used") | ||
.getAddressNode(), | ||
"interval", | ||
"0"); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...domain-itest/src/test/java/org/hawkular/wildfly/agent/installer/DomainImmutableITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.wildfly.agent.installer; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.ExpectedEvent; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.ExpectedEvent.ExpectedMessage; | ||
import org.hawkular.cmdgw.ws.test.TestWebSocketClient.PatternMatcher; | ||
import org.hawkular.dmrclient.Address; | ||
import org.hawkular.inventory.api.model.Resource; | ||
import org.hawkular.inventory.paths.CanonicalPath; | ||
import org.hawkular.wildfly.agent.itest.util.AbstractITest; | ||
import org.hawkular.wildfly.agent.itest.util.WildFlyClientConfig; | ||
import org.jboss.as.controller.client.ModelControllerClient; | ||
import org.jboss.dmr.ModelNode; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import okhttp3.ws.WebSocket; | ||
|
||
/** | ||
* @author <a href="https://github.com/jshaughn">Jay Shaughnessy</a> | ||
*/ | ||
public class DomainImmutableITest extends AbstractITest { | ||
public static final String GROUP = "DomainImmutableITest"; | ||
|
||
// because this test will update the agent to be immutable, it must RUN AFTER THE OTHER ITESTS! | ||
@Test(groups = { GROUP }, dependsOnGroups = { | ||
AgentInstallerDomainITest.GROUP, | ||
ControlDomainServersITest.GROUP, | ||
DomainDeployApplicationITest.GROUP, | ||
}) | ||
public void testImmutableUpdate() throws Throwable { | ||
waitForAccountsAndInventory(); | ||
|
||
WildFlyClientConfig clientConfig = getPlainWildFlyClientConfig(); | ||
CanonicalPath wfPath = getHostController(clientConfig); | ||
|
||
try (ModelControllerClient mcc = newPlainWildFlyModelControllerClient(clientConfig)) { | ||
|
||
final String serverToTest = "server-one"; | ||
final String hostAgent = "/host=master/subsystem=hawkular-wildfly-agent"; | ||
final Address hostAgentAddress = Address.parse(hostAgent); | ||
final ModelNode hostAgentNode = hostAgentAddress.getAddressNode(); | ||
final String hostAttr = hostAgent + "/metric-set-dmr=WildFly Memory Metrics/metric-dmr=Heap Max"; | ||
final Address hostAttrAddress = Address.parse(hostAttr); | ||
final ModelNode hostAttrNode = hostAttrAddress.getAddressNode(); | ||
|
||
assertNodeAttributeEquals(mcc, hostAttrNode, "interval", "1"); | ||
|
||
assertNodeAttributeEquals(mcc, hostAgentNode, "immutable", "${hawkular.agent.immutable:false}"); | ||
writeNodeAttribute(mcc, hostAgentNode, "immutable", "true"); | ||
assertNodeAttributeEquals(mcc, hostAgentNode, "immutable", "true"); | ||
|
||
Assert.assertTrue(waitForAgent(mcc, hostAgentAddress), "Expected host agent to be started."); | ||
|
||
Resource agent = getResource( | ||
"/traversal/f;" + clientConfig.getFeedId() + "/type=rt;" | ||
+ "id=Domain WildFly Server Controller/rl;defines/type=r", | ||
(r -> r.getId().contains(serverToTest))); | ||
|
||
String req = "UpdateCollectionIntervalsRequest={\"authentication\":" + authentication + ", " | ||
+ "\"resourcePath\":\"" + agent.getPath().toString() + "\"," | ||
+ "\"metricTypes\":{\"WildFly Memory Metrics~Heap Max\":\"77\"}" | ||
+ "}"; | ||
String response = ".*\"status\":\"ERROR\"" | ||
+ ".*\"message\":\"Could not perform.*Command not allowed because the agent is immutable.*"; | ||
|
||
ExpectedEvent expectedEvent = new ExpectedMessage(new PatternMatcher(response), | ||
CoreMatchers.equalTo(WebSocket.TEXT), TestWebSocketClient.Answer.CLOSE); | ||
|
||
try (TestWebSocketClient testClient = TestWebSocketClient.builder() | ||
.url(baseGwUri + "/ui/ws") | ||
.expectWelcome(req) | ||
.expectGenericSuccess(wfPath.ids().getFeedId()) | ||
.expectMessage(expectedEvent) | ||
.expectClose() | ||
.build()) { | ||
testClient.validate(10000); | ||
} | ||
|
||
assertNodeAttributeEquals(mcc, hostAttrNode, "interval", "1"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.