Skip to content

Commit

Permalink
Merge pull request #1315 from GRIDAPPSD/releases/2020.07.0
Browse files Browse the repository at this point in the history
Release of version 2020.07.0
  • Loading branch information
poorva1209 authored Jul 16, 2020
2 parents 3433baf + 94eca31 commit bc8236d
Show file tree
Hide file tree
Showing 23 changed files with 2,268 additions and 915 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void store (String source, String processId, long timestamp,

Serializable query(String queryString);

void storeExpectedResults(String test_id, String processId, long simulation_time, String mrid, String property,
String expected, String actual);
void storeExpectedResults(String app_id, String test_id, String processIdOne, String processIdTwo, long simulation_time, long simulation_time_two, String mrid, String property,
String expected, String actual, String difference_direction, String difference_mrid, Boolean match);

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import gov.pnnl.goss.gridappsd.dto.SimulationContext;
import gov.pnnl.goss.gridappsd.dto.TestConfig;
import gov.pnnl.goss.gridappsd.dto.events.Event;
import pnnl.goss.core.DataResponse;

import java.util.List;

Expand Down Expand Up @@ -84,15 +85,39 @@ public interface TestManager {
* @param simulationIdOne simulation id of currently running simulation
* @param simulationIdTwo Simulation id of older simulation
*/
public void compareSimulations(String simulationIdOne, String simulationIdTwo);
public void compareSimulations(TestConfig testConfig, String simulationIdOne, String simulationIdTwo, DataResponse request);

/**
* @param testConfig
* @param currentSimulationId
* @param simulationIdOne
* @param expectedResultObject
* @param request
*/
public void compareTimeseriesSimulationWithExpected(TestConfig testConfig, String currentSimulationId, String simulationIdOne, JsonObject expectedResultObject, DataResponse request);

/**
* @param testConfig
* @param currentSimulationId
* @param simulationIdOne
*/
public void compareRunningWithTimeseriesSimulation(TestConfig testConfig, String currentSimulationId, String simulationIdOne);

/**
* This method compares simulation output with provided expected simulation
* output.
* @param simulationId Id of the currently running simulation
* @param expectedResults Expected simulation output
*/
public void compareRunningSimulationOutputWithExpected(TestConfig testConfig, String simulationId, JsonObject expectedResults, String expectedOrSimulationIdTwo);

/**
* This method compares simulation output with provided expected simulation
* output.
* @param simulationId Id of the surrently running simulation
* @param simulationId Id of the currently running simulation
* @param expectedResults Expected simulation output
*/
public void compareWithExpectedSimOutput(String simulationId, JsonObject expectedResults);
public void compareRunningSimulationInputWithExpected(TestConfig testConfig, String simulationId, JsonObject expectedResults, String expectedOrSimulationIdTwo);

/**
* This method update property of existing events for the simulation if the events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,29 @@ public void store(String source, String processId, long timestamp,
}

@Override
public void storeExpectedResults(String test_id, String processId, long simulation_time,
String mrid, String property, String expected, String actual) {

if(connection!=null){
try {

PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO gridappsd.expected_results VALUES (default, ?, ?, ?, ?, ?, ?,?)");
preparedStatement.setString(1, test_id);
preparedStatement.setString(2, processId);
preparedStatement.setString(3, mrid);
preparedStatement.setString(4, property);
preparedStatement.setString(5, expected);
preparedStatement.setString(6, actual);
preparedStatement.setTimestamp(7, new Timestamp(simulation_time));
public void storeExpectedResults(String app_id, String test_id, String processIdOne, String processIdTwo, long simulation_time_one, long simulation_time_two,
String mrid, String property, String expected, String actual, String difference_direction, String difference_mrid, Boolean match) {

if(connection!=null){
try {

PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO gridappsd.expected_results VALUES (default, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
preparedStatement.setString(1, app_id);
preparedStatement.setString(2, test_id);
preparedStatement.setString(3, processIdOne);
preparedStatement.setString(4, processIdTwo);
preparedStatement.setLong(5, simulation_time_one);
preparedStatement.setLong(6, simulation_time_two);
preparedStatement.setString(7, mrid);
preparedStatement.setString(8, property);
preparedStatement.setString(9, expected);
preparedStatement.setString(10, actual);
preparedStatement.setString(11, difference_direction);
preparedStatement.setString(12, difference_mrid);
preparedStatement.setBoolean(13, match);
preparedStatement.setTimestamp(14, new Timestamp(simulation_time_one* 1000));

preparedStatement.executeUpdate();
preparedStatement.executeUpdate();

} catch (DataTruncation e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public enum LogLevel {
TRACE, DEBUG, INFO, WARN, ERROR, FATAL
}
public enum ProcessStatus {
STARTING, STARTED, RUNNING, ERROR, CLOSED, COMPLETE, STOPPED
STARTING, STARTED, RUNNING, ERROR, CLOSED, COMPLETE, STOPPED, PAUSED
}

String source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,43 @@

import java.io.Serializable;
import java.util.List;

//import java.util.UUID;
import java.util.Random;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

public class TestConfig implements Serializable {

private static final long serialVersionUID = 1L;

private Random randomNum = new Random();

public enum TestType {
simulation_vs_expected, simulation_vs_timeseries, expected_vs_timeseries, timeseries_vs_timeseries
}

private List<Event> events;

private List<RuleSettings> rules;

private JsonObject expectedResults;

private Boolean testInput = true;

private Boolean testOutput = true;

private String compareWithSimId;

private String compareWithSimIdTwo;

private String appId;

private String testId = ""+Math.abs(randomNum.nextInt());

private TestType testType = TestType.simulation_vs_expected;

private Boolean storeMatches = false;

public JsonObject getExpectedResultObject() {
return expectedResults;
}
Expand All @@ -85,6 +104,22 @@ public void setRules(List<RuleSettings> rules) {
this.rules = rules;
}

public Boolean getTestInput() {
return testInput;
}

public void setTestInput(Boolean testInput) {
this.testInput = testInput;
}

public Boolean getTestOutput() {
return testOutput;
}

public void setTestOutput(Boolean testOutput) {
this.testOutput = testOutput;
}

public String getCompareWithSimId() {
return compareWithSimId;
}
Expand All @@ -93,13 +128,46 @@ public void setCompareWithSimId(String compareWithSimId) {
this.compareWithSimId = compareWithSimId;
}

public String getCompareWithSimIdTwo() {
return compareWithSimIdTwo;
}

public void setCompareWithSimIdTwo(String compareWithSimIdTwo) {
this.compareWithSimIdTwo = compareWithSimIdTwo;
}

public String getAppId() {
return appId;
}

public void setAppId(String appId) {
this.appId = appId;
}


public String getTestId() {
return testId;
}

public void setTestId(String testId) {
this.testId = testId;
}

public TestType getTestType() {
return testType;
}

public void setTestType(TestType testType) {
this.testType = testType;
}

public Boolean getStoreMatches() {
return storeMatches;
}

public void setStoreMatches(Boolean storeMatches) {
this.storeMatches = storeMatches;
}

@Override
public String toString() {
Expand All @@ -110,8 +178,8 @@ public String toString() {
public static TestConfig parse(String jsonString){
Gson gson = new Gson();
TestConfig obj = gson.fromJson(jsonString, TestConfig.class);
if(obj.events==null || obj.events.size()==0)
throw new RuntimeException("Expected attribute events not found or is empty");
// if(obj.events==null || obj.events.size()==0 || obj.compareWithSimId ==null)
// throw new RuntimeException("Expected attribute events not found or is empty");
if(obj.appId==null)
throw new RuntimeException("Expected attribute appId not found");
return obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String toString() {
public static Event parse(String jsonString){
GsonBuilder gsonBuilder = new GsonBuilder();
RuntimeTypeAdapterFactory<Event> commandAdapterFactory = RuntimeTypeAdapterFactory.of(Event.class, "event_type")
.registerSubtype(CommOutage.class,"CommOutage").registerSubtype(Fault.class, "Fault");
.registerSubtype(CommOutage.class,"CommOutage").registerSubtype(Fault.class, "Fault").registerSubtype(ScheduledCommandEvent.class, "ScheduledCommandEvent");
gsonBuilder.registerTypeAdapterFactory(commandAdapterFactory);
gsonBuilder.setPrettyPrinting();
Gson gson = gsonBuilder.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
import gov.pnnl.goss.gridappsd.dto.LogMessage;
import gov.pnnl.goss.gridappsd.dto.LogMessage.LogLevel;
import gov.pnnl.goss.gridappsd.dto.LogMessage.ProcessStatus;
import gov.pnnl.goss.gridappsd.dto.events.CommOutage;
import gov.pnnl.goss.gridappsd.dto.events.Event;
import gov.pnnl.goss.gridappsd.dto.events.Fault;
import gov.pnnl.goss.gridappsd.dto.events.ScheduledCommandEvent;
import gov.pnnl.goss.gridappsd.dto.RuntimeTypeAdapterFactory;
import gov.pnnl.goss.gridappsd.dto.PlatformStatus;
import gov.pnnl.goss.gridappsd.dto.RequestPlatformStatus;
import gov.pnnl.goss.gridappsd.dto.RequestSimulation;
Expand All @@ -75,6 +80,8 @@
import pnnl.goss.core.Response;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import com.google.gson.JsonSyntaxException;

/**
Expand Down Expand Up @@ -121,6 +128,7 @@ public ProcessEvent(ProcessManagerImpl processManager,
this.dataManager = dataManager;
this.testManager = testManager;
this.roleManager = roleManager;

}


Expand All @@ -135,6 +143,13 @@ public void onMessage(Serializable message) {


try{
GsonBuilder gsonBuilder = new GsonBuilder();
RuntimeTypeAdapterFactory<Event> commandAdapterFactory = RuntimeTypeAdapterFactory.of(Event.class, "event_type")
.registerSubtype(CommOutage.class,"CommOutage").registerSubtype(Fault.class, "Fault").registerSubtype(ScheduledCommandEvent.class, "ScheduledCommandEvent");
gsonBuilder.registerTypeAdapterFactory(commandAdapterFactory);
gsonBuilder.setPrettyPrinting();
Gson gsonSpecial = gsonBuilder.create();
// simRequest = gson.fromJson(request.toString(), RequestSimulation.class);

if(event.getDestination().contains(GridAppsDConstants.topic_requestSimulation )){
//Parse simluation request
Expand All @@ -152,7 +167,8 @@ public void onMessage(Serializable message) {
if(request!=null){
//make sure it doesn't fail if request is null, although it should never be null
try{
simRequest = RequestSimulation.parse(request.toString());
// simRequest = RequestSimulation.parse(request.toString());
simRequest = gsonSpecial.fromJson(request.toString(), RequestSimulation.class);
}catch(JsonSyntaxException e){
e.printStackTrace();
//TODO log error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ public void process(ConfigurationManager configurationManager,
simContext.serviceInstanceIds = connectServiceInstanceIds;
simContext.appInstanceIds = connectedAppInstanceIds;

dataManager.processDataRequest(simContext, "timeseries", simulationId, null, username);
dataManager.processDataRequest(simContext, "timeseries", simulationId, null, username);

// start test if requested
testManager.handleTestRequest(simRequest.getTest_config(), simContext);

// start simulation
logManager.log(new LogMessage(source, simId,new Date().getTime(),
Expand Down
Loading

0 comments on commit bc8236d

Please sign in to comment.