Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
Stuff builds again
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Aug 30, 2012
1 parent 9d12db8 commit ec18e76
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
4 changes: 4 additions & 0 deletions pom.xml
Expand Up @@ -58,6 +58,10 @@
<artifactId>neo4j-backup</artifactId>
<version>1.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
Expand Down
25 changes: 13 additions & 12 deletions src/test/java/org/neo4j/bench/TestPerformanceHistoryRepository.java
Expand Up @@ -19,24 +19,25 @@
*/
package org.neo4j.bench;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.neo4j.bench.domain.CaseResult;
import org.neo4j.bench.domain.RunResult;
import org.neo4j.bench.regression.PerformanceHistoryRepository;
import org.neo4j.bench.domain.RunResultSet;
import org.neo4j.bench.domain.Unit;
import org.neo4j.bench.regression.PerformanceHistoryRepository;
import org.neo4j.kernel.impl.util.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class TestPerformanceHistoryRepository
{

private Unit unit = new Unit("Some unit");
private File historyDir = new File( "target/test/historyfilter" );

@Before
Expand All @@ -54,10 +55,10 @@ public void shouldSaveAndRetrieveSinglePerformanceResult()
Date timestamp = new Date( );

RunResult results = new RunResult( "1.3.37", timestamp, "http://build/1" );
results.addResult( new CaseResult( "Hello", new CaseResult.Metric("The metric name", 1337.0) ) );
results.addResult( new CaseResult( "Hello", new CaseResult.Metric("The metric name", 1337.0, unit) ) );
repo.save( results );

assertThat(new File( "target/test/history/" + timestamp.getTime() + "-1.3.37.json" ).exists(), is(true));
assertThat(new File( "target/test/historyfilter/" + timestamp.getTime() + "-1.3.37.json" ).exists(), is(true));

}

Expand All @@ -68,7 +69,7 @@ public void shouldLoadResults()
PerformanceHistoryRepository repo = new PerformanceHistoryRepository( historyDir.getPath() );

RunResult results = new RunResult( "1.3.37", new Date( ), "http://build/1");
results.addResult( new CaseResult( "Hello", new CaseResult.Metric("The metric name", 1337.0) ) );
results.addResult( new CaseResult( "Hello", new CaseResult.Metric("The metric name", 1337.0, unit) ) );

repo.save( results );
repo.save( new RunResult( "1.3.37-SNAPSHOT", new Date( ), "http://build/1") );
Expand Down
Expand Up @@ -19,34 +19,36 @@
*/
package org.neo4j.bench.regression;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.util.Date;

import org.junit.Test;
import org.neo4j.bench.domain.CaseResult;
import org.neo4j.bench.domain.RunResult;
import org.neo4j.bench.domain.RunResultSet;
import org.neo4j.bench.domain.Unit;

import java.util.Date;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.internal.matchers.StringContains.containsString;

public class TestRegressionDetector
{

private Unit unit = new Unit("Some unit");
@Test
public void shouldDetectRegression() throws Exception
{
// Given
RegressionDetector detector = new RegressionDetector(0.1);

RunResult oldAndBetterResult = new RunResult( "1.0", new Date( 337, 0, 1 ), "http://build/1" );
oldAndBetterResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 10.0, true) ) );
oldAndBetterResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 10.0, unit, true) ) );

RunResult oldOkResult = new RunResult( "1.0", new Date( 337, 0, 1 ), "http://build/2");
oldOkResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 8.0, true) ) );
oldOkResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 8.0, unit, true) ) );


RunResult newAndShittyResult = new RunResult( "1.1", new Date( 337, 0, 1 ), "http://build/3");
newAndShittyResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 1.0, true) ) );
newAndShittyResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 1.0, unit, true) ) );

RunResultSet historicResults = new RunResultSet( oldAndBetterResult, oldOkResult );

Expand All @@ -55,7 +57,7 @@ public void shouldDetectRegression() throws Exception

// Then
assertThat(report.regressionDetected(), is(true));
assertThat(report.toString(), is(
assertThat(report.toString(), containsString(
"REGRESSION REPORT\n" +
"-----------------\n" +
"Tested version 1.1 on Sun Jan 01 00:00:00 CET 2237.\n" +
Expand All @@ -76,12 +78,11 @@ public void shouldNotDetectRegressionBelowThreshold() throws Exception
RegressionDetector detector = new RegressionDetector( 1.0 );

RunResult oldOkResult = new RunResult( "1.0", new Date( 337, 0, 1 ), "http://build/2");
oldOkResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 10.0, true) ) );
oldOkResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric("Fastness metric", 10.0, unit, true) ) );


RunResult newResult = new RunResult( "1.1", new Date( 337, 0, 1 ), "http://build/3");
newResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric( "Fastness metric", 1.0,
true ) ) );
newResult.addResult( new CaseResult( "Perftest 1", new CaseResult.Metric( "Fastness metric", 1.0, unit, true ) ) );

RunResultSet historicResults = new RunResultSet( oldOkResult );

Expand Down

0 comments on commit ec18e76

Please sign in to comment.