Skip to content

Commit 88eb536

Browse files
committed
Merge branch 'master' into pk910/validator-lifecycle-test-v3
2 parents 32f054f + 67bd416 commit 88eb536

File tree

6 files changed

+200
-36
lines changed

6 files changed

+200
-36
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN go mod download
66
COPY . .
77
RUN make build
88

9-
FROM ubuntu:latest
9+
FROM ubuntu:latest
1010
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
1111
libssl-dev \
1212
ca-certificates \
@@ -17,4 +17,4 @@ RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-reco
1717
&& apt-get clean \
1818
&& rm -rf /var/lib/apt/lists/*
1919
COPY --from=builder /src/bin/assertoor /assertoor
20-
ENTRYPOINT ["/assertoor"]
20+
ENTRYPOINT ["/assertoor"]

Dockerfile-local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-reco
2222
COPY --from=builder /src/bin/assertoor /assertoor
2323
RUN mkdir /workspace
2424
WORKDIR /workspace
25-
ENTRYPOINT ["/assertoor"]
25+
ENTRYPOINT ["/assertoor"]

pkg/coordinator/scheduler/task_state.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ func (ts *TaskScheduler) newTaskState(options *types.TaskOptions, parentState *t
8080
}
8181

8282
// create task state
83+
ts.taskStateMutex.Lock()
84+
defer ts.taskStateMutex.Unlock()
85+
8386
taskIdx := ts.taskCount
8487
taskState := &taskState{
8588
index: taskIdx,
@@ -110,16 +113,13 @@ func (ts *TaskScheduler) newTaskState(options *types.TaskOptions, parentState *t
110113

111114
ts.taskCount++
112115

113-
// create internal execution state
114-
ts.taskStateMutex.Lock()
115116
ts.taskStateMap[taskIdx] = taskState
116117

117118
if isCleanupTask {
118119
ts.allCleanupTasks = append(ts.allCleanupTasks, taskIdx)
119120
} else {
120121
ts.allTasks = append(ts.allTasks, taskIdx)
121122
}
122-
ts.taskStateMutex.Unlock()
123123

124124
return taskState, nil
125125
}

pkg/coordinator/web/handlers/test_run.go

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,27 @@ type TestRunPage struct {
2828
}
2929

3030
type TestRunTask struct {
31-
Index uint64 `json:"index"`
32-
ParentIndex uint64 `json:"parent_index"`
33-
GraphLevels []uint64 `json:"graph_levels"`
34-
Name string `json:"name"`
35-
Title string `json:"title"`
36-
IsStarted bool `json:"started"`
37-
IsCompleted bool `json:"completed"`
38-
StartTime time.Time `json:"start_time"`
39-
StopTime time.Time `json:"stop_time"`
40-
Timeout time.Duration `json:"timeout"`
41-
HasTimeout bool `json:"has_timeout"`
42-
RunTime time.Duration `json:"runtime"`
43-
HasRunTime bool `json:"has_runtime"`
44-
Status string `json:"status"`
45-
Result string `json:"result"`
46-
ResultError string `json:"result_error"`
47-
Log []*TestRunTaskLog `json:"log"`
48-
ConfigYaml string `json:"config_yaml"`
49-
ResultYaml string `json:"result_yaml"`
31+
Index uint64 `json:"index"`
32+
ParentIndex uint64 `json:"parent_index"`
33+
GraphLevels []uint64 `json:"graph_levels"`
34+
Name string `json:"name"`
35+
Title string `json:"title"`
36+
IsStarted bool `json:"started"`
37+
IsCompleted bool `json:"completed"`
38+
StartTime time.Time `json:"start_time"`
39+
StopTime time.Time `json:"stop_time"`
40+
Timeout time.Duration `json:"timeout"`
41+
HasTimeout bool `json:"has_timeout"`
42+
RunTime time.Duration `json:"runtime"`
43+
HasRunTime bool `json:"has_runtime"`
44+
CustomRunTime time.Duration `json:"custom_runtime"`
45+
HasCustomRunTime bool `json:"has_custom_runtime"`
46+
Status string `json:"status"`
47+
Result string `json:"result"`
48+
ResultError string `json:"result_error"`
49+
Log []*TestRunTaskLog `json:"log"`
50+
ConfigYaml string `json:"config_yaml"`
51+
ResultYaml string `json:"result_yaml"`
5052
}
5153

5254
type TestRunTaskLog struct {
@@ -267,7 +269,15 @@ func (fh *FrontendHandler) getTestRunPageData(runID int64) (*TestRunPage, error)
267269
taskData.ConfigYaml = fmt.Sprintf("\n%v\n", string(taskConfig))
268270
}
269271

270-
taskResult, err := yaml.Marshal(taskState.GetTaskStatusVars().GetVarsMap(nil, false))
272+
taskStatusVars := taskState.GetTaskStatusVars().GetVarsMap(nil, false)
273+
if taskOutput, ok := taskStatusVars["outputs"]; ok {
274+
if customRunTimeSecondsRaw, ok := taskOutput.(map[string]interface{})["customRunTimeSeconds"]; ok {
275+
taskData.CustomRunTime = time.Duration(customRunTimeSecondsRaw.(float64) * float64(time.Second))
276+
taskData.HasCustomRunTime = true
277+
}
278+
}
279+
280+
taskResult, err := yaml.Marshal(taskStatusVars)
271281
if err != nil {
272282
taskData.ResultYaml = fmt.Sprintf("failed marshalling result: %v", err)
273283
} else {

pkg/coordinator/web/templates/test_run/test_run.html

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{{ define "page" }}
22
<div class="d-flex flex-column flex-grow-1 mt-3 container-fluid">
33
<h2 class="py-2">Test Run {{ .RunID }}: {{ .Name }}</h2>
4-
4+
55
<!-- client pool status -->
66
<table class="test-header">
77
<tr>
88
<td style="width: 200px">
99
Test ID:
1010
</td>
1111
<td>
12-
{{ .TestID }}
12+
{{ .TestID }}
1313
</td>
1414
</tr>
1515
<tr>
@@ -50,7 +50,7 @@ <h2 class="py-2">Test Run {{ .RunID }}: {{ .Name }}</h2>
5050
Start Time:
5151
</td>
5252
<td>
53-
{{ formatDateTime .StartTime.UTC }}
53+
{{ formatDateTime .StartTime.UTC }}
5454
</td>
5555
</tr>
5656
{{ end }}
@@ -60,7 +60,7 @@ <h2 class="py-2">Test Run {{ .RunID }}: {{ .Name }}</h2>
6060
Finish Time:
6161
</td>
6262
<td>
63-
{{ formatDateTime .StopTime.UTC }}
63+
{{ formatDateTime .StopTime.UTC }}
6464
</td>
6565
</tr>
6666
{{ end }}
@@ -69,11 +69,11 @@ <h2 class="py-2">Test Run {{ .RunID }}: {{ .Name }}</h2>
6969
Timeout:
7070
</td>
7171
<td>
72-
{{ .Timeout }}
72+
{{ .Timeout }}
7373
</td>
7474
</tr>
7575
</table>
76-
76+
7777
<!-- task list -->
7878
<div class="task-list">
7979
<h5 class="mt-3 mb-0">Tasks</h5>
@@ -112,7 +112,17 @@ <h5 class="mt-3 mb-0">Tasks</h5>
112112
</td>
113113
<td>{{ $task.Name }}</td>
114114
<td>{{ $task.Title }}</td>
115-
<td>{{ if $task.HasRunTime }}{{ $task.RunTime }}{{ else }}?{{ end }}{{ if $task.HasTimeout }} / {{ $task.Timeout }}{{ end }}</td>
115+
<td>
116+
{{ if $task.HasRunTime }}{{ $task.RunTime }}{{ else }}?{{ end }}
117+
{{ if $task.HasTimeout }} / {{ $task.Timeout }}{{ end }}
118+
{{ if $task.HasCustomRunTime}}
119+
<span data-bs-toggle="tooltip"
120+
data-bs-placement="top"
121+
data-bs-title="Custom timer via outputs.customRunTimeSeconds" >
122+
({{ $task.CustomRunTime}})
123+
</span>
124+
{{ end }}
125+
</td>
116126
<td>
117127
{{ if eq $task.Result "success" }}
118128
<span class="badge rounded-pill text-bg-success">
@@ -259,10 +269,13 @@ <h5 class="mt-3 mb-0">Tasks</h5>
259269
</div>
260270
</div>
261271
<div class="tab-pane fade card-body" id="task{{ $task.Index }}-config" role="tabpanel" aria-labelledby="task{{ $task.Index }}-config-tab">
262-
<pre>{{ $task.ConfigYaml }}</pre>
272+
<pre style="text-wrap: pretty">{{ $task.ConfigYaml }}</pre>
263273
</div>
264274
<div class="tab-pane fade card-body" id="task{{ $task.Index }}-result" role="tabpanel" aria-labelledby="task{{ $task.Index }}-result-tab">
265-
<pre>{{ $task.ResultYaml }}</pre>
275+
<pre style="text-wrap: pretty">{{ $task.ResultYaml }}</pre>
276+
</div>
277+
<div class="tab-pane fade card-body" id="task{{ $task.Index }}-custom-html" role="tabpanel" aria-labelledby="task{{ $task.Index }}-custom-html-tab">
278+
<pre style="text-wrap: pretty">{{ $task.ResultYaml }}</pre>
266279
</div>
267280
</div>
268281
</div>
@@ -359,4 +372,4 @@ <h5 class="mt-3 mb-0">Tasks</h5>
359372
}
360373

361374
</style>
362-
{{ end }}
375+
{{ end }}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
id: execution-spec-tests-execute
2+
name: "Run 'execute' on execution spec tests"
3+
timeout: 1h
4+
config:
5+
gitRepo: https://github.com/ethereum/execution-spec-tests.git
6+
gitBranch: main
7+
testPath: ""
8+
chainID: "0"
9+
rpcEndpoint: http://127.0.0.1:8545
10+
seedPrivateKey: ""
11+
seedAmount: "1" # (In Wei). Amount used to seed child accounts for test execution. Can also use "1 ether" or "10000 gwei" as input
12+
extraFlags: ""
13+
solcVersion: "0.8.24"
14+
tasks:
15+
- name: run_shell
16+
title: "Execute tests: ${gitRepo}@${gitBranch} [${testPath}]"
17+
id: execute
18+
config:
19+
shell: bash
20+
shellArgs: [--login]
21+
envVars:
22+
GIT_REPO: gitRepo
23+
GIT_BRANCH: gitBranch
24+
TEST_PATH: testPath
25+
CHAIN_ID: chainID
26+
RPC_ENDPOINT: rpcEndpoint
27+
PRIVATE_KEY: seedPrivateKey
28+
SEED_AMOUNT: seedAmount
29+
EXTRA_FLAGS: extraFlags
30+
SOLC_VERSION: "solcVersion"
31+
command: |
32+
set -e
33+
34+
# Convert env vars. They are passed as RAW JSON values
35+
36+
GIT_REPO=$(echo $GIT_REPO | jq -r)
37+
GIT_BRANCH=$(echo $GIT_BRANCH | jq -r)
38+
TEST_PATH=$(echo $TEST_PATH | jq -r)
39+
CHAIN_ID=$(echo $CHAIN_ID | jq -r)
40+
RPC_ENDPOINT=$(echo $RPC_ENDPOINT | jq -r)
41+
PRIVATE_KEY=$(echo $PRIVATE_KEY | jq -r)
42+
SEED_AMOUNT=$(echo $SEED_AMOUNT | jq -r)
43+
EXTRA_FLAGS=$(echo $EXTRA_FLAGS | jq -r)
44+
SOLC_VERSION=$(echo $SOLC_VERSION | jq -r)
45+
46+
echo "RPC_ENDPOINT: ${RPC_ENDPOINT}"
47+
echo "CHAIN_ID: ${CHAIN_ID}"
48+
49+
# Validate some inputs
50+
if [ -z "$TEST_PATH" ]; then
51+
echo
52+
exit "You need to provide a test path"
53+
fi
54+
if [ -z "$PRIVATE_KEY" ]; then
55+
echo
56+
exit "You need to provide a private key to fund the tests"
57+
fi
58+
59+
# Check if pip (python package manager) is installed
60+
if ! command -v pip &> /dev/null
61+
then
62+
echo "pip could not be found. Please install python3-pip"
63+
exit 1
64+
fi
65+
66+
# Create dir for temp files
67+
tmp_dir=$(mktemp -d -t execution-spec-tests-XXXXXXXXXX)
68+
cd $tmp_dir
69+
export HOME=$tmp_dir
70+
echo "============================"
71+
echo "Temp dir created: ${tmp_dir}"
72+
echo "============================"
73+
74+
function cleanup {
75+
rv=$?
76+
rm -rf "$tmp_dir"
77+
echo "tmpdir removed"
78+
exit $rv
79+
}
80+
81+
trap cleanup EXIT # always remove tempdir on exit
82+
83+
echo "============================"
84+
echo "Clone git repo ${GIT_REPO} @ ${GIT_BRANCH}"
85+
echo "============================"
86+
git clone ${GIT_REPO} --branch ${GIT_BRANCH} --single-branch
87+
cd execution-spec-tests
88+
89+
echo "============================"
90+
echo "Installing dependencies"
91+
echo "============================"
92+
pip install uv
93+
uv sync --all-extras
94+
uv run solc-select use "${SOLC_VERSION}" --always-install
95+
source .venv/bin/activate
96+
97+
echo "============================"
98+
echo "Running test: ${TEST_PATH}"
99+
echo "============================"
100+
uv run execute remote "${TEST_PATH}" \
101+
--rpc-chain-id=${CHAIN_ID} \
102+
--rpc-endpoint=${RPC_ENDPOINT} \
103+
--rpc-seed-key=${PRIVATE_KEY} \
104+
--seed-account-sweep-amount=${SEED_AMOUNT} \
105+
--json-report \
106+
--json-report-file=report.json \
107+
--html=report.html \
108+
${EXTRA_FLAGS[@]}
109+
110+
echo "============================"
111+
echo "Exporting reports"
112+
echo "============================"
113+
REPORT_JSON=$(cat report.json)
114+
REPORT_HTML=$(jq -Rs '.' report.html)
115+
echo "::set-output reportHTML ${REPORT_HTML}"
116+
echo "::set-output-json reportJSON ${REPORT_JSON}"
117+
118+
- name: run_task_matrix
119+
title: "Show test results"
120+
configVars:
121+
matrixValues: "tasks.execute.outputs.reportJSON.tests"
122+
config:
123+
runConcurrent: true
124+
matrixVar: "testResult"
125+
task:
126+
name: run_shell
127+
title: "${{testResult.nodeid}}"
128+
config:
129+
shell: bash
130+
envVars:
131+
TEST_RESULT: testResult
132+
command: |
133+
DURATION_SECONDS=$(echo $TEST_RESULT | jq -r '.setup.duration + .call.duration + .teardown.duration')
134+
echo "::set-output-json customRunTimeSeconds ${DURATION_SECONDS}"
135+
echo "::set-output-json execTestResult ${TEST_RESULT}"
136+
if $(echo $TEST_RESULT | jq -e '.outcome == "passed"') ; then
137+
echo "Test passed"
138+
else
139+
echo "Test failed"
140+
exit 1
141+
fi

0 commit comments

Comments
 (0)