Permalink
Browse files

Removed Betamax

  • Loading branch information...
hpled committed Dec 6, 2018
1 parent 6f0e862 commit 23e250e03db458e90e81b89fac70e4d68f6cd0cd
3 NOTICE
@@ -27,9 +27,6 @@ This project includes:
Application Info Plugin created by Burt Beckwith, Apache License 2.0,
available at http://grails.org/plugin/app-info

betamax created by Rob Fletcher, Apache License 2.0,
available at http://freeside.co/betamax/

Cache Plugin created by Jeff Brown and Burt Beckwith, Apache License 2.0,
available at http://grails.org/plugin/cache

@@ -136,7 +136,6 @@ dependencies {
runtime 'net.sf.supercsv:super-csv:2.4.0'
assets 'com.bertramlabs.plugins:less-asset-pipeline:2.15.1'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'software.betamax:betamax-junit:2.0.1'
testCompile('com.athaydes:spock-reports:1.6.1') {
transitive = false // this avoids affecting your version of Groovy/Spock
}

This file was deleted.

Oops, something went wrong.
@@ -38,7 +38,7 @@ class HttpRequestService {
return getRestClient(wptserver?.baseUrl)
}

GPathResult getJsonResponse(String url, String path, queryParams) {
def getJsonResponse(String url, String path, queryParams) {
return getRestClient(url).get{
request.uri.path = addLeadingSlashIfMissing(path)
request.uri.query = queryParams
@@ -25,7 +25,6 @@ import de.iteratec.osm.report.chart.CsiAggregationUtilService
import de.iteratec.osm.report.chart.Event
import de.iteratec.osm.report.chart.EventDaoService
import grails.gorm.transactions.Transactional
import groovy.util.slurpersupport.GPathResult
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import org.joda.time.format.DateTimeFormatter
@@ -83,7 +82,7 @@ class GraphiteEventService {
private List<Event> createEvents(GraphiteEventSourcePath eventSourcePath, GraphiteServer server, String from, String until){
log.debug("Fetching of graphite events: Create events for graphite server: $server, eventSourcePath: $eventSourcePath, from: $from, until: $until.")
def events = []
GPathResult json = getEventJSON(eventSourcePath.targetMetricName, server, from, until)
def json = getEventJSON(eventSourcePath.targetMetricName, server, from, until)
log.debug("Fetching of graphite events: Fetched json from server: $json")
json.each{
String shortName = it.target
@@ -108,7 +107,7 @@ class GraphiteEventService {
* @param until
* @return
*/
private GPathResult getEventJSON(String eventSourceMetricName, GraphiteServer server, String from, String until){
private def getEventJSON(String eventSourceMetricName, GraphiteServer server, String from, String until){

String webappUrl = createWebappUrlOf(server)
LinkedHashMap<String, String> queryParams = ['format': 'json', 'from': from, 'until': until, 'target': eventSourceMetricName]

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -29,25 +29,16 @@ import de.iteratec.osm.report.chart.Event
import de.iteratec.osm.report.chart.EventDaoService
import grails.buildtestdata.BuildDataTest
import grails.testing.services.ServiceUnitTest
import groovy.json.JsonSlurper
import org.joda.time.DateTime
import org.junit.Rule
import software.betamax.Configuration
import software.betamax.junit.Betamax
import software.betamax.junit.RecorderRule
import spock.lang.Ignore
import spock.lang.Specification

@Ignore
class GraphiteEventServiceSpec extends Specification implements BuildDataTest, ServiceUnitTest<GraphiteEventService> {
//TODO: Re-Write these tests without mocking http requests (e.g. without betamax or similar libray)
class GraphiteEventServiceSpec extends Specification implements BuildDataTest, ServiceUnitTest<GraphiteEventService>{

public static final DateTime untilDateTime = new DateTime(2015, 5, 29, 5, 0, 0)
public static final int minutesInPast = 1
GraphiteEventService serviceUnderTest

Configuration configuration = Configuration.builder().tapeRoot(new File("src/test/resources/betamax_tapes")).ignoreLocalhost(false).build();
@Rule
public RecorderRule recorder = new RecorderRule(configuration)
public static final String jobGroupName = 'associated JobGroup'
public static String metricName = 'alias(drawAsInfinite(server.monitor02.*.load.load_fifteen),"my-graph")'

@@ -65,14 +56,21 @@ class GraphiteEventServiceSpec extends Specification implements BuildDataTest, S
//mocks common for all tests/////////////////////////////////////////////////////////////////////////////////////////////
mockBatchActivityService()
serviceUnderTest.eventDaoService = grailsApplication.mainContext.getBean('eventDaoService')

File jsonFile = new File("src/test/resources/GraphiteEvents/GraphiteEventServiceSpec_retreive_events.json")
def jsonData = new JsonSlurper().parse(jsonFile)

serviceUnderTest.httpRequestService = Stub(HttpRequestService) {
getJsonResponse(_ as String, _ as String, _ as Object) >> jsonData
}

mockCsiAggregationUtilService()
}

void setupSpec() {
mockDomains(GraphiteServer, BatchActivity, Event, JobGroup, GraphiteEventSourcePath)
}

@Betamax(tape = 'GraphiteEventServiceSpec_retrieve_events')
def "retrieve events from test graphite server test"() {
given:
createGraphiteServerWithSourcePaths()
@@ -0,0 +1,6 @@
[
{
"target": "my-graph",
"datapoints": [[0.05, 1432871950], [0.05, 1432871960], [0.05, 1432871970], [0.05, 1432871980], [0.05, 1432871990], [0.05, 1432872000]],
}
]
Oops, something went wrong.

0 comments on commit 23e250e

Please sign in to comment.