Search in sources :

Example 1 with MockConnectMetrics

use of org.apache.kafka.connect.runtime.MockConnectMetrics in project kafka by apache.

the class ErrorReporterTest method setup.

@Before
public void setup() {
    metrics = new MockConnectMetrics();
    errorHandlingMetrics = new ErrorHandlingMetrics(new ConnectorTaskId("connector-", 1), metrics);
}
Also used : ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) MockConnectMetrics(org.apache.kafka.connect.runtime.MockConnectMetrics) Before(org.junit.Before)

Example 2 with MockConnectMetrics

use of org.apache.kafka.connect.runtime.MockConnectMetrics in project kafka by apache.

the class DistributedHerderTest method setUp.

@Before
public void setUp() throws Exception {
    time = new MockTime();
    metrics = new MockConnectMetrics(time);
    worker = PowerMock.createMock(Worker.class);
    EasyMock.expect(worker.isSinkConnector(CONN1)).andStubReturn(Boolean.TRUE);
    AutoCloseable uponShutdown = () -> shutdownCalled.countDown();
    // Default to the old protocol unless specified otherwise
    connectProtocolVersion = CONNECT_PROTOCOL_V0;
    herder = PowerMock.createPartialMock(DistributedHerder.class, new String[] { "connectorTypeForClass", "updateDeletedConnectorStatus", "updateDeletedTaskStatus", "validateConnectorConfig", "buildRestartPlan", "recordRestarting" }, new DistributedConfig(HERDER_CONFIG), worker, WORKER_ID, KAFKA_CLUSTER_ID, statusBackingStore, configBackingStore, member, MEMBER_URL, metrics, time, noneConnectorClientConfigOverridePolicy, new AutoCloseable[] { uponShutdown });
    configUpdateListener = herder.new ConfigUpdateListener();
    rebalanceListener = herder.new RebalanceListener(time);
    plugins = PowerMock.createMock(Plugins.class);
    conn1SinkConfig = new SinkConnectorConfig(plugins, CONN1_CONFIG);
    conn1SinkConfigUpdated = new SinkConnectorConfig(plugins, CONN1_CONFIG_UPDATED);
    EasyMock.expect(herder.connectorTypeForClass(BogusSourceConnector.class.getName())).andReturn(ConnectorType.SOURCE).anyTimes();
    pluginLoader = PowerMock.createMock(PluginClassLoader.class);
    delegatingLoader = PowerMock.createMock(DelegatingClassLoader.class);
    PowerMock.mockStatic(Plugins.class);
    PowerMock.expectPrivate(herder, "updateDeletedConnectorStatus").andVoid().anyTimes();
    PowerMock.expectPrivate(herder, "updateDeletedTaskStatus").andVoid().anyTimes();
}
Also used : MockConnectMetrics(org.apache.kafka.connect.runtime.MockConnectMetrics) DelegatingClassLoader(org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader) SinkConnectorConfig(org.apache.kafka.connect.runtime.SinkConnectorConfig) Worker(org.apache.kafka.connect.runtime.Worker) MockTime(org.apache.kafka.common.utils.MockTime) Plugins(org.apache.kafka.connect.runtime.isolation.Plugins) PluginClassLoader(org.apache.kafka.connect.runtime.isolation.PluginClassLoader) Before(org.junit.Before)

Example 3 with MockConnectMetrics

use of org.apache.kafka.connect.runtime.MockConnectMetrics in project apache-kafka-on-k8s by banzaicloud.

the class DistributedHerderTest method setUp.

@Before
public void setUp() throws Exception {
    time = new MockTime();
    metrics = new MockConnectMetrics(time);
    worker = PowerMock.createMock(Worker.class);
    EasyMock.expect(worker.isSinkConnector(CONN1)).andStubReturn(Boolean.TRUE);
    herder = PowerMock.createPartialMock(DistributedHerder.class, new String[] { "backoff", "connectorTypeForClass", "updateDeletedConnectorStatus" }, new DistributedConfig(HERDER_CONFIG), worker, WORKER_ID, KAFKA_CLUSTER_ID, statusBackingStore, configBackingStore, member, MEMBER_URL, metrics, time);
    configUpdateListener = herder.new ConfigUpdateListener();
    rebalanceListener = herder.new RebalanceListener();
    plugins = PowerMock.createMock(Plugins.class);
    conn1SinkConfig = new SinkConnectorConfig(plugins, CONN1_CONFIG);
    conn1SinkConfigUpdated = new SinkConnectorConfig(plugins, CONN1_CONFIG_UPDATED);
    EasyMock.expect(herder.connectorTypeForClass(BogusSourceConnector.class.getName())).andReturn(ConnectorType.SOURCE).anyTimes();
    pluginLoader = PowerMock.createMock(PluginClassLoader.class);
    delegatingLoader = PowerMock.createMock(DelegatingClassLoader.class);
    PowerMock.mockStatic(Plugins.class);
    PowerMock.expectPrivate(herder, "updateDeletedConnectorStatus").andVoid().anyTimes();
}
Also used : MockConnectMetrics(org.apache.kafka.connect.runtime.MockConnectMetrics) Worker(org.apache.kafka.connect.runtime.Worker) DelegatingClassLoader(org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader) MockTime(org.apache.kafka.common.utils.MockTime) SinkConnectorConfig(org.apache.kafka.connect.runtime.SinkConnectorConfig) Plugins(org.apache.kafka.connect.runtime.isolation.Plugins) PluginClassLoader(org.apache.kafka.connect.runtime.isolation.PluginClassLoader) Before(org.junit.Before)

Aggregations

MockConnectMetrics (org.apache.kafka.connect.runtime.MockConnectMetrics)3 Before (org.junit.Before)3 MockTime (org.apache.kafka.common.utils.MockTime)2 SinkConnectorConfig (org.apache.kafka.connect.runtime.SinkConnectorConfig)2 Worker (org.apache.kafka.connect.runtime.Worker)2 DelegatingClassLoader (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)2 PluginClassLoader (org.apache.kafka.connect.runtime.isolation.PluginClassLoader)2 Plugins (org.apache.kafka.connect.runtime.isolation.Plugins)2 ConnectorTaskId (org.apache.kafka.connect.util.ConnectorTaskId)1