Skip to content

Commit

Permalink
latest gradle and project plugin.
Browse files Browse the repository at this point in the history
Some real wierdness around Spectator Registry throwing ArrayIndexOutOfBoundExceptions when running tests at the CLI
Switched tests to just do a Stub(Registry)
  • Loading branch information
cfieber committed Nov 13, 2015
1 parent b15b89f commit b11d72b
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 362 deletions.
69 changes: 17 additions & 52 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,22 @@
*/

buildscript {
ext {
springBootVersion = "1.2.5.RELEASE"
}
repositories {
if (project.hasProperty('internalArtifactory')) {
maven { url project.internalArtifactory }
} else {
jcenter()
}
jcenter()
maven { url 'http://dl.bintray.com/spinnaker/gradle/' }
}
dependencies {
classpath 'com.netflix.spinnaker:spinnaker-gradle-project:1.12.102'
classpath 'com.netflix.spinnaker.gradle:spinnaker-gradle-project:2.2.0'
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}

ext {
springBootVersion = "1.2.5.RELEASE"

versions = [
batch : "3.0.1.RELEASE",
guava : "14.0.1",
jackson : "2.3.3",
okhttp : "2.0.0",
retrofit: "1.6.1",
rx : "0.20.2",
slf4j : "1.7.5",
spock : "1.0-groovy-2.3",
spring : "4.0.6.RELEASE"
]

commonDependencies = [
guava : dependencies.create("com.google.guava:guava:$versions.guava"),
hamcrest : dependencies.create("org.hamcrest:hamcrest-all:1.3"),
jacksonDatabind: dependencies.create("com.fasterxml.jackson.core:jackson-databind:$versions.jackson"),
jacksonGuava : dependencies.create("com.fasterxml.jackson.datatype:jackson-datatype-guava:$versions.jackson"),
logback : dependencies.create("ch.qos.logback:logback-classic:$versions.logback"),
okHttp : dependencies.create("com.squareup.okhttp:okhttp-urlconnection:$versions.okhttp"),
retrofit : dependencies.create("com.squareup.retrofit:retrofit:$versions.retrofit"),
rxJava : dependencies.create("com.netflix.rxjava:rxjava-core:$versions.rx"),
slf4j : dependencies.create("org.slf4j:slf4j-api:$versions.slf4j"),
slf4jJcl : dependencies.create("org.slf4j:jcl-over-slf4j:$versions.slf4j"),
slf4jSimple : dependencies.create("org.slf4j:slf4j-simple:$versions.slf4j"),
spock : dependencies.create("org.spockframework:spock-core:$versions.spock"),
spockSpring : dependencies.create("org.spockframework:spock-spring:$versions.spock"),
springBatch : dependencies.create("org.springframework.batch:spring-batch-core:$versions.batch"),
springBatchTest: dependencies.create("org.springframework.batch:spring-batch-test:$versions.batch"),
springTest : dependencies.create("org.springframework:spring-test:$versions.spring"),
springWeb : dependencies.create("org.springframework:spring-web:$versions.spring"),
objenesis : dependencies.create("org.objenesis:objenesis:2.1")
]
}

allprojects {
apply plugin: "spinnaker-gradle-project"
apply plugin: "spinnaker.project"
apply plugin: "groovy"
apply plugin: 'jacoco'
group = "com.netflix.spinnaker.echo"

Expand All @@ -83,13 +47,6 @@ allprojects {
}

subprojects {
repositories {
if (project.hasProperty('internalArtifactory')) {
maven { url project.internalArtifactory }
} else {
jcenter()
}
}
plugins.withType(JavaPlugin) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
Expand All @@ -98,8 +55,16 @@ subprojects {
jacoco {
toolVersion = '0.7.0.201403182114'
}

dependencies {
compile spinnaker.dependency('groovy')
compile spinnaker.dependency('guava')
compile spinnaker.dependency('slf4j')
testCompile spinnaker.dependency('spock')
testRuntime spinnaker.dependency('slf4jSimple')
testRuntime "org.slf4j:jcl-over-slf4j:${spinnaker.version('slf4j')}"
}
}

tasks.checkSnapshotDependencies.enabled = false

defaultTasks ':echo-web:bootRun'
53 changes: 0 additions & 53 deletions config/codenarc/rules.groovy

This file was deleted.

8 changes: 3 additions & 5 deletions echo-cassandra/echo-cassandra.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
compile project(':echo-model')
compile spinnaker.dependency('bootWeb')
compile spinnaker.dependency("kork")
compile spinnaker.dependency("korkCassandra")
compile commonDependencies.jacksonDatabind
testCompile commonDependencies.spockSpring
testCompile commonDependencies.springTest
compile spinnaker.dependency('jacksonDatabind')
testCompile spinnaker.dependency('spockSpring')
testCompile spinnaker.dependency('springTest')
}

test {
Expand Down
8 changes: 3 additions & 5 deletions echo-core/echo-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
spinnaker.group("retrofitDefault")

compile project(":echo-model")
compile commonDependencies.rxJava
testCompile commonDependencies.spockSpring
testCompile commonDependencies.springTest
compile spinnaker.dependency('rxJava')
testCompile spinnaker.dependency('spockSpring')
testCompile spinnaker.dependency('springTest')
}
2 changes: 0 additions & 2 deletions echo-model/echo-model.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
spinnaker.group("lombok")

Expand Down
4 changes: 1 addition & 3 deletions echo-notifications/echo-notifications.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
compile project(':echo-core')
spinnaker.group("test")
Expand All @@ -25,7 +23,7 @@ dependencies {
compile spinnaker.dependency("kork")
compile spinnaker.dependency("rxJava")
compile "javax.mail:mail:1.4.1"
compile "org.springframework:spring-context-support:4.0.8.RELEASE"
compile "org.springframework:spring-context-support:${spinnaker.version('spring')}"
compile "org.apache.velocity:velocity:1.7"
compile "org.jsoup:jsoup:1.8.2"
testCompile "com.icegreen:greenmail:1.4.0"
Expand Down
2 changes: 0 additions & 2 deletions echo-pipelinetriggers/echo-pipelinetriggers.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
spinnaker.group("test")
spinnaker.group("lombok")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.function.Predicate;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spectator.api.ExtendedRegistry;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.echo.events.EchoEventListener;
import com.netflix.spinnaker.echo.model.BuildEvent;
import com.netflix.spinnaker.echo.model.Event;
Expand All @@ -16,7 +16,6 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import rx.Observable;
import rx.functions.Action1;
Expand All @@ -36,12 +35,12 @@ public class BuildEventMonitor implements EchoEventListener {

private final PipelineCache pipelineCache;
private final Action1<Pipeline> subscriber;
private final ExtendedRegistry registry;
private final Registry registry;

@Autowired
public BuildEventMonitor(@NonNull PipelineCache pipelineCache,
@NonNull Action1<Pipeline> subscriber,
@NonNull @Qualifier("extendedRegistry") ExtendedRegistry registry) {
@NonNull Registry registry) {
this.pipelineCache = pipelineCache;
this.subscriber = subscriber;
this.registry = registry;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.netflix.spinnaker.echo.pipelinetriggers;

import lombok.extern.slf4j.Slf4j;
import rx.functions.Action1;

@Slf4j
public class LogError implements Action1<Throwable> {
@Override
public void call(Throwable throwable) {
log.error("Observable Failed", throwable);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@

package com.netflix.spinnaker.echo.pipelinetriggers;

import com.netflix.spectator.api.ExtendedRegistry;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.echo.model.Pipeline;
import com.netflix.spinnaker.echo.services.Front50Service;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;
import rx.functions.Action1;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
Expand All @@ -45,7 +43,7 @@ public class PipelineCache implements MonitoredPoller {
private final Scheduler scheduler;
private final int pollingIntervalSeconds;
private final Front50Service front50;
private final ExtendedRegistry registry;
private final Registry registry;

private transient Instant lastPollTimestamp;
private transient Subscription subscription;
Expand All @@ -56,7 +54,7 @@ public class PipelineCache implements MonitoredPoller {
public PipelineCache(@NonNull Scheduler scheduler,
int pollingIntervalSeconds,
@NonNull Front50Service front50,
@NonNull @Qualifier("extendedRegistry") ExtendedRegistry registry) {
@NonNull Registry registry) {
this.scheduler = scheduler;
this.pollingIntervalSeconds = pollingIntervalSeconds;
this.front50 = front50;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package com.netflix.spinnaker.echo.pipelinetriggers

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spectator.api.ExtendedRegistry
import com.netflix.spectator.api.NoopRegistry
import com.netflix.spectator.api.Counter
import com.netflix.spectator.api.Id
import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.echo.model.Event
import com.netflix.spinnaker.echo.model.Pipeline
import com.netflix.spinnaker.echo.services.Front50Service
import com.netflix.spinnaker.echo.test.RetrofitStubs
import rx.functions.Action1
import rx.schedulers.Schedulers
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Subject
import spock.lang.Unroll
import static com.netflix.spinnaker.echo.model.BuildEvent.Result.*
import static java.util.concurrent.TimeUnit.SECONDS
import static rx.Observable.empty
import static rx.Observable.just

class BuildEventMonitorSpec extends Specification implements RetrofitStubs {
def objectMapper = new ObjectMapper()
def pipelineCache = Mock(PipelineCache)
def subscriber = Mock(Action1)
def registry = new ExtendedRegistry(new NoopRegistry())
def registry = Stub(Registry) {
createId(*_) >> Stub(Id)
counter(*_) >> Stub(Counter)
gauge(*_) >> Integer.valueOf(1)
}

@Subject
def monitor = new BuildEventMonitor(pipelineCache, subscriber, registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package com.netflix.spinnaker.echo.pipelinetriggers

import com.netflix.spectator.api.ExtendedRegistry
import com.netflix.spectator.api.NoopRegistry
import com.netflix.spectator.api.Counter
import com.netflix.spectator.api.Id
import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.echo.model.Pipeline
import com.netflix.spinnaker.echo.services.Front50Service
import com.netflix.spinnaker.echo.test.RetrofitStubs
Expand All @@ -35,7 +36,12 @@ import static rx.Observable.just
class PipelineCacheSpec extends Specification implements RetrofitStubs {
def scheduler = Schedulers.test()
def front50 = Mock(Front50Service)
def registry = new ExtendedRegistry(new NoopRegistry())
def registry = Stub(Registry) {
createId(*_) >> Stub(Id)
counter(*_) >> Stub(Counter)
gauge(*_) >> Integer.valueOf(1)
}


@Shared
def interval = 30
Expand Down
8 changes: 3 additions & 5 deletions echo-rest/echo-rest.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
spinnaker.group('retrofitDefault')
compile project(':echo-model')
compile spinnaker.dependency('korkWeb')
compile commonDependencies.jacksonDatabind
testCompile commonDependencies.spockSpring
testCompile commonDependencies.springTest
compile spinnaker.dependency('jacksonDatabind')
testCompile spinnaker.dependency('spockSpring')
testCompile spinnaker.dependency('springTest')
}
2 changes: 0 additions & 2 deletions echo-scheduler/echo-scheduler.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

dependencies {
compile project(':echo-pipelinetriggers')

Expand Down
Loading

0 comments on commit b11d72b

Please sign in to comment.