Skip to content

Commit

Permalink
Moved the loca-dev module to the root, since it's not a service/appli…
Browse files Browse the repository at this point in the history
…cation. Changed the order of @TestPropertySource -- since it matters for overriding properties.
  • Loading branch information
gsmachado authored and Guilherme Sperb Machado committed Apr 4, 2018
1 parent d5c2cf3 commit 20db856
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 63 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,9 @@ ICOnator has the aim to make the tokenization of assets a popular and easy proce

We are building the most straight-forward, secure, configurable, and user-friendly open source ICO/ITO platform ever -- all driven by the community!

## How to run?
## API documentation

For developing localy, an message queue and email sink is started automatically. Just start ICOnatorApplication, run:

```
./gradlew clean build
./services/local-dev/build/libs/local-dev.jar
```

You still need to run the Parity node in order that the monitor can connect to localhost:8545

ICOnator has integrated swagger in the non-production profile. To see the API in swagger, go to [http://localhost:8081/swagger-ui.html](http://localhost:8081/swagger-ui.html).
ICOnator has integrated swagger in the non-production profile. The API documentation is available on [http://localhost:8081/swagger-ui.html](http://localhost:8081/swagger-ui.html).

## Architecture

Expand Down Expand Up @@ -66,6 +57,7 @@ Run parity in the Kovan (testnet) chain:
```
docker run --rm -ti -p 127.0.0.1:8180:8180 -p 127.0.0.1:8545:8545 -p 127.0.0.1:8546:8546 -p 127.0.0.1:30303:30303 -p 127.0.0.1:30303:30303/udp parity/parity --ui-interface all --jsonrpc-interface all --tracing on --pruning fast --warp --mode active --chain kovan
```

## Application Monitoring

### ELK stack
Expand Down Expand Up @@ -131,8 +123,6 @@ output {

# Docker



```
$ ./gradlew clean build
$ export ICONATOR_VERSION=0.0.1 && docker build -f docker/base/Dockerfile -t iconator/base:${ICONATOR_VERSION} -t iconator/base:latest ./
Expand Down
14 changes: 2 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,7 @@ subprojects {
targetCompatibility = JavaVersion.VERSION_1_8
}

// Don't generate a build folder in the services directory
configure([project("services")]) {
// Don't generate a build folder in the root of the following projects:
configure([project('commons'), project('services')]) {
jar.enabled = false
}

// Don't generate a build folder in the commons directory
configure([project("commons")]) {
jar.enabled = false
}

// Define which tasks Heroku will run before starting the server
//task stage(dependsOn: ['services:core:build', 'services:monitor:build', 'services:email:build']) {
// gradle.startParameter.excludedTaskNames += "test"
//}
17 changes: 17 additions & 0 deletions local-dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ICOnator: Local Development Project

This module provides an easy way to start all the ICOnator applications at once for local development. You have two options:

* Execute the `ICOnatorLocalDevApplication` class directly from the IDE;
* or, run from a single JAR file.

You can produce the single JAR file running the following command (relative of the git root dir):

```
$ sh gradlew clean :local-dev:build
$ sh local-dev/build/libs/local-dev.jar
```

A built-in message broker (Apache QPID) and an email sink would be automatically be started.

Also, a Parity node running on `localhost:8545` is required. You can override that by setting the `MONITOR_ETHEREUM_NODE_URL` environment variable.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,38 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.PropertySource;


@SpringBootApplication
@PropertySource({
"core.application.properties",
"email.application.properties",
"monitor.application.properties",
"rates.application.properties"})
public class ICOnatorApplication {
private static final Logger LOG = LoggerFactory.getLogger(ICOnatorApplication.class);
public class ICOnatorLocalDevApplication {

private static final Logger LOG = LoggerFactory.getLogger(ICOnatorLocalDevApplication.class);

public static void main(String[] args) throws Exception {
try {
startMessageQueue();
startDummySmtp();
//SpringApplication.run(EmailApplication.class, args);
new SpringApplicationBuilder().sources(CoreApplication.class, EmailApplication.class).run(args);
//SpringApplication.run(CoreApplication.class, args);
//SpringApplication.run(MonitorApplication.class, args);
//SpringApplication.run(RatesApplication.class, args);
} catch (Throwable t) {
//ignore silent exception
if(!t.getClass().toString().endsWith("SilentExitException")) {
if (!t.getClass().toString().endsWith("SilentExitException")) {
LOG.error("cannot execute monitor", t);
}
}
}

/**
* Starts the message queue when no profile is set, this means we are local
* and we want to start the message queue on this machine. Also, the dev-tools
* Starts the message queue broker when no profile is set, this means we are local
* and we want to start the broker on this machine. Also, the dev-tools
* with Spring Boot, restart the application, thus, we don't want to restart the queue.
*
* @throws Exception
*/
private static void startMessageQueue() throws Exception {
if(!Thread.currentThread().getName().equals("restartedMain")) {
if (!Thread.currentThread().getName().equals("restartedMain")) {
io.iconator.commons.test.utils.BuiltInMessageBroker.start();
}
}
Expand All @@ -54,8 +50,9 @@ private static void startMessageQueue() throws Exception {
* @throws Exception
*/
private static void startDummySmtp() throws Exception {
if(!Thread.currentThread().getName().equals("restartedMain")) {
if (!Thread.currentThread().getName().equals("restartedMain")) {
io.iconator.commons.test.utils.DummySmtp.start();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import static org.springframework.boot.SpringApplication.run;

@SpringBootApplication
@EnableJpaRepositories("io.iconator.commons.sql.dao")
@EntityScan("io.iconator.commons.model.db")

//required for swagger to find the configuration (baseservice) and the API methods (controller)
@ComponentScan("io.iconator")
@EnableJpaRepositories({"io.iconator.commons.sql.dao"})
@EntityScan({"io.iconator.commons.model.db"})
@ComponentScan({"io.iconator.commons.baseservice", "io.iconator.core"})
public class CoreApplication {

private static final Logger LOG = LoggerFactory.getLogger(CoreApplication.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource({"classpath:application-test.properties", "classpath:core.application.properties"})
@TestPropertySource({"classpath:core.application.properties", "classpath:application-test.properties"})
// ;mv_store=false needed for correct isolation level:
// http://h2-database.66688.n3.nabble.com/Am-I-bananas-or-does-serializable-isolation-not-work-as-it-should-tp4030767p4030768.html
public abstract class BaseApplicationTest extends BaseMessageBrokerServiceTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;

import static org.springframework.boot.SpringApplication.run;

Expand All @@ -17,7 +16,7 @@ public static void main(String[] args) {
run(EmailApplication.class, args);
} catch (Throwable t) {
//ignore silent exception
if(!t.getClass().toString().endsWith("SilentExitException")) {
if (!t.getClass().toString().endsWith("SilentExitException")) {
LOG.error("cannot execute core", t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@TestPropertySource("classpath:application.properties")
@TestPropertySource({"classpath:application.properties"})
public abstract class TokenAppBaseTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import static org.springframework.boot.SpringApplication.run;

@SpringBootApplication
@EnableJpaRepositories("io.iconator.commons.sql.dao")
@EntityScan("io.iconator.commons.model.db")
@EnableJpaRepositories({"io.iconator.commons.sql.dao"})
@EntityScan({"io.iconator.commons.model.db"})
public class MonitorApplication {

private static final Logger LOG = LoggerFactory.getLogger(MonitorApplication.class);

public static void main(String[] args) throws Exception {
Expand All @@ -22,7 +21,7 @@ public static void main(String[] args) throws Exception {
run(MonitorApplication.class, args);
} catch (Throwable t) {
//ignore silent exception
if(!t.getClass().toString().endsWith("SilentExitException")) {
if (!t.getClass().toString().endsWith("SilentExitException")) {
LOG.error("cannot execute monitor", t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import static org.springframework.boot.SpringApplication.run;

@SpringBootApplication
@EntityScan(basePackages = {"io.iconator.commons.model.db"})
@EnableJpaRepositories("io.iconator.commons.sql.dao")
@EntityScan({"io.iconator.commons.model.db"})
@EnableJpaRepositories({"io.iconator.commons.sql.dao"})
@EnableAutoConfiguration
@ComponentScan(basePackages = {"io.iconator.commons.sql.dao", "io.iconator.rates"})
@ComponentScan({"io.iconator.commons.sql.dao", "io.iconator.rates"})
public class RatesApplication {

private static final Logger LOG = LoggerFactory.getLogger(RatesApplication.class);

public static void main(String[] args) {
Expand All @@ -25,7 +25,7 @@ public static void main(String[] args) {
run(RatesApplication.class, args);
} catch (Throwable t) {
//ignore silent exception
if(!t.getClass().toString().endsWith("SilentExitException")) {
if (!t.getClass().toString().endsWith("SilentExitException")) {
LOG.error("cannot execute rates", t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import io.iconator.commons.model.ExchangeType;
import io.iconator.commons.model.db.ExchangeAggregateRate;
import io.iconator.commons.sql.dao.ExchangeAggregateRateRepository;
import io.iconator.rates.config.AggregationServiceConfig;
import io.iconator.rates.config.Beans;
import io.iconator.rates.config.BlockchainInfoClientConfig;
import io.iconator.rates.config.EtherScanClientConfig;
import io.iconator.rates.config.ExchangeRateServiceConfig;
import io.iconator.rates.config.RatesAppConfig;
import io.iconator.rates.config.TestConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,10 +24,17 @@
import static org.junit.Assert.assertTrue;

@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(classes = {
TestConfig.class,
AggregationServiceConfig.class,
ExchangeRateServiceConfig.class,
BlockchainInfoClientConfig.class,
EtherScanClientConfig.class,
RatesAppConfig.class,
Beans.class
})
@DataJpaTest
@TestPropertySource({"classpath:application-test.properties", "classpath:rates.application.properties"})

@TestPropertySource({"classpath:rates.application.properties", "classpath:application-test.properties"})
public class ExchangeRateServiceTest {

@Autowired
Expand All @@ -37,10 +51,8 @@ public void testFetchRates() {
assertTrue(checkIfExchangeIsPresent(all, ExchangeType.BITFINEX));
assertTrue(checkIfExchangeIsPresent(all, ExchangeType.BITSTAMP));
assertTrue(checkIfExchangeIsPresent(all, ExchangeType.KRAKEN));
//GDAX, COINMARKETCAP are not running
//TODO: figure out why and fix
//assertTrue(checkIfExchangeIsPresent(all, ExchangeType.GDAX));
//assertTrue(checkIfExchangeIsPresent(all, ExchangeType.COINMARKETCAP));
assertTrue(checkIfExchangeIsPresent(all, ExchangeType.GDAX));
assertTrue(checkIfExchangeIsPresent(all, ExchangeType.COINMARKETCAP));
assertTrue(checkIfCurrencyIsPresent(all, CurrencyType.ETH));
assertTrue(checkIfCurrencyIsPresent(all, CurrencyType.BTC));
}
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ FileFilter fileFilter = new FileFilter() {
}
}

include 'local-dev'

['services', 'commons'].each { String dir ->
file(dir).listFiles(fileFilter).each { File module ->
include "${dir}:${module.name}"
Expand Down

0 comments on commit 20db856

Please sign in to comment.