Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Nov 14, 2024
1 parent cd318f2 commit f77e051
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Feature: Benders Criterion files
Scenario: xpansion-test-01
Given the study path is "data_test/examples/xpansion-test-01"
When I run antares-xpansion with the benders method and 1 proc(s)
Then the simulation takes less than 300 seconds
And the simulation succeeds
Then the simulation succeeds
And the simulation takes less than 300 seconds
And the expected positive unsupplied energy is
| Outer loop | Ite | area1 | area2 | flex | peak | pv | semibase | store_in | store_out |
| 0 | 1 | 5.3771400000e+05 | 4.3137090000e+06 | 0.0000000000e+00 | 0.0000000000e+00 | 0.0000000000e+00 | 0.0000000000e+00 | 2.6208000000e+07 | 0.0000000000e+00 |
Expand Down
4 changes: 2 additions & 2 deletions tests/end_to_end/cucumber/features/outer_loop_tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Feature: outer loop tests
Scenario: a system with 4 nodes, on 1 timestep, 2 scenarios
Given the study path is "data_test/external_loop_test"
When I run outer loop with 1 proc(s)
Then the simulation takes less than 5 seconds
And the simulation succeeds
Then the simulation succeeds
And the simulation takes less than 5 seconds
And the expected overall cost is 92.70005
And the solution is
| variable | value |
Expand Down
17 changes: 9 additions & 8 deletions tests/end_to_end/cucumber/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import subprocess
import sys
from pathlib import Path

import numpy as np
from behave import *

from utils_functions import get_mpi_command, get_conf, read_outputs, remove_outputs


Expand Down Expand Up @@ -83,19 +83,20 @@ def run_antares_xpansion(context, method, memory=None, n: int = 1):
context.return_code = run_command(context.tmp_study, memory=memory, method=method, n_mpi=n,
allow_run_as_root=get_conf("allow_run_as_root"))

output_path = context.tmp_study / "output"
outputs = read_outputs(output_path, use_archive=not memory, lold=True, positive_unsupplied_energy=True)
context.outputs = outputs.out_json
context.options_data = outputs.options_json
context.lold = outputs.lold
context.positive_unsupplied_energy = outputs.positive_unsupplied_energy
if context.return_code == 0:
output_path = context.tmp_study / "output"
outputs = read_outputs(output_path, use_archive=not memory, lold=True, positive_unsupplied_energy=True)
context.outputs = outputs.out_json
context.options_data = outputs.options_json
context.lold = outputs.lold
context.positive_unsupplied_energy = outputs.positive_unsupplied_energy


def run_command(study_path, memory, method, n_mpi, allow_run_as_root=False):
command = build_launch_command(study_path, method, nproc=n_mpi, in_memory=memory,
allow_run_as_root=allow_run_as_root)
print(f"Running command: {command}")
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
if process.returncode != 0:
print("*********************** Begin stdout ***********************")
Expand Down
1 change: 1 addition & 0 deletions tests/end_to_end/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def remove_outputs(study_path):
def get_filepath(output_dir, folder, filename):
op = []
print(f"output_dir: {output_dir}")
assert Path(output_dir).exists()
print(f"folder: {folder}")
print(f"filename: {filename}")
for path in Path(output_dir).iterdir():
Expand Down

0 comments on commit f77e051

Please sign in to comment.