Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1690#discussion_r113187070
  
    --- Diff: 
nifi-nar-bundles/nifi-cdc/nifi-cdc-mysql-bundle/nifi-cdc-mysql-processors/src/test/groovy/org/apache/nifi/cdc/mysql/processors/CaptureChangeMySQLTest.groovy
 ---
    @@ -362,6 +363,79 @@ class CaptureChangeMySQLTest {
             testRunner.provenanceEvents.each { 
assertEquals(ProvenanceEventType.RECEIVE, it.eventType)}
         }
     
    +    @Test
    +    void testExcludeSchemaChanges() throws Exception {
    +        testRunner.setProperty(CaptureChangeMySQL.DRIVER_LOCATION, 
'file:///path/to/mysql-connector-java-5.1.38-bin.jar')
    +        testRunner.setProperty(CaptureChangeMySQL.HOSTS, 'localhost:3306')
    +        testRunner.setProperty(CaptureChangeMySQL.USERNAME, 'root')
    +        testRunner.setProperty(CaptureChangeMySQL.PASSWORD, 'password')
    +        testRunner.setProperty(CaptureChangeMySQL.SERVER_ID, '1')
    +        testRunner.setProperty(CaptureChangeMySQL.CONNECT_TIMEOUT, '2 
seconds')
    +        testRunner.setProperty(CaptureChangeMySQL.INIT_BINLOG_FILENAME, 
'master.000001')
    +        testRunner.setProperty(CaptureChangeMySQL.INIT_BINLOG_POSITION, 
'4')
    +        testRunner.setProperty(CaptureChangeMySQL.INCLUDE_SCHEMA_CHANGES, 
'false')
    +        final DistributedMapCacheClientImpl cacheClient = 
createCacheClient()
    +        def clientProperties = [:]
    +        
clientProperties.put(DistributedMapCacheClientService.HOSTNAME.getName(), 
'localhost')
    +        testRunner.addControllerService('client', cacheClient, 
clientProperties)
    +        testRunner.setProperty(CaptureChangeMySQL.DIST_CACHE_CLIENT, 
'client')
    +        testRunner.enableControllerService(cacheClient)
    +
    +
    +        testRunner.run(1, false, true)
    +
    +        // ROTATE scenario
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: EventType.ROTATE, 
nextPosition: 2] as EventHeaderV4,
    +                [binlogFilename: 'master.000001', binlogPosition: 4L] as 
RotateEventData
    +        ))
    +
    +        // INSERT scenario
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: EventType.QUERY, 
nextPosition: 4] as EventHeaderV4,
    +                [database: 'myDB', sql: 'BEGIN'] as QueryEventData
    +        ))
    +
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: 
EventType.TABLE_MAP, nextPosition: 6] as EventHeaderV4,
    +                [tableId: 1, database: 'myDB', table: 'myTable', 
columnTypes: [4, -4] as byte[]] as TableMapEventData
    +        ))
    +
    +        def cols = new BitSet()
    +        cols.set(1)
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: 
EventType.EXT_WRITE_ROWS, nextPosition: 8] as EventHeaderV4,
    +                [tableId: 1, includedColumns: cols,
    +                 rows   : [[2, 'Smith'] as Serializable[], [3, 'Jones'] as 
Serializable[], [10, 'Cruz'] as Serializable[]] as List<Serializable[]>] as 
WriteRowsEventData
    +        ))
    +
    +        // ALTER TABLE
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: EventType.QUERY, 
nextPosition: 32] as EventHeaderV4,
    +                [database: 'myDB', sql: 'ALTER TABLE myTable add column 
col1 int'] as QueryEventData
    +        ))
    +
    +        client.sendEvent(new Event(
    +                [timestamp: new Date().time, eventType: EventType.XID, 
nextPosition: 40] as EventHeaderV4,
    +                {} as EventData
    +        ))
    +
    +        testRunner.run(1, true, false)
    +
    +        def resultFiles = 
testRunner.getFlowFilesForRelationship(CaptureChangeMySQL.REL_SUCCESS)
    +        // No 'schema_change' events expected
    +        List<String> expectedEventTypes = ([] + 'begin' + 
Collections.nCopies(3, 'insert') + 'commit')
    --- End diff --
    
    Done (set to true to include them again)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to