Skip to content

Commit

Permalink
Merge branch 'dev' into jb/#671-externaldataservice
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-bao authored Feb 23, 2024
2 parents 94aba27 + c72487c commit 93b9327
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added capability of SystemParticipants to handle flexibility [#308](https://github.com/ie3-institute/simona/issues/308)
- Added smart charging logic [#31](https://github.com/ie3-institute/simona/issues/31) and flex calculation in `EvcsAgent` [#332](https://github.com/ie3-institute/simona/issues/332)
- Enhance output quotes of `RunSimona` [#743](https://github.com/ie3-institute/simona/issues/743)
- Printing logs of failed tests [#747](https://github.com/ie3-institute/simona/issues/747)

### Changed
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
Expand Down
36 changes: 28 additions & 8 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2019. TU Dortmund University,
~ Copyright (c) 2024. TU Dortmund University,
~ Institute of Energy Systems, Energy Efficiency and Energy Economics,
~ Research group Distribution grid planning and operation
-->
<configuration>
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%highlight%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>OFF</level>
</filter>
</appender>

<appender name="RF" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>test/logs/simona/simona_tests.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>test/logs/simona/archive/simona_tests-%d{yyyyMMdd'T'HHmmss}-${bySecond}.log</fileNamePattern>
<!-- keep 30 days' worth of history capped at 3GB total size -->
<fileNamePattern>test/logs/simona/archive/simona_tests-%d{yyyyMMdd'T'HHmmss}.log</fileNamePattern>
<!-- keep 10 days worth of history capped at 3GB total size -->
<maxHistory>10</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
Expand All @@ -32,8 +30,30 @@
<level>DEBUG</level>
</filter>
</appender>
<root level="debug">

<!--
Logging from tests are silenced by this appender. When there is a test failure
the captured logging events are flushed to the appenders defined for the
org.apache.pekko.actor.testkit.typed.internal.CapturingAppenderDelegate logger.
-->
<appender name="CapturingAppender" class="org.apache.pekko.actor.testkit.typed.internal.CapturingAppender" />

<!--
The appenders defined for this CapturingAppenderDelegate logger are used
when there is a test failure and all logging events from the test are
flushed to these appenders. The test spec must extend
org.apache.pekko.actor.testkit.typed.scaladsl.LogCapturing.
-->
<logger name="org.apache.pekko.actor.testkit.typed.internal.CapturingAppenderDelegate" >
<appender-ref ref="STDOUT"/>
</logger>

<root level="debug">
<!--
No direct reference to STDOUT here, since we only want logs in console on failure
-->
<appender-ref ref="CapturingAppender"/>
<appender-ref ref="RF"/>
</root>

</configuration>
3 changes: 1 addition & 2 deletions src/test/scala/edu/ie3/simona/agent/ValueStoreSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
package edu.ie3.simona.agent

import edu.ie3.simona.test.common.UnitSpec
import org.scalatest.PrivateMethodTester

import scala.collection.SortedMap

class ValueStoreSpec extends UnitSpec with PrivateMethodTester {
class ValueStoreSpec extends UnitSpec {
"An empty value store" should {
val emptyValueStore: ValueStore[String] = ValueStore[String](Long.MaxValue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import scala.language.postfixOps

class RuntimeEventListenerKafkaSpec
extends ScalaTestWithActorTestKit
with KafkaSpecLike
with UnitSpec
with KafkaSpecLike
with GivenWhenThen
with TableDrivenPropertyChecks {
private var testConsumer: KafkaConsumer[Bytes, SimonaEndMessage] = _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import edu.ie3.simona.event.RuntimeEvent.{
Ready,
Simulating,
}
import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.simona.util.TickUtil._
import edu.ie3.util.TimeUtil
import org.scalatest.PrivateMethodTester
import org.scalatest.matchers.should
import org.scalatest.wordspec.AnyWordSpecLike
import org.slf4j.event.Level

import java.util.concurrent.{LinkedBlockingQueue, TimeUnit}
Expand All @@ -42,9 +40,7 @@ class RuntimeEventListenerSpec
ConfigValueFactory.fromAnyRef("30s"),
)
)
with AnyWordSpecLike
with should.Matchers
with PrivateMethodTester {
with UnitSpec {

// global variables
val startDateTimeString = "2011-01-01 00:00:00"
Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/edu/ie3/simona/test/common/UnitSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

package edu.ie3.simona.test.common

import java.util.Locale
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.simona.test.matchers.{QuantityMatchers, SquantsMatchers}
import edu.ie3.util.scala.quantities.{QuantityUtil => PSQuantityUtil}
import org.apache.pekko.actor.testkit.typed.scaladsl.LogCapturing
import org.scalatest._
import org.scalatest.matchers.should
import org.scalatest.prop.TableDrivenPropertyChecks
import org.scalatest.wordspec.AnyWordSpecLike

import java.util.Locale

/** Base class to be used with all scala unit tests. All data that should be
* commonly available to all unit tests should be placed here instead of mixing
* a lot of traits together. See
Expand All @@ -28,6 +30,7 @@ trait UnitSpec
with QuantityMatchers
with SquantsMatchers
with AnyWordSpecLike
with LogCapturing
with OptionValues
with Inside
with Inspectors
Expand Down

0 comments on commit 93b9327

Please sign in to comment.