Skip to content

Commit

Permalink
EFCore Sql Server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galvesribeiro committed Oct 7, 2023
1 parent 32257bb commit 659aa2b
Show file tree
Hide file tree
Showing 67 changed files with 2,327 additions and 181 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,41 @@ jobs:
path: |
**/TestResults/*
**/logs/*
test-efcore-sqlserver:
name: Microsoft Entity Framework Core SQL Server provider tests
runs-on: ubuntu-latest
strategy:
matrix:
provider: [ "EFCore-SqlServer" ]
services:
mssql:
image: mcr.microsoft.com/mssql/server:latest
ports:
- 1433:1433
env:
ACCEPT_EULA: "Y"
MSSQL_PID: "Developer"
# [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="False positive")]
SA_PASSWORD: "yourStrong(!)Password"
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
7.0.x
- name: Test
run: dotnet test --filter "Category=${{ matrix.provider }}&(Category=BVT|Category=SlowBVT|Category=Functional)" --blame-hang-timeout 10m --logger "trx" -- -parallel none -noshadow
- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: test_output
retention-days: 1
path: |
**/TestResults/*
**/logs/*
test-sqlserver:
name: Microsoft SQL Server provider tests
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<PackageVersion Include="Azure.Storage.Blobs" Version="12.14.0" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.12.0" />
<!-- 3rd party packages -->
<PackageVersion Include="MySql.EntityFrameworkCore" Version="7.0.5" />
<PackageVersion Include="AWSSDK.DynamoDBv2" Version="3.7.5.16" />
<PackageVersion Include="AWSSDK.SQS" Version="3.7.2.119" />
<PackageVersion Include="Consul" Version="1.6.10.7" />
Expand Down
7 changes: 7 additions & 0 deletions Orleans.sln
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.Persistence.EntityF
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.Reminders.EntityFrameworkCore.SqlServer", "src\EFCore\Orleans.Reminders.EntityFrameworkCore.SqlServer\Orleans.Reminders.EntityFrameworkCore.SqlServer.csproj", "{CC8ECC81-4160-47E9-B9D7-E578BAC424F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.Clustering.EntityFrameworkCore.MySql", "src\EFCore\Orleans.Clustering.EntityFrameworkCore.MySql\Orleans.Clustering.EntityFrameworkCore.MySql.csproj", "{AA369C0C-9941-469E-BD5C-E5E5DB632431}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -652,6 +654,10 @@ Global
{CC8ECC81-4160-47E9-B9D7-E578BAC424F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC8ECC81-4160-47E9-B9D7-E578BAC424F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC8ECC81-4160-47E9-B9D7-E578BAC424F7}.Release|Any CPU.Build.0 = Release|Any CPU
{AA369C0C-9941-469E-BD5C-E5E5DB632431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA369C0C-9941-469E-BD5C-E5E5DB632431}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA369C0C-9941-469E-BD5C-E5E5DB632431}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA369C0C-9941-469E-BD5C-E5E5DB632431}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -771,6 +777,7 @@ Global
{54F742D9-B721-4B2D-98F1-B2EDA8E8C70F} = {616ECAC3-2EA7-4819-9A05-EF4F4D8DDFA8}
{95F5EC32-BEFC-4FBA-8BEA-857007AEB9C6} = {616ECAC3-2EA7-4819-9A05-EF4F4D8DDFA8}
{CC8ECC81-4160-47E9-B9D7-E578BAC424F7} = {616ECAC3-2EA7-4819-9A05-EF4F4D8DDFA8}
{AA369C0C-9941-469E-BD5C-E5E5DB632431} = {616ECAC3-2EA7-4819-9A05-EF4F4D8DDFA8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BFB3429-B5BB-4DB1-95B4-67D77A864952}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` (
`MigrationId` varchar(150) NOT NULL,
`ProductVersion` varchar(32) NOT NULL,
PRIMARY KEY (`MigrationId`)
);

START TRANSACTION;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
CREATE TABLE `Clusters` (
`Id` varchar(255) NOT NULL,
`Timestamp` datetime(6) NOT NULL,
`Version` int NOT NULL,
`ETag` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (`Id`)
);
END;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
CREATE TABLE `Silos` (
`ClusterId` varchar(255) NOT NULL,
`Address` varchar(45) NOT NULL,
`Port` int NOT NULL,
`Generation` int NOT NULL,
`Name` varchar(150) NOT NULL,
`HostName` varchar(150) NOT NULL,
`Status` int NOT NULL,
`ProxyPort` int NULL,
`SuspectingTimes` longtext NULL,
`SuspectingSilos` longtext NULL,
`StartTime` datetime(6) NOT NULL,
`IAmAliveTime` datetime(6) NOT NULL,
`ETag` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (`ClusterId`, `Address`, `Port`, `Generation`),
CONSTRAINT `FK_Silos_Clusters_ClusterId` FOREIGN KEY (`ClusterId`) REFERENCES `Clusters` (`Id`) ON DELETE CASCADE
);
END;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
CREATE INDEX `IDX_Silo_ClusterId` ON `Silos` (`ClusterId`);
END;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
CREATE INDEX `IDX_Silo_ClusterId_Status` ON `Silos` (`ClusterId`, `Status`);
END;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
CREATE INDEX `IDX_Silo_ClusterId_Status_IAmAlive` ON `Silos` (`ClusterId`, `Status`, `IAmAliveTime`);
END;

IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory` WHERE `MigrationId` = '20231007024046_InitialClusteringSchema')
BEGIN
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20231007024046_InitialClusteringSchema', '7.0.11');
END;

COMMIT;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;

#nullable disable

namespace Orleans.Clustering.EntityFrameworkCore.MySql.Data.Migrations
{
/// <inheritdoc />
public partial class InitialClusteringSchema : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySQL:Charset", "utf8mb4");

migrationBuilder.CreateTable(
name: "Clusters",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false),
Timestamp = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
ETag = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.ComputedColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_Cluster", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");

migrationBuilder.CreateTable(
name: "Silos",
columns: table => new
{
ClusterId = table.Column<string>(type: "varchar(255)", nullable: false),
Address = table.Column<string>(type: "varchar(45)", maxLength: 45, nullable: false),
Port = table.Column<int>(type: "int", nullable: false),
Generation = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "varchar(150)", maxLength: 150, nullable: false),
HostName = table.Column<string>(type: "varchar(150)", maxLength: 150, nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
ProxyPort = table.Column<int>(type: "int", nullable: true),
SuspectingTimes = table.Column<string>(type: "longtext", nullable: true),
SuspectingSilos = table.Column<string>(type: "longtext", nullable: true),
StartTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
IAmAliveTime = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: false),
ETag = table.Column<DateTime>(type: "datetime(6)", rowVersion: true, nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.ComputedColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_Silo", x => new { x.ClusterId, x.Address, x.Port, x.Generation });
table.ForeignKey(
name: "FK_Silos_Clusters_ClusterId",
column: x => x.ClusterId,
principalTable: "Clusters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");

migrationBuilder.CreateIndex(
name: "IDX_Silo_ClusterId",
table: "Silos",
column: "ClusterId");

migrationBuilder.CreateIndex(
name: "IDX_Silo_ClusterId_Status",
table: "Silos",
columns: new[] { "ClusterId", "Status" });

migrationBuilder.CreateIndex(
name: "IDX_Silo_ClusterId_Status_IAmAlive",
table: "Silos",
columns: new[] { "ClusterId", "Status", "IAmAliveTime" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Silos");

migrationBuilder.DropTable(
name: "Clusters");
}
}
}
Loading

0 comments on commit 659aa2b

Please sign in to comment.