Search in sources :

Example 11 with ApiEvent

use of com.cloudera.api.swagger.model.ApiEvent in project knox by apache.

the class PollingConfigurationAnalyzerTest method testExistingServiceStartWithConfigChange.

/**
 * Test the start of an existing service when relevant configuration has changed.
 */
@Test
public void testExistingServiceStartWithConfigChange() {
    final String clusterName = "Cluster E";
    // Simulate a service Start event
    ApiEvent startEvent = createApiEvent(clusterName, NameNodeServiceModelGenerator.SERVICE_TYPE, NameNodeServiceModelGenerator.SERVICE, PollingConfigurationAnalyzer.START_COMMAND, PollingConfigurationAnalyzer.SUCCEEDED_STATUS);
    doTestEventWithConfigChange(startEvent, clusterName);
}
Also used : ApiEvent(com.cloudera.api.swagger.model.ApiEvent) Test(org.junit.Test)

Example 12 with ApiEvent

use of com.cloudera.api.swagger.model.ApiEvent in project knox by apache.

the class PollingConfigurationAnalyzerTest method testRestartWaitingForStalenessSuccessEvent.

/**
 * Test the restart waiting for staleness, for which it should be assumed that configuration has changed.
 */
@Test
public void testRestartWaitingForStalenessSuccessEvent() {
    final String address = "http://host1:1234";
    final String clusterName = "Cluster 8";
    // Simulate a successful restart waiting for staleness event
    final ApiEvent rollingRestartEvent = createApiEvent(clusterName, PollingConfigurationAnalyzer.CM_SERVICE_TYPE, PollingConfigurationAnalyzer.CM_SERVICE, PollingConfigurationAnalyzer.RESTART_WAITING_FOR_STALENESS_SUCCESS_COMMAND, PollingConfigurationAnalyzer.SUCCEEDED_STATUS, "EV_CLUSTER_RESTARTED");
    final ChangeListener listener = doTestEvent(rollingRestartEvent, address, clusterName, Collections.emptyMap(), Collections.emptyMap());
    assertTrue("Expected a change notification", listener.wasNotified(address, clusterName));
}
Also used : ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ConfigurationChangeListener(org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor.ConfigurationChangeListener) Test(org.junit.Test)

Example 13 with ApiEvent

use of com.cloudera.api.swagger.model.ApiEvent in project knox by apache.

the class PollingConfigurationAnalyzerTest method testExistingServiceStartWithoutConfigChange.

/**
 * Test the start of an existing service when no relevant configuration has changed.
 */
@Test
public void testExistingServiceStartWithoutConfigChange() {
    final String clusterName = "Cluster E";
    // Simulate a service Start event
    ApiEvent startEvent = createApiEvent(clusterName, NameNodeServiceModelGenerator.SERVICE_TYPE, NameNodeServiceModelGenerator.SERVICE, PollingConfigurationAnalyzer.START_COMMAND, PollingConfigurationAnalyzer.SUCCEEDED_STATUS);
    doTestEventWithoutConfigChange(startEvent, clusterName);
}
Also used : ApiEvent(com.cloudera.api.swagger.model.ApiEvent) Test(org.junit.Test)

Example 14 with ApiEvent

use of com.cloudera.api.swagger.model.ApiEvent in project knox by apache.

the class PollingConfigurationAnalyzerTest method testNewServiceStartEvent.

/**
 * Test the start of a new service.
 */
@Test
public void testNewServiceStartEvent() {
    final String address = "http://host1:1234";
    final String clusterName = "Cluster N";
    // Simulate a service Start event
    ApiEvent startEvent = createApiEvent(clusterName, NameNodeServiceModelGenerator.SERVICE_TYPE, NameNodeServiceModelGenerator.SERVICE, PollingConfigurationAnalyzer.START_COMMAND, PollingConfigurationAnalyzer.SUCCEEDED_STATUS);
    ChangeListener listener = doTestEvent(startEvent, address, clusterName, Collections.emptyMap(), Collections.emptyMap());
    assertTrue("Expected a change notification", listener.wasNotified(address, clusterName));
}
Also used : ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ConfigurationChangeListener(org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor.ConfigurationChangeListener) Test(org.junit.Test)

Example 15 with ApiEvent

use of com.cloudera.api.swagger.model.ApiEvent in project knox by apache.

the class PollingConfigurationAnalyzerTest method testEventWithoutCommandOrCommandStatus.

/**
 * KNOX-2350
 */
@Test
public void testEventWithoutCommandOrCommandStatus() {
    final String clusterName = "Cluster T";
    // Simulate an event w/o COMMAND and/or COMMAND_STATUS attributes
    final List<ApiEventAttribute> revisionEventAttrs = new ArrayList<>();
    revisionEventAttrs.add(createEventAttribute("CLUSTER", clusterName));
    revisionEventAttrs.add(createEventAttribute("SERVICE_TYPE", HiveOnTezServiceModelGenerator.SERVICE_TYPE));
    revisionEventAttrs.add(createEventAttribute("SERVICE", HiveOnTezServiceModelGenerator.SERVICE));
    revisionEventAttrs.add(createEventAttribute("REVISION", "215"));
    revisionEventAttrs.add(createEventAttribute("EVENTCODE", "EV_REVISION_CREATED"));
    final ApiEvent revisionEvent = createApiEvent(ApiEventCategory.AUDIT_EVENT, revisionEventAttrs, null);
    doTestEventWithoutConfigChange(revisionEvent, clusterName);
}
Also used : ApiEventAttribute(com.cloudera.api.swagger.model.ApiEventAttribute) ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ApiEvent (com.cloudera.api.swagger.model.ApiEvent)15 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)4 ConfigurationChangeListener (org.apache.knox.gateway.topology.discovery.ClusterConfigurationMonitor.ConfigurationChangeListener)4 ApiEventAttribute (com.cloudera.api.swagger.model.ApiEventAttribute)2 EventsResourceApi (com.cloudera.api.swagger.EventsResourceApi)1 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiEventQueryResult (com.cloudera.api.swagger.model.ApiEventQueryResult)1 Instant (java.time.Instant)1