Skip to content

Commit

Permalink
Move simulation to ADO too, and shorten the length of its run to not …
Browse files Browse the repository at this point in the history
…delay PRs (#5827)
  • Loading branch information
achamayou authored Nov 10, 2023
1 parent 56ee39e commit da37dbf
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 34 deletions.
10 changes: 10 additions & 0 deletions .azure-pipelines-templates/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ jobs:
depends_on:
- configure

- ${{ if eq(parameters.perf_tests, 'run') }}:
- template: simulation.yml
parameters:
target: Virtual
env: ${{ parameters.env.Virtual }}
installExtendedTestingTools: false
depends_on:
- configure

- ${{ if eq(parameters.perf_tests, 'run') }}:
- template: cimetrics.yml
parameters:
Expand All @@ -171,6 +180,7 @@ jobs:
- Virtual_Perf_MultiThreaded
- SGX_Perf_MultiThreaded
- Model_Checking
- Simulation

# Release
- ${{ if eq(parameters.perf_or_release, 'release') }}:
Expand Down
38 changes: 38 additions & 0 deletions .azure-pipelines-templates/simulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
jobs:
- job: Simulation
displayName: Simulation
variables:
Codeql.SkipTaskAutoInjection: true
skipComponentGovernanceDetection: true

${{ insert }}: ${{ parameters.env }}

steps:
- checkout: self
clean: true
fetchDepth: 1

- script: |
set -ex
sudo apt update
sudo apt install -y default-jre
python3 ./tla/install_deps.py
displayName: Setup
- script: ./tlc.sh -workers auto -simulate -depth 500 consensus/SIMccfraft.tla -dumpTrace tla SIMccfraft.trace.tla -dumpTrace json SIMccfraft.json
workingDirectory: tla
displayName: Simulation

- script: |
set -ex
./cimetrics_env.sh python upload_tlc_stats.py sim ../tla/SIMccfraft_stats.json
env:
METRICS_MONGO_CONNECTION: $(METRICS_MONGO_CONNECTION)
workingDirectory: tests
displayName: Uploading TLC stats to cimetrics
- task: PublishPipelineArtifact@1
inputs:
artifactName: "Simulation Traces"
targetPath: tla
condition: or(failed(), canceled())
24 changes: 0 additions & 24 deletions .github/workflows/tlaplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,6 @@ on:
workflow_dispatch:

jobs:
simulation-consensus:
name: Simulation - Consensus
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: python3 ./tla/install_deps.py

- name: SIMccfraft.tla
run: |
cd tla/
./tlc.sh -workers auto -simulate -depth 500 consensus/SIMccfraft.tla -dumpTrace tla SIMccfraft.trace.tla -dumpTrace json SIMccfraft.json
- name: Upload traces in TLA and JSON format
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: tlc
path: |
tla/consensus/*_TTrace_*.tla
tla/consensus/*_TTrace_*.bin
tla/*.trace.tla
tla/*.json
model-checking-consistency:
name: Model Checking - Consistency
runs-on: [self-hosted, 1ES.Pool=gha-virtual-ccf-sub]
Expand Down
19 changes: 13 additions & 6 deletions tests/upload_tlc_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ def run(test_label, filename):
data = json.load(f)
duration_sec = data["duration"]
dstates = data["distinct"]
print(
f"Uploading metrics for {test_label} - duration: {duration_sec}, distinct states: {dstates}"
)
with cimetrics.upload.metrics(complete=False) as metrics:
metrics.put(f"tlc_{test_label}_duration_s", duration_sec)
metrics.put(f"tlc_{test_label}_states", dstates)
traces = data.get("traces", 0)
levelmean = data.get("levelmean", 0)
print(f"Uploading metrics for {test_label}: {data}")
if dstates == -1:
# Simulation
with cimetrics.upload.metrics(complete=False) as metrics:
metrics.put(f"tlc_{test_label}_traces", traces)
metrics.put(f"tlc_{test_label}_levelmean", levelmean)
else:
# Model checking
with cimetrics.upload.metrics(complete=False) as metrics:
metrics.put(f"tlc_{test_label}_duration_s", duration_sec)
metrics.put(f"tlc_{test_label}_states", dstates)

else:
print(f"Could not find file {filename}: skipping metrics upload")
Expand Down
2 changes: 1 addition & 1 deletion tla/consensus/MCccfraftWithReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ VIEW View
CHECK_DEADLOCK
FALSE

POSTCONDITION
POSTCONDITION
WriteStatsFile

PROPERTIES
Expand Down
5 changes: 5 additions & 0 deletions tla/consensus/SIMccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ CONSTANTS
NodeFour = n4
NodeFive = n5

StatsFilename = "SIMccfraft_stats.json"

CONSTRAINT
StopAfter

Expand All @@ -48,6 +50,9 @@ PROPERTIES
PendingBecomesFollowerProp
NeverCommitEntryPrevTermsProp

POSTCONDITION
WriteStatsFile

INVARIANTS
LogInv
MoreThanOneLeaderInv
Expand Down
7 changes: 4 additions & 3 deletions tla/consensus/SIMccfraft.tla
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---------- MODULE SIMccfraft ----------
EXTENDS ccfraft, TLC, Integers
EXTENDS ccfraft, TLC, Integers, StatsFile, IOUtils

CONSTANTS
NodeOne, NodeTwo, NodeThree, NodeFour, NodeFive
Expand Down Expand Up @@ -44,8 +44,9 @@ SIMSpec ==
\* The state constraint StopAfter stops TLC after the alloted
\* time budget is up, unless TLC encounteres an error first.
StopAfter ==
(* The smoke test has a time budget of 50 minutes. *)
TLCSet("exit", TLCGet("duration") > 3000)
LET timeout == IF "SIM_TIMEOUT" \in DOMAIN IOEnv THEN atoi(IOEnv.SIM_TIMEOUT) ELSE 1200
(* The smoke test has a time budget of 20 minutes. *)
IN TLCSet("exit", TLCGet("duration") > timeout)

=============================================================================

Expand Down

0 comments on commit da37dbf

Please sign in to comment.