Skip to content

Commit 8cd049f

Browse files
committed
Trying variant for SCI test
1 parent 9df4376 commit 8cd049f

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Test Stress
3+
author: Dan Mateas
4+
description: test
5+
6+
sci:
7+
R_d: Cool run
8+
9+
services:
10+
test-container:
11+
type: container
12+
image: gcb_stress
13+
build:
14+
context: ../stress-application
15+
16+
flow:
17+
- name: Stress
18+
container: test-container
19+
commands:
20+
- type: console
21+
shell: sh
22+
command: stress-ng -c 1 -t 1 -q; echo GMT_SCI_R=100
23+
log-stdout: True
24+
read-sci-stdout: True

tests/lib/test_phase_stats.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import os
2+
import io
23

34
GMT_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))+'/../../'
45

56
import pytest
7+
from contextlib import redirect_stdout, redirect_stderr
68

79
from tests import test_functions as Tests
810
from lib.db import DB
911
from lib.phase_stats import build_and_store_phase_stats
12+
from runner import Runner
1013

1114
MICROJOULES_TO_KWH = 1/(3_600*1_000_000_000)
1215

@@ -275,3 +278,19 @@ def test_phase_stats_single_network_procfs():
275278
assert data[5]['sampling_rate_max'] == 105930, 'MAX sampling rate not in expected range'
276279
assert data[5]['sampling_rate_95p'] == 100477, '95p sampling rate not in expected range'
277280
assert isinstance(data[5]['sampling_rate_95p'], int)
281+
282+
283+
def test_sci():
284+
runner = Runner(uri=GMT_ROOT_DIR, uri_type='folder', filename='tests/data/usage_scenarios/stress_sci.yml', skip_system_checks=True, dev_cache_build=True, dev_no_sleeps=True, dev_no_metrics=False, dev_no_phase_stats=False)
285+
286+
out = io.StringIO()
287+
err = io.StringIO()
288+
with redirect_stdout(out), redirect_stderr(err):
289+
run_id = runner.run()
290+
291+
data = DB().fetch_all("SELECT value, unit FROM phase_stats WHERE phase = %s AND run_id = %s AND metric = 'software_carbon_intensity_global' ", params=('004_[RUNTIME]', run_id), fetch_mode='dict')
292+
293+
294+
assert len(data) == 1
295+
assert 50 < data[0]['value'] < 70
296+
assert data[0]['unit'] == 'ugCO2e/Cool run'

0 commit comments

Comments
 (0)