Akka.Persistence.Sql test data exporter tool
Перейти к файлу
Gregorius Soedharmo 13b457f3dc
Merge pull request #5 from akkadotnet/Update-RELEASE_NOTES-for-0.3.0
Update RELEASE_NOTES.md for 0.3.0 release
2024-10-02 23:51:01 +07:00
build-system Update docker-release.yaml for Azure Pipelines 2022-11-04 14:13:14 -05:00
docs/images Use Directory.Build.props 2022-10-12 01:09:10 +07:00
src Update MS SqlServer base docker image to 2022-latest 2024-10-02 23:43:51 +07:00
.gitattributes Initial commit 2022-10-01 07:18:39 +07:00
.gitignore Initial commit 2022-10-01 07:18:39 +07:00
Akka.Persistence.Sql.Exporter.sln Update RELEASE_NOTES.md for 0.3.0 release 2024-10-02 23:50:31 +07:00
Akka.Persistence.Sql.Exporter.sln.DotSettings Add PostgreSql.Exporter 2022-10-12 04:52:47 +07:00
LICENSE Initial commit 2022-10-01 07:09:54 +07:00
README.md Update RELEASE_NOTES.md for 0.3.0 release 2024-10-02 23:50:31 +07:00
RELEASE_NOTES.md Update RELEASE_NOTES.md for 0.3.0 release 2024-10-02 23:50:31 +07:00
build.ps1 Fix build script 2022-11-05 01:29:36 +07:00
build.sh Fix build script 2022-11-05 01:29:36 +07:00

README.md

Akka.Persistence.Sql.Exporter

This repository is used to generate data for Akka.Persistence.Sql backward compatibility test. It generates a standardized test data and package them inside a docker container.

Supported Akka Persistence Module

  • Akka.Persistence.MySql
  • Akka.Persistence.PostgreSql
  • Akka.Persistence.Sqlite
  • Akka.Persistence SqlServer

Data Generation

  • Persisted data types: int, string, ShardedMessage, CustomShardedMessage
    • ShardedMessage contains a single int payload and saved using standard serializer
    • CustomShardedMessage contains a single int payload and saved using a custom serializer CustomSerializer with serializer ID 999
  • Each data types are persisted using 0, 1, and 2 tags
    • Tags are "Tag1" and "Tag2"
  • Data are generated using a 3 node cluster into 100 entities.

Entity State

The test entities are very simple, they contain 2 tracked states:

  • Total: The aggregate total of all passed messages.
  • Persisted: The total number of messages received by the entity.

Entity ID Generation

Entity ID are generated from the int message itself using this formula:

int msg;
const int MaxEntities = 100;
string entityId = ((msg / 3) % MaxEntities).ToString();

Round Of Data Generation

A round of data generation is done by sending a sequence of [0..299] integer messages of each data type to the shard region actor. On each round, each entity will persist exactly 12 data consisting each data type in all the tag variants.

Full Data Generation

A full data generation is done in this exact order:

  • Round of data generation.
  • Save snapshot and delete journal.
  • Round of data generation.
  • Save snapshot.
  • Round of data generation.

At the end of data generation, each entity should have persisted 36 messages and have 2 snapshots.

Database Content

At the end of full data generation, the database journal, snapshot, and metadata table will contain data from both Sharding and Persistence.

Predicting Final Entity State

State

var baseValue = persistentId * 3;
var roundTotal = (baseValue + baseValue + 1 + baseValue + 2) * 4;

Total = roundTotal * 3;
Persisted = 36;

Tags

int msg;
var tagCount = (msg % 3);
  • The message is not tagged tagged if msg % 3 == 0,
  • tagged with ["Tag1"] if msg % 3 == 1, and
  • tagged with ["Tag1", "Tag2"] when msg % 3 == 2.

Creating Test Environment

All the needed environment code are in the Akka.Persistence.Sql.Exporter.Shared project. The start code automatically start a 3 node cluster with all the required configuration set.

void Setup(AkkaConfigurationBuilder builder, IServiceProvider provider)
{
    var config = ConfigurationFactory.ParseString($@"
                akka.persistence.journal {{
                    plugin = ""akka.persistence.journal.mysql""
                    mysql.connection-string = ""{docker.ConnectionString}""
                }}
                akka.persistence.snapshot-store {{
                    plugin = ""akka.persistence.snapshot-store.mysql""
                    mysql.connection-string = ""{docker.ConnectionString}""
                }}").WithFallback(MySqlPersistence.DefaultConfiguration());

    builder
        .AddHocon(config);
}

await using var testCluster = new TestCluster(Setup, "mysql");
await testCluster.StartAsync();

Building Docker Image

  • Change the plugin version in the .csproj file to the version you want to make a specific data dump for
  • Run the build.ps1 script
    • .\build.ps1 all to create all data docker images
    • .\build.ps1 mysql to create a MySql docker image
    • .\build.ps1 postgresql to create a PostgreSql docker image
    • .\build.ps1 sqlite to create a SqLite data file
    • .\build.ps1 sqlserver to create a MS SQL Server docker image