Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Run All Pytests

on:
push:
pull_request:
schedule:
- cron: '0 10 * * 1'

jobs:
build:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
python-version: [3.7.10]

steps:
- name: Set static enviornment values
run: |
echo "RESULTS=gridappsd-testing_$(date +\"%Y%m%d_%H%M%S\")_${GITHUB_REF##*/}.html" >> $GITHUB_ENV
echo "BRANCH_RESULTS=gridappsd-testing_${GITHUB_REF##*/}.html" >> $GITHUB_ENV

- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Integration Tests
env:
GRIDAPPSD_USER: ${{ secrets.GRIDAPPSD_USER }}
GRIDAPPSD_PASSWORD: ${{ secrets.GRIDAPPSD_PASSWORD }}
run: |
mkdir out
pytest -rA --html=out/${{ env.RESULTS }} --self-contained-html --timeout=2700

- name: Archive test results
if: ${{ always() }}
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_region: 'us-west-2'
source: "out/${{ env.RESULTS }}"
dest: "s3://gridappsd-builds/GRIDAPPSD/gridappsd-testing/${{ env.RESULTS }}"

- name: Archive branch test results
if: ${{ always() }}
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_region: 'us-west-2'
source: "out/${{ env.RESULTS }}"
dest: "s3://gridappsd-builds/GRIDAPPSD/gridappsd-testing/${{ env.BRANCH_RESULTS }}"

- name: Test Reports
if: ${{ always() }}
run: |
echo "https://s3-us-west-2.amazonaws.com/gridappsd-builds/GRIDAPPSD/gridappsd-testing/${{ env.RESULTS }}"
echo "https://s3-us-west-2.amazonaws.com/gridappsd-builds/GRIDAPPSD/gridappsd-testing/${{ env.BRANCH_RESULTS }}"
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Python script to start the gridappsd platform for automated testing

*** This will stop all your running containers ***

*** Requires python 3.6 ***
*** Requires python 3.7 ***

# setup python environment
sudo apt install python3.6 python3.6-venv
python3.6 -m venv env
sudo apt install python3.7 python3.7-venv
python3.7 -m venv env
source env/bin/activate
pip3 install -r requirements.txt

Expand Down
81 changes: 51 additions & 30 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,79 @@
from pathlib import Path
from py.xml import html

import logging
import os
import sys

import pytest
from gridappsd import GOSS, GridAPPSD
from gridappsd.docker_handler import (run_dependency_containers, run_gridappsd_container, Containers,
run_containers, DEFAULT_GRIDAPPSD_DOCKER_CONFIG)

# Assumes tests directory is within the directory that should be mounted to the
# gridappsd container
LOCAL_MOUNT_POINT_FOR_SERVICE = Path(__file__).parent.parent.absolute()
from gridappsd import GridAPPSD, GOSS
from gridappsd.docker_handler import run_dependency_containers, run_gridappsd_container, Containers

levels = dict(
CRITICAL=50,
FATAL=50,
ERROR=40,
WARNING=30,
WARN=30,
INFO=20,
DEBUG=10,
NOTSET=0
)

# Get string representation of the log level passed
LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO")

# Make sure the level passed is one of the valid levels.
if LOG_LEVEL not in levels.keys():
raise AttributeError("Invalid LOG_LEVEL environmental variable set.")

# Mount point inside the gridappsd container itself.
SERVICE_MOUNT_POINT = "/gridappsd/services/gridappsd-sensor-simulator"
CONFIG_MOUNT_POINT = "/gridappsd/services/sensor_simulator.config"
# Set the numeric version of log level to pass to the basicConfig function
LOG_LEVEL = levels[LOG_LEVEL]

# If set to False then None of the containers will clean up after themselves.
# If more than one test is ran then this will cause an error because the gridappsd
# container will not be cleansed.
STOP_AFTER_FIXTURE = True
logging.basicConfig(stream=sys.stdout, level=LOG_LEVEL,
format="%(asctime)s|%(levelname)s|%(name)s|%(message)s")
logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO)
logging.getLogger("docker.utils.config").setLevel(logging.INFO)
logging.getLogger("docker.auth").setLevel(logging.INFO)


STOP_CONTAINER_AFTER_TEST = os.environ.get('GRIDAPPSD_STOP_CONTAINERS_AFTER_TESTS', True)


@pytest.fixture(scope="module")
def docker_dependencies():
print("Docker dependencies")
Containers.reset_all_containers()
# Containers.reset_all_containers()

with run_dependency_containers(stop_after=STOP_AFTER_FIXTURE) as dep:
with run_dependency_containers(stop_after=STOP_CONTAINER_AFTER_TEST) as dep:
yield dep
print("Cleanup docker dependencies")

@pytest.fixture
def gridappsd_client(request, docker_dependencies):
#with run_gridappsd_container(stop_after=STOP_CONTAINER_AFTER_TEST):
with run_gridappsd_container(stop_after=False):
gappsd = GridAPPSD()
gappsd.connect()
assert gappsd.connected
models = gappsd.query_model_names()
assert models is not None
if request.cls is not None:
request.cls.gridappsd_client = gappsd
yield gappsd

gappsd.disconnect()

@pytest.fixture
def goss_client(docker_dependencies):
with run_gridappsd_container(STOP_AFTER_FIXTURE):
with run_gridappsd_container(stop_after=STOP_CONTAINER_AFTER_TEST):
goss = GOSS()
goss.connect()
assert goss.connected

