Blog

MySQL: Test data script

I created this for work, but adding here for archival purposes.


DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `create_new_srp_listings_data`(numOfRuns INT)
BEGIN
  DECLARE listingCounter INT;
  DECLARE seatCounter INT;
  DECLARE secnamCounter INT;
  DECLARE listingId BIGINT;
  DECLARE listingSeatId INT;
  DECLARE recordExpiryDate TIMESTAMP;

  SET listingCounter = 0;
  WHILE listingCounter < numOfRuns DO
    SET listingId = FLOOR(RAND() * 40000000001) + (RAND() * 63072000);
    SET recordExpiryDate = FROM_UNIXTIME(UNIX_TIMESTAMP('2016-07-01 14:53:27') + FLOOR(0 + (RAND() * 63072000)));

    INSERT INTO third_party_adapter.srp_listing        
    (
      listing_id,
      listing_version_id,
      last_ingestion_id,
      inventory_source_id,
      inventory_source_reference_id,
      event_start_date,
      active,
      sync_timestamp,
      inventory_source_event_id,
      jetson_event_id,
      is_barcode_available,
      version_index,
      version_status,
      record_expiry_date,
      created,
      last_update,
      persistence_version,
      app_created,
      app_last_update
    ) 
    VALUES
    (
      listingId,
      FLOOR(RAND() * 40000000001) + 100,
      1,
      CONCAT('inventorysourceid_', FLOOR(RAND() * 40000000001) + (RAND() * 63072000)),
      CONCAT('inventorysourcerefid_', FLOOR(RAND() * 40000000001) + (RAND() * 63072000)),
      now(),
      'Y',
      now(), -- sync_timestamp
      CONCAT('eventid_', FLOOR(RAND() * 40000000001) + 100),
      CONCAT('jetsoneventid_', FLOOR(RAND() * 40000000001) + 100),
      'N',
      1,
      'AVAILABLE',
      recordExpiryDate,
      now(),
      now(),
      1,
      now(),
      now()
     );
    -- END srp_listing

    -- BEGIN srp_listing_seat
    SET seatCounter = 0;
    WHILE seatCounter < (FLOOR(1 + RAND() * 6)) DO
      INSERT INTO third_party_adapter.srp_listing_seat
      (
        listing_id,
        active,
        is_available,
        seat_name,
        record_expiry_date
      )
      VALUES
      (
        listingId,
        'Y',
        'Y',
        CONCAT('seat_', FLOOR (RAND() * 40001) + 100),
        recordExpiryDate
      );

      -- BEGIN srp_secnam_data
      SET secnamCounter = 0;
      SET listingSeatId = (SELECT LAST_INSERT_ID());
      WHILE secnamCounter < (FLOOR(1 + RAND() * 6)) DO
        INSERT INTO third_party_adapter.srp_secnam_data
        (
          listing_seat_id,
          add_na,
          group_num,
          active,
          record_expiry_date
        )
        VALUES
        (
          listingSeatId,
          CONCAT('addna_', FLOOR (RAND() * 40001) + 100),
          CONCAT('groupnum_', FLOOR (RAND() * 40001) + 100),
          'Y',
          recordExpiryDate
        );
        SET secnamCounter = secnamCounter + 1; 
      END WHILE;
      -- END srp_secnam_data

      SET seatCounter = seatCounter + 1; 
    END WHILE;
    -- END srp_listing_seat

    SET listingCounter = listingCounter + 1; 
  END WHILE; 
    -- END srp_listing
END

Maven build error: “Caused by: java.io.IOException: Incompatible version 1007”

I was encountering this error in Jenkins when it tried to build a project I was working on:


Caused by: java.io.IOException: Incompatible version 1007.
at org.jacoco.core.data.ExecutionDataReader.readHeader(ExecutionDataReader.java:127)
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:107)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)
at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:134)
at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107)

The problem was due to a breakage/bug in the jacoco-maven-plugin. To fix, simply add a version in your pom.xml, like so:


<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.4.201502262128</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
    </executions>
</plugin>

That’s it!