Skip to content

Commit

Permalink
style: ran csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
chgl committed Dec 9, 2023
1 parent 4b8c52d commit 9a1270f
Show file tree
Hide file tree
Showing 27 changed files with 302 additions and 234 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ jobs:
fetch-depth: 0

- name: Install .NET
uses: actions/setup-dotnet@a351d9ea84bc76ec7508debf02a39d88f8b6c0c0 # tag=v2
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
dotnet-version: "7.0.x"
include-prerelease: true
dotnet-version: "8.0.x"

- name: Run benchmark
run: dotnet run -c Release --project=src/Vfps.Benchmarks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
UNIT_TEST_IMAGE: ${{ fromJson(needs.build.outputs.test-image-meta-json).tags[0] }}
run: |
docker create --name=unit-test-container "${UNIT_TEST_IMAGE}"
docker cp unit-test-container:/build/src/FhirPseudonymizer.Tests/coverage ./coverage
docker cp unit-test-container:/build/src/Vfps.Tests/coverage ./coverage
- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # tag=v1.3.0
Expand Down
74 changes: 17 additions & 57 deletions .github/workflows/nightly-chaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: nightly chaos testing
on:
workflow_dispatch: {}
schedule:
# daily at 04:07.
# daily at 04:07
- cron: "07 04 * * *"

# Declare default permissions as read only.
Expand All @@ -22,64 +22,24 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2

- name: Build stress testing image
id: build-image
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3
- name: Install Task
uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1.0.3
with:
push: false
load: true
tags: ghcr.io/miracum/vfps/stress-test:v1
cache-from: type=gha
cache-to: type=gha,mode=max
target: stress-test
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create KinD cluster
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
with:
cluster_name: kind

- name: Load stress-test image into KinD
run: |
kind load docker-image ghcr.io/miracum/vfps/stress-test:v1
- name: Run chaos-test task
run: task chaos-test

- name: Install prerequisites
working-directory: tests/chaos
- name: Print cluster logs
if: always()
run: |
curl -sL -o - https://github.com/argoproj/argo-workflows/releases/download/v3.4.3/argo-linux-amd64.gz | gunzip > argo
chmod +x ./argo
./argo version
kubectl create ns vfps
helm repo add chaos-mesh https://charts.chaos-mesh.org
helm upgrade --install chaos-mesh chaos-mesh/chaos-mesh \
--create-namespace \
--wait \
-n chaos-mesh \
--set chaosDaemon.runtime=containerd \
--set chaosDaemon.socketPath='/run/containerd/containerd.sock' \
--version 2.4.3
kubectl apply -f chaos-mesh-rbac.yaml
kubectl cluster-info dump -o yaml | tee kind-cluster-dump.txt
helm upgrade --install \
--create-namespace \
--wait \
-n argo-workflows \
-f argo-workflows-values.yaml \
argo-workflows oci://ghcr.io/argoproj/argo-helm/argo-workflows
- name: Install vfps
working-directory: tests/chaos
run: |
helm upgrade --install \
-n vfps \
-f vfps-values.yaml \
--wait \
--version=^1.0.0 \
vfps oci://ghcr.io/miracum/charts/vfps
- name: Run chaos testing workflow
working-directory: tests/chaos
run: |
./argo submit argo-workflow.yaml -n vfps --wait --log
- name: Upload cluster dump
if: always()
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: kind-cluster-dump.txt
path: |
kind-cluster-dump.txt
1 change: 1 addition & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DISABLE:
DISABLE_LINTERS:
- REPOSITORY_DEVSKIM
- SPELL_LYCHEE
- MARKDOWN_MARKDOWN_LINK_CHECK

SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,13 @@ docker build -t ghcr.io/miracum/vfps:${IMAGE_TAG} .

kind load docker-image ghcr.io/miracum/vfps:${IMAGE_TAG}

helm repo add miracum https://miracum.github.io/charts
helm repo update

helm install \
helm upgrade --install \
--set="image.tag=${IMAGE_TAG}" \
-f tests/iter8/values.yaml \
--wait \
--timeout=15m \
--version=^1.0.0 \
vfps miracum/vfps
vfps oci://ghcr.io/miracum/charts/vfps

kubectl apply -f tests/iter8/experiment.yaml

Expand Down
46 changes: 46 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "3"

tasks:
build-stress-test-image:
desc: build the container image used for stress testing
vars:
BUILDKIT_PROGRESS: plain
cmds:
- docker build -t ghcr.io/miracum/vfps/stress-test:v1 --target=stress-test --iidfile=./stress-test-iid.txt .
sources:
- src/Vfps.StressTests/*.cs
generates:
- ./stress-test-iid.txt

install-argo-cli:
desc: download and install the argo workflows cli
dir: tests/chaos
cmds:
- curl -sL -o - https://github.com/argoproj/argo-workflows/releases/download/v3.5.2/argo-linux-amd64.gz | gunzip > argo
- chmod +x ./argo
- ./argo version
status:
- ./argo version

create-cluster:
desc: create a KinD cluster
cmds:
- kind create cluster --name kind
status:
- kind get clusters | grep kind

chaos-test:
desc: run the chaos testing workflow
dir: tests/chaos
deps:
- create-cluster
- install-argo-cli
- build-stress-test-image
cmds:
- helm repo add chaos-mesh https://charts.chaos-mesh.org
- kind load docker-image ghcr.io/miracum/vfps/stress-test:v1
- helm upgrade --install --create-namespace -n vfps -f vfps-values.yaml --wait vfps oci://ghcr.io/miracum/charts/vfps
- helm upgrade --install chaos-mesh chaos-mesh/chaos-mesh --create-namespace --wait -n chaos-mesh --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath='/run/containerd/containerd.sock'
- kubectl apply -f chaos-mesh-rbac.yaml
- helm upgrade --install --create-namespace -n argo-workflows -f argo-workflows-values.yaml --wait argo-workflows oci://ghcr.io/argoproj/argo-helm/argo-workflows
- ./argo submit workflow.yaml -n vfps --wait --log
2 changes: 1 addition & 1 deletion src/Vfps.IntegrationTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
global using Xunit;
global using FluentAssertions;
global using Xunit;
13 changes: 9 additions & 4 deletions src/Vfps.StressTests/StressTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ out bool isRunningInContainer
: "./nbomber-reports";
}

private async Task<Response<object>> RunCreatePseudonyms(IScenarioContext scenarioContext, string namespaceName)
private async Task<Response<object>> RunCreatePseudonyms(
IScenarioContext scenarioContext,
string namespaceName
)
{
return await Step.Run(
"create_pseudonyms",
Expand Down Expand Up @@ -106,9 +109,11 @@ public void RunStressSimulation()
}
catch (RpcException exc) when (exc.StatusCode == StatusCode.AlreadyExists)
{
context.Logger.Warning(
$"Namespace {namespaceRequest.Name} already exists. Continuing anyway."
);
context
.Logger
.Warning(
$"Namespace {namespaceRequest.Name} already exists. Continuing anyway."
);
}
})
.WithWarmUpDuration(TimeSpan.FromSeconds(5))
Expand Down
6 changes: 3 additions & 3 deletions src/Vfps.StressTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
global using Xunit;
global using FluentAssertions;
global using Grpc.Core;
global using Grpc.Net.Client;
global using Grpc.Net.Client.Configuration;
global using Vfps.Protos;
global using NBomber.Contracts;
global using NBomber.CSharp;
global using FluentAssertions;
global using Vfps.Protos;
global using Xunit;
12 changes: 9 additions & 3 deletions src/Vfps.Tests/ControllerTests/FhirControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public async Task CreatePseudonym_WithEmptyBody_ShouldReturnErrorOutcome()
response
.Should()
.BeOfType<BadRequestObjectResult>()
.Which.Value.Should()
.Which
.Value
.Should()
.BeOfType<OperationOutcome>();
}

Expand All @@ -44,7 +46,9 @@ public async Task CreatePseudonym_WithNull_ShouldReturnErrorOutcome()
response
.Should()
.BeOfType<BadRequestObjectResult>()
.Which.Value.Should()
.Which
.Value
.Should()
.BeOfType<OperationOutcome>();
}

Expand Down Expand Up @@ -73,7 +77,9 @@ public async Task CreatePseudonym_WithExistingNamespaceRequested_ShouldSucceed()
var parameterResponse = response
.Should()
.BeOfType<OkObjectResult>()
.Which.Value.Should()
.Which
.Value
.Should()
.BeOfType<Parameters>()
.Which;

Expand Down
2 changes: 1 addition & 1 deletion src/Vfps.Tests/MemoryCacheMetricsBackgroundServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;
using Microsoft.Extensions.Caching.Memory;
using Prometheus;
using System.Text;

namespace Vfps.Tests.MemoryCacheMetricsBackgroundServiceTests;

Expand Down
9 changes: 6 additions & 3 deletions src/Vfps.Tests/ServiceTests/NamespaceServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public async Task Delete_WithNamespaceContainingPseudonyms_ShouldDeleteNamespace
await pseudonymService.Create(createPseudonymRequest, TestServerCallContext.Create());
}

var pseudonymCount = await InMemoryPseudonymContext.Pseudonyms
var pseudonymCount = await InMemoryPseudonymContext
.Pseudonyms
.AsNoTracking()
.Where(p => p.NamespaceName == createRequest.Name)
.CountAsync();
Expand All @@ -154,13 +155,15 @@ public async Task Delete_WithNamespaceContainingPseudonyms_ShouldDeleteNamespace

await sut.Delete(deleteRequest, TestServerCallContext.Create());

InMemoryPseudonymContext.Namespaces
InMemoryPseudonymContext
.Namespaces
.AsNoTracking()
.Where(n => n.Name == deleteRequest.Name)
.Should()
.BeEmpty();

pseudonymCount = await InMemoryPseudonymContext.Pseudonyms
pseudonymCount = await InMemoryPseudonymContext
.Pseudonyms
.AsNoTracking()
.Where(p => p.NamespaceName == createRequest.Name)
.CountAsync();
Expand Down
17 changes: 11 additions & 6 deletions src/Vfps.Tests/ServiceTests/PseudonymServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Grpc.Core;
using Microsoft.Extensions.Caching.Memory;
using System.Diagnostics;

namespace Vfps.Tests.ServiceTests;

Expand Down Expand Up @@ -63,7 +63,8 @@ public async Task Create_ShouldSaveNewPseudonym()
response.Pseudonym.OriginalValue.Should().Be(request.OriginalValue);
response.Pseudonym.PseudonymValue.Should().NotBeNull(request.OriginalValue);

InMemoryPseudonymContext.Pseudonyms
InMemoryPseudonymContext
.Pseudonyms
.Should()
.Contain(
p =>
Expand Down Expand Up @@ -99,21 +100,24 @@ public async Task Create_CalledMultipleTimesWithTheSameOriginalValue_ShouldOnlyS

var response = await sut.Create(request, TestServerCallContext.Create());
var firstCreatedPseudonym = response.Pseudonym.PseudonymValue;
InMemoryPseudonymContext.Pseudonyms
InMemoryPseudonymContext
.Pseudonyms
.Where(p => p.NamespaceName == request.Namespace)
.Should()
.HaveCount(1);

response = await sut.Create(request, TestServerCallContext.Create());
response.Pseudonym.PseudonymValue.Should().Be(firstCreatedPseudonym);
InMemoryPseudonymContext.Pseudonyms
InMemoryPseudonymContext
.Pseudonyms
.Where(p => p.NamespaceName == request.Namespace)
.Should()
.HaveCount(1);

response = await sut.Create(request, TestServerCallContext.Create());
response.Pseudonym.PseudonymValue.Should().Be(firstCreatedPseudonym);
InMemoryPseudonymContext.Pseudonyms
InMemoryPseudonymContext
.Pseudonyms
.Where(p => p.NamespaceName == request.Namespace)
.Should()
.HaveCount(1);
Expand Down Expand Up @@ -251,7 +255,8 @@ public async Task List_WithMoreItemsThanPageSize_ShouldReturnAllPseudonymsViaPag
await sut.Create(createRequest, TestServerCallContext.Create());
}

InMemoryPseudonymContext.Pseudonyms
InMemoryPseudonymContext
.Pseudonyms
.Where(p => p.NamespaceName == namespaceName)
.Count()
.Should()
Expand Down
2 changes: 1 addition & 1 deletion src/Vfps.Tests/ServiceTests/TestServerCallContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#endregion

using Grpc.Core;
using System.Diagnostics.CodeAnalysis;
using Grpc.Core;

namespace Vfps.Tests.ServiceTests;

Expand Down
2 changes: 1 addition & 1 deletion src/Vfps.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global using Xunit;
global using FluentAssertions;
global using Vfps.Data;
global using Vfps.Protos;
global using Xunit;
2 changes: 1 addition & 1 deletion src/Vfps.Tests/WebAppTests/TestFactory.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.CodeAnalysis;

namespace Vfps.Tests.WebAppTests;

Expand Down
3 changes: 2 additions & 1 deletion src/Vfps/Data/PseudonymContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
// This only supports millisecond precision, but should be sufficient for most use cases.
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
var properties = entityType.ClrType
var properties = entityType
.ClrType
.GetProperties()
.Where(
p =>
Expand Down
Loading

0 comments on commit 9a1270f

Please sign in to comment.