Skip to content

Commit

Permalink
Bug fixes after processCommand restructuring; other cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottArbeit committed Nov 26, 2023
1 parent b52a8fa commit 0adeaa2
Show file tree
Hide file tree
Showing 20 changed files with 526 additions and 219 deletions.
16 changes: 8 additions & 8 deletions src/.grace/graceconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"OwnerId": "f37d3fcd-5f76-4187-942d-890f21656ebe",
"OwnerName": "Owner9FED",
"OrganizationId": "df1e97e4-5ee9-4e37-b095-4a677b44ef57",
"OrganizationName": "Organization001",
"RepositoryId": "8c4eae5f-f734-4067-a39f-ce2d9c9fabbc",
"RepositoryName": "Repository001",
"BranchId": "de9220fb-e2bc-4562-b5c4-1798d81100c1",
"BranchName": "main",
"OwnerId": "1d0f3f91-a98a-4188-bff5-a2914b52301a",
"OwnerName": "Owner85F5",
"OrganizationId": "80be1fb5-35bb-4f23-b64c-99528d6d920d",
"OrganizationName": "Org85F5",
"RepositoryId": "a81b4530-3d2d-4485-af93-fbfa3c41f0d9",
"RepositoryName": "Repo85F5",
"BranchId": "8cb99933-2c2b-4121-a4d4-67ce6b61cbb9",
"BranchName": "Branch85F5",
"DefaultBranchName": "main",
"Themes": [
{
Expand Down
56 changes: 32 additions & 24 deletions src/Create-Grace-Objects.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
$startTime = Get-Date

$words = "Sit fusce at sociosqu eros bibendum aliquet cursus ante non facilisis tempor Scelerisque arcu potenti feugiat fermentum viverra et litora facilisis vestibulum sit aliquam quisque sagittis ut Ultricies nisi urna cursus tellus tempor vivamus nec Dictumst tristique porta vel cubilia mollis Tempus nullam laoreet sit vestibulum etiam in volutpat dui class netus morbi Duis facilisis at aliquet fusce nisi Nulla arcu molestie mauris integer aenean ligula curabitur dui sociosqu suspendisse mi fringilla faucibus Rhoncus habitasse massa amet ipsum ligula quisque Quisque fames bibendum eu ullamcorper pulvinar in aenean hendrerit Augue tristique aenean amet auctor curabitur congue placerat aenean posuere porttitor pulvinar lectus Mattis aenean elit condimentum nam iaculis ante felis sollicitudin Risus viverra ornare curabitur sem massa nibh vulputate senectus dictum vitae leo varius dictumst tristique Ultrices ut blandit adipiscing dictumst sagittis elementum urna Vel feugiat consectetur malesuada nibh turpis odio convallis molestie vulputate magna venenatis lacinia Suscipit consequat lectus nullam suspendisse aliquam sed venenatis Feugiat vehicula iaculis donec aenean Volutpat amet feugiat fringilla bibendum scelerisque fermentum pellentesque hendrerit dapibus primis eu ipsum proin mauris Amet magna non mattis dictum risus sit Luctus hendrerit in integer euismod sapien aenean vel maecenas venenatis lorem cubilia taciti Id mauris dictum aenean leo quisque auctor sagittis nisl rutrum at Iaculis luctus orci egestas metus commodo praesent sodales nam quis conubia cras sagittis vestibulum Viverra justo cursus tempor fringilla egestas Potenti aliquam quisque tincidunt pellentesque Lacinia eu convallis quis risus accumsan Augue adipiscing orci massa lorem curabitur eleifend tincidunt justo varius vulputate Mollis aenean est pulvinar proin in donec bibendum dolor quis sociosqu mattis mi Euismod urna leo mollis potenti fames mattis ultrices diam Vivamus sit mattis vehicula viverra mi imperdiet Adipiscing est vehicula scelerisque velit Malesuada integer quisque fusce quis mollis eros Leo nec tellus curabitur ornare amet quisque fusce habitasse morbi Sem lacinia eu aenean pretium curae dolor cubilia faucibus purus Sollicitudin nisl tempus auctor etiam felis urna consectetur donec dui Posuere elit orci lobortis magna Enim at pellentesque ac taciti convallis sapien ad elit Integer potenti malesuada lacinia fames euismod amet purus justo sociosqu dolor cras tempus dictumst Dictumst adipiscing quisque sapien pharetra pretium aliquam nunc ipsum varius mi justo aenean mattis Aenean conubia felis inceptos nulla ante sociosqu libero non imperdiet Nunc feugiat sodales commodo interdum rhoncus nulla aliquet cras sociosqu eros sed Vivamus varius sapien sollicitudin curabitur class aenean tempus tempor magna donec bibendum nulla morbi semper Praesent inceptos etiam tempus in Varius hac et feugiat nullam dictum vivamus adipiscing ut in eros nulla molestie ante Interdum dictum volutpat accumsan posuere quis amet curae nostra purus fusce nisl lacus Aenean erat suscipit urna ante In ad varius interdum porta at pulvinar aptent enim nam sit ultrices hendrerit Vitae rhoncus consequat non metus nullam augue Massa vestibulum dapibus lectus nibh at tortor ullamcorper mattis rutrum pellentesque aliquam adipiscing porttitor".Split()

1..1 | ForEach-Object -Parallel {
$words = "Sit fusce at sociosqu eros bibendum aliquet cursus ante non facilisis tempor Scelerisque arcu potenti feugiat fermentum viverra et litora facilisis vestibulum sit aliquam quisque sagittis ut Ultricies nisi urna cursus tellus tempor vivamus nec Dictumst tristique porta vel cubilia mollis Tempus nullam laoreet sit vestibulum etiam in volutpat dui class netus morbi Duis facilisis at aliquet fusce nisi Nulla arcu molestie mauris integer aenean ligula curabitur dui sociosqu suspendisse mi fringilla faucibus Rhoncus habitasse massa amet ipsum ligula quisque Quisque fames bibendum eu ullamcorper pulvinar in aenean hendrerit Augue tristique aenean amet auctor curabitur congue placerat aenean posuere porttitor pulvinar lectus Mattis aenean elit condimentum nam iaculis ante felis sollicitudin Risus viverra ornare curabitur sem massa nibh vulputate senectus dictum vitae leo varius dictumst tristique Ultrices ut blandit adipiscing dictumst sagittis elementum urna Vel feugiat consectetur malesuada nibh turpis odio convallis molestie vulputate magna venenatis lacinia Suscipit consequat lectus nullam suspendisse aliquam sed venenatis Feugiat vehicula iaculis donec aenean Volutpat amet feugiat fringilla bibendum scelerisque fermentum pellentesque hendrerit dapibus primis eu ipsum proin mauris Amet magna non mattis dictum risus sit Luctus hendrerit in integer euismod sapien aenean vel maecenas venenatis lorem cubilia taciti Id mauris dictum aenean leo quisque auctor sagittis nisl rutrum at Iaculis luctus orci egestas metus commodo praesent sodales nam quis conubia cras sagittis vestibulum Viverra justo cursus tempor fringilla egestas Potenti aliquam quisque tincidunt pellentesque Lacinia eu convallis quis risus accumsan Augue adipiscing orci massa lorem curabitur eleifend tincidunt justo varius vulputate Mollis aenean est pulvinar proin in donec bibendum dolor quis sociosqu mattis mi Euismod urna leo mollis potenti fames mattis ultrices diam Vivamus sit mattis vehicula viverra mi imperdiet Adipiscing est vehicula scelerisque velit Malesuada integer quisque fusce quis mollis eros Leo nec tellus curabitur ornare amet quisque fusce habitasse morbi Sem lacinia eu aenean pretium curae dolor cubilia faucibus purus Sollicitudin nisl tempus auctor etiam felis urna consectetur donec dui Posuere elit orci lobortis magna Enim at pellentesque ac taciti convallis sapien ad elit Integer potenti malesuada lacinia fames euismod amet purus justo sociosqu dolor cras tempus dictumst Dictumst adipiscing quisque sapien pharetra pretium aliquam nunc ipsum varius mi justo aenean mattis Aenean conubia felis inceptos nulla ante sociosqu libero non imperdiet Nunc feugiat sodales commodo interdum rhoncus nulla aliquet cras sociosqu eros sed Vivamus varius sapien sollicitudin curabitur class aenean tempus tempor magna donec bibendum nulla morbi semper Praesent inceptos etiam tempus in Varius hac et feugiat nullam dictum vivamus adipiscing ut in eros nulla molestie ante Interdum dictum volutpat accumsan posuere quis amet curae nostra purus fusce nisl lacus Aenean erat suscipit urna ante In ad varius interdum porta at pulvinar aptent enim nam sit ultrices hendrerit Vitae rhoncus consequat non metus nullam augue Massa vestibulum dapibus lectus nibh at tortor ullamcorper mattis rutrum pellentesque aliquam adipiscing porttitor".Split()
Set-Alias -Name grace -Value D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe

$suffix = (Get-Random -Maximum 65536).ToString("X4")

$ownerId = (New-Guid).ToString()
Expand All @@ -16,29 +19,34 @@ $startTime = Get-Date
$branchId = (New-Guid).ToString()
$branchName = 'Branch' + $suffix

"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe owner create --output Verbose --ownerName $ownerNameOriginal --ownerId $ownerId"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe owner set-name --output Verbose --ownerName $ownerNameOriginal --newName $ownerName"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe org create --output Verbose --ownerName $ownerName --organizationName $orgNameOriginal --organizationId $organizationId"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe org set-name --output Verbose --ownerName $ownerName --organizationName $orgNameOriginal --newName $orgName"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe repo create --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoNameOriginal --repositoryId $repoId"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe repo set-name --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoNameOriginal --newName $repoName"
"D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe branch create --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName"

1..0 | ForEach-Object {
$numberOfWords = Get-Random -Minimum 3 -Maximum 9
$start = Get-Random -Minimum 0 -Maximum ($words.Count - $numberOfWords)
$message = ''
for ($i = $0; $i -lt $numberOfWords; $i++) {
$message += $words[$i + $start] + " "
}

switch (Get-Random -Maximum 4) {
0 {D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe branch save --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName}
1 {D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe branch checkpoint --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
2 {D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe branch commit --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
3 {D:\Source\Grace\src\Grace.CLI\bin\Debug\net8.0\Grace.CLI.exe branch tag --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
}
}
grace owner create --output Verbose --ownerName $ownerNameOriginal --ownerId $ownerId
grace owner set-name --output Verbose --ownerName $ownerNameOriginal --newName $ownerName
grace org create --output Verbose --ownerName $ownerName --organizationName $orgNameOriginal --organizationId $organizationId
grace org set-name --output Verbose --ownerName $ownerName --organizationName $orgNameOriginal --newName $orgName
grace repo create --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoNameOriginal --repositoryId $repoId
grace repo set-name --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoNameOriginal --newName $repoName
grace branch create --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchId $branchId --branchName $branchName

# 1..0 | ForEach-Object {
# $numberOfWords = Get-Random -Minimum 3 -Maximum 9
# $start = Get-Random -Minimum 0 -Maximum ($words.Count - $numberOfWords)
# $message = ''
# for ($i = $0; $i -lt $numberOfWords; $i++) {
# $message += $words[$i + $start] + " "
# }

# switch (Get-Random -Maximum 4) {
# 0 {grace branch save --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName}
# 1 {grace branch checkpoint --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
# 2 {grace branch commit --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
# 3 {grace branch tag --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName -m $message}
# }
# }

grace branch delete --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --branchName $branchName
grace repo delete --output Verbose --ownerName $ownerName --organizationName $orgName --repositoryName $repoName --deleteReason "Test cleanup"
grace org delete --output Verbose --ownerName $ownerName --organizationName $orgName --deleteReason "Test cleanup"
grace owner delete --output Verbose --ownerName $ownerName --deleteReason "Test cleanup"
} -ThrottleLimit 8

$endTime = Get-Date
Expand Down
3 changes: 1 addition & 2 deletions src/Grace.Actors/Branch.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ module Branch =
let isValid (command: BranchCommand) (metadata: EventMetadata) =
task {
let! branchEvents = this.BranchEvents
logToConsole (serialize branchEvents)
if branchEvents.Exists(fun ev -> ev.Metadata.CorrelationId = metadata.CorrelationId) && (branchEvents.Count > 3) then
return Error (GraceError.Create (BranchError.getErrorMessage DuplicateCorrelationId) metadata.CorrelationId)
else
Expand Down Expand Up @@ -226,7 +225,7 @@ module Branch =
| Create (branchId, branchName, parentBranchId, basedOn, repositoryId, branchPermissions) ->
return Created(branchId, branchName, parentBranchId, basedOn, repositoryId, branchPermissions)
| Rebase referenceId -> return Rebased referenceId
| SetName organizationName -> return NameSet (organizationName)
| SetName branchName -> return NameSet branchName
| BranchCommand.Promote (directoryId, sha256Hash, referenceText) ->
let! referenceId = addReference directoryId sha256Hash referenceText ReferenceType.Promotion
metadata.Properties.Add(nameof(ReferenceId), $"{referenceId}")
Expand Down
1 change: 1 addition & 0 deletions src/Grace.Actors/Commands.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module Commands =
| SetDefaultBranchName of defaultBranchName: BranchName
| SetSaveDays of duration: double
| SetCheckpointDays of duration: double
| SetName of repositoryName: RepositoryName
| SetDescription of description: string
| EnableSingleStepPromotion of enabled: bool
| EnableComplexPromotion of enabled: bool
Expand Down
1 change: 1 addition & 0 deletions src/Grace.Actors/Events.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module Events =
| CheckpointDaysSet of duration: double
| EnabledSingleStepPromotion of enabled: bool
| EnabledComplexPromotion of enabled: bool
| NameSet of repositoryName: RepositoryName
| DescriptionSet of description: string
| LogicalDeleted of force: bool * deleteReason: string
| PhysicalDeleted
Expand Down
2 changes: 2 additions & 0 deletions src/Grace.Actors/Repository.Actor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module Repository =
| CheckpointDaysSet days -> {currentRepositoryDto with CheckpointDays = days}
| EnabledSingleStepPromotion enabled -> {currentRepositoryDto with EnabledSingleStepPromotion = enabled}
| EnabledComplexPromotion enabled -> {currentRepositoryDto with EnabledComplexPromotion = enabled}
| NameSet repositoryName -> {currentRepositoryDto with RepositoryName = repositoryName}
| DescriptionSet description -> {currentRepositoryDto with Description = description}
| LogicalDeleted _ -> {currentRepositoryDto with DeletedAt = Some (getCurrentInstant())}
| PhysicalDeleted -> currentRepositoryDto // Do nothing because it's about to be deleted anyway.
Expand Down Expand Up @@ -395,6 +396,7 @@ module Repository =
| SetCheckpointDays days -> return CheckpointDaysSet days
| EnableSingleStepPromotion enabled -> return EnabledSingleStepPromotion enabled
| EnableComplexPromotion enabled -> return EnabledComplexPromotion enabled
| SetName repositoryName -> return NameSet repositoryName
| SetDescription description -> return DescriptionSet description
| DeleteLogical (force, deleteReason) ->
// Get the list of branches that aren't already deleted.
Expand Down
Loading

0 comments on commit 0adeaa2

Please sign in to comment.