yield goss

goss.disconnect()


@pytest.fixture
def gridappsd_client(docker_dependencies):
with run_gridappsd_container(True):
gappsd = GridAPPSD()
gappsd.connect()
assert gappsd.connected

yield gappsd

gappsd.disconnect()

@pytest.fixture(scope="module")
def gridappsd_client_module(docker_dependencies):
with run_gridappsd_container(True):
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# enter requirements that aren't related to connecting to the messagebus here
git+https://github.com/GRIDAPPSD/gridappsd-python.git@develop#egg=gridappsd
stomp.py==6.0.0
gridappsd-python
pytest
docker
mock
pytest-html
pytest-timeout
dictdiffer
deepdiff
38 changes: 33 additions & 5 deletions simulation_baseline_files/power_api_model_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"feeder_name": {
"type": "literal",
"value": "ieee123"
"value": "ieee123pv"
},
"region_name": {
"type": "literal",
Expand All @@ -54,7 +54,7 @@
{
"feeder_name": {
"type": "literal",
"value": "ieee123pv"
"value": "ieee123"
},
"region_name": {
"type": "literal",
Expand All @@ -65,6 +65,20 @@
"value": "Medium"
}
},
{
"feeder_name": {
"type": "literal",
"value": "ieee13nodecktassets"
},
"region_name": {
"type": "literal",
"value": "IEEE"
},
"subregion_name": {
"type": "literal",
"value": "Small"
}
},
{
"feeder_name": {
"type": "literal",
Expand All @@ -82,7 +96,7 @@
{
"feeder_name": {
"type": "literal",
"value": "ieee13nodecktassets"
"value": "ieee13ochre"
},
"region_name": {
"type": "literal",
Expand All @@ -93,6 +107,20 @@
"value": "Small"
}
},
{
"feeder_name": {
"type": "literal",
"value": "test9500new"
},
"region_name": {
"type": "literal",
"value": "IEEE"
},
"subregion_name": {
"type": "literal",
"value": "Large"
}
},
{
"feeder_name": {
"type": "literal",
Expand All @@ -110,7 +138,7 @@
{
"feeder_name": {
"type": "literal",
"value": "test9500new"
"value": "final9500node"
},
"region_name": {
"type": "literal",
Expand Down Expand Up @@ -152,6 +180,6 @@
]
}
},
"id": "2126488164",
"id": "504795932",
"responseComplete": true
}
22 changes: 21 additions & 1 deletion simulation_baseline_files/power_api_model_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"subRegionId": "_2F8FC9BF-FF32-A197-D541-0A2529D04DF7",
"subRegionName": "Fairbanks"
},
{
"modelId": "_EE71F6C9-56F0-4167-A14E-7F4C71F10EAA",
"modelName": "final9500node",
"regionId": "_73C512BD-7249-4F50-50DA-D93849B89C43",
"regionName": "IEEE",
"stationId": "_4AE25EA5-C364-43BB-BD7D-C8E870EE8F5D",
"stationName": "ThreeSubs",
"subRegionId": "_A1170111-942A-6ABD-D325-C64886DC4D7D",
"subRegionName": "Large"
},
{
"modelId": "_C1C3E687-6FFD-C753-582B-632A27E28507",
"modelName": "ieee123",
Expand Down Expand Up @@ -61,6 +71,16 @@
"subRegionId": "_ABEB635F-729D-24BF-B8A4-E2EF268D8B9E",
"subRegionName": "Small"
},
{
"modelId": "_13AD8E07-3BF9-A4E2-CB8F-C3722F837B62",
"modelName": "ieee13ochre",
"regionId": "_73C512BD-7249-4F50-50DA-D93849B89C43",
"regionName": "IEEE",
"stationId": "_6C62C905-6FC7-653D-9F1E-1340F974A587",
"stationName": "IEEE13",
"subRegionId": "_ABEB635F-729D-24BF-B8A4-E2EF268D8B9E",
"subRegionName": "Small"
},
{
"modelId": "_4F76A5F9-271D-9EB8-5E31-AA362D86F2C3",
"modelName": "ieee8500",
Expand Down Expand Up @@ -103,6 +123,6 @@
}
]
},
"id": "1042047246",
"id": "1536028212",
"responseComplete": true
}
6 changes: 4 additions & 2 deletions simulation_baseline_files/power_api_models.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"data": {
"modelNames": [
"_13AD8E07-3BF9-A4E2-CB8F-C3722F837B62",
"_49AD8E07-3BF9-A4E2-CB8F-C3722F837B62",
"_4F76A5F9-271D-9EB8-5E31-AA362D86F2C3",
"_503D6E20-F499-4CC7-8051-971E23D0BF79",
Expand All @@ -10,9 +11,10 @@
"_9CE150A8-8CC5-A0F9-B67E-BBD8C79D3095",
"_AAE94E4A-2465-6F5E-37B1-3E72183A4E44",
"_C1C3E687-6FFD-C753-582B-632A27E28507",
"_E407CBB6-8C8D-9BC9-589C-AB83FBF0826D"
"_E407CBB6-8C8D-9BC9-589C-AB83FBF0826D",
"_EE71F6C9-56F0-4167-A14E-7F4C71F10EAA"
]
},
"id": "660230763",
"id": "732254521",
"responseComplete": true
}
Loading