Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Apekshit Sharma <apekshit.sharma@hedera.com>
  • Loading branch information
apeksharma committed Nov 23, 2019
1 parent 8015440 commit 5a8ce85
Show file tree
Hide file tree
Showing 65 changed files with 243 additions and 186 deletions.
34 changes: 17 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ references:
name: Generating mirror-importer.tgz
working_directory: /tmp/workspace/
command: |
_tagged_dir=mirror-importer-${CIRCLE_TAG:-b$CIRCLE_BUILD_NUM}
mv mirror-importer "${_tagged_dir}"
tar -czf /tmp/workspace/mirror-importer.tgz "${_tagged_dir}"
tgzname=mirror-importer-${CIRCLE_TAG:-b$CIRCLE_BUILD_NUM}
mv mirror-importer "${tgzname}"
tar -czf /tmp/workspace/${tgzname}.tgz "${tgzname}"
workflows:
version: 2
Expand All @@ -24,7 +24,7 @@ workflows:
only: /.*/
tags:
only: /.*/
- build_rest_api:
- build_mirror_rest:
filters: # required since `release_artifacts` has tag filters AND requires `this`
branches:
only: /.*/
Expand All @@ -33,7 +33,7 @@ workflows:
- release_artifacts:
requires:
- build_mirror_importer
- build_rest_api
- build_mirror_rest
filters:
branches:
ignore: /.*/
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
paths:
- mirror-importer

build_rest_api:
build_mirror_rest:
docker:
- image: node:12.10.0
- image: circleci/postgres:9.6.14
Expand All @@ -92,39 +92,39 @@ jobs:
- checkout:
- restore_cache:
keys:
- npm-v1-{{ .Branch }}-{{ checksum "mirror-api-rest/rest-api/package-lock.json" }}
- npm-v1-{{ .Branch }}-{{ checksum "mirror-rest/package-lock.json" }}
- npm-v1-{{ .Branch }}
- npm-v1-
- run:
working_directory: "mirror-api-rest/rest-api"
working_directory: "mirror-rest"
name: Run npm ci (ensure node_modules is based on package-lock.json).
command: npm ci
- save_cache:
key: npm-v1-{{ .Branch }}-{{ checksum "mirror-api-rest/rest-api/package-lock.json" }}
key: npm-v1-{{ .Branch }}-{{ checksum "mirror-rest/package-lock.json" }}
paths:
- node_modules
- .node-flywaydb
- ~/.npm
- run:
working_directory: "mirror-api-rest/rest-api"
working_directory: "mirror-rest"
name: Run npm test
command: npm test
environment:
TEST_DB_HOST: "127.0.0.1"
TEST_DB_NAME: "mirror_node_integration"
- store_test_results:
path: mirror-api-rest/rest-api/target/jest-junit
path: mirror-rest/target/jest-junit
- run:
working_directory: "mirror-api-rest/rest-api"
name: Collecting rest-api assets
working_directory: "mirror-rest"
name: Collecting mirror-rest assets
command: |
npm pack
mkdir -p /tmp/workspace/
mv rest-api*.tgz /tmp/workspace/rest-api.tgz
mv mirror-rest*.tgz /tmp/workspace/mirror-rest-${CIRCLE_TAG:-b$CIRCLE_BUILD_NUM}.tgz
- persist_to_workspace:
root: *workspace_root
paths:
- rest-api.tgz
- mirror-rest-*.tgz

release_artifacts:
docker:
Expand All @@ -133,9 +133,9 @@ jobs:
- *attach_workspace
- *package_mirror_importer
- store_artifacts:
path: /tmp/workspace/mirror-importer.tgz
path: /tmp/workspace/mirror-importer-*.tgz
- store_artifacts:
path: /tmp/workspace/rest-api.tgz
path: /tmp/workspace/mirror-rest-*.tgz

dependencies:
override:
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ manage the process. See the [operations](operations.md) documentation for more i
To start the REST API ensure you have the necessary [configuration](configuration.md) populated and run:

```console
cd mirror-api-rest/rest-api
cd mirror-rest
npm install
npm start
```
Expand All @@ -61,7 +61,7 @@ npm test

The acceptance tests can be used against a live instance to verify the REST API is functioning correctly. To use specify
the instance IP address and port as a `TARGET` environment variable. See the
[monitoring](../rest-api/monitoring/README.md) documentation for more detail.
[monitoring](../mirror-rest/monitoring/README.md) documentation for more detail.

```console
TARGET=127.0.0.1:5551 npm run acceptancetest
Expand Down
45 changes: 45 additions & 0 deletions jacoco-aggregator/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<artifactId>jacoco-aggregator</artifactId>

<parent>
<groupId>com.hedera</groupId>
<artifactId>mirror-node</artifactId>
<version>0.4.1-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>com.hedera</groupId>
<artifactId>mirror-importer</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

This file was deleted.

72 changes: 70 additions & 2 deletions mirror-importer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

<artifactId>mirror-importer</artifactId>
<name>Hedera Mirror Node Importer</name>
<description>Hedera Mirror Node mirrors data from Hedera nodes</description>

<!-- Inherits from the Jib Multimodule parent POM. -->
<parent>
<groupId>com.hedera</groupId>
<artifactId>mirror-node</artifactId>
Expand All @@ -17,6 +15,15 @@

<packaging>jar</packaging>

<properties>
<commons-io.version>2.6</commons-io.version>
<disruptor.version>3.4.2</disruptor.version> <!-- Used for asynchronous logging -->
<hedera-protobuf.version>0.3.5</hedera-protobuf.version>
<hedera-sdk.version>0.6.1</hedera-sdk.version>
<jib.version>1.8.0</jib.version>
<testcontainers.version>1.12.1</testcontainers.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -32,6 +39,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>${disruptor.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
Expand Down Expand Up @@ -144,10 +156,66 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib.version}</version>
<configuration>
<to>
<image>hederahashgraph/mirror-node</image>
<tags>
<tag>${project.version}</tag>
</tags>
</to>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<roots>
<root>.</root>
</roots>
</configuration>
</plugin>
</plugins>
</build>
</project>
8 changes: 4 additions & 4 deletions mirror-importer/scripts/deploy-mirror-importer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ mkdir -p "${usretc}" "${usrlib}" "${varlib}"
if [ -f "/usr/lib/mirror-node/mirror-node.jar" ] || [ -f "${usrlib}/mirror-importer.jar" ]; then
echo "Upgrading to ${version}"

# Stop the service
echo "Stopping ${oldjarname} service"
systemctl stop ${oldjarname}.service || true

if [ -f "/usr/lib/mirror-node/mirror-node.jar" ]; then
echo "Migrating from 'mirror-node' to 'mirror-importer'"
oldjarname="mirror-node"
Expand All @@ -28,10 +32,6 @@ if [ -f "/usr/lib/mirror-node/mirror-node.jar" ] || [ -f "${usrlib}/mirror-impor
oldjarname="mirror-importer"
fi

# Stop the service
echo "Stopping ${oldjarname} service"
systemctl stop ${oldjarname}.service || true

echo "Backing up binary"
mv "${usrlib}/${oldjarname}.jar" "${usrlib}/${oldjarname}.jar.${ts}.old"

Expand Down
6 changes: 3 additions & 3 deletions mirror-importer/scripts/mirror-importer.service
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[Unit]
After=syslog.target
Description=Hedera Mirror Node
Description=Hedera Mirror Importer

[Service]
ExecStart=/usr/bin/java -jar mirror-node.jar -Djavax.net.ssl.trustStorePassword=changeit -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector --spring.config.additional-location=file:/usr/etc/mirror-node/
ExecStart=/usr/bin/java -jar mirror-importer.jar -Djavax.net.ssl.trustStorePassword=changeit -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector --spring.config.additional-location=file:/usr/etc/mirror-importer/
LimitNOFILE=65536
Restart=on-failure
RestartSec=1
SuccessExitStatus=143
Type=simple
WorkingDirectory=/usr/lib/mirror-node
WorkingDirectory=/usr/lib/mirror-importer

[Install]
WantedBy=multi-user.target
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ const instantiateDatabase = async function() {
};

/**
* Run the sql (non-java) based migrations in
* ../mirror-importer/src/main/resources/db/migration against the target database.
* Run the sql (non-java) based migrations stored in the importer project against the target database.
* @returns {Promise}
*/
const flywayMigrate = function() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,18 @@
"result": "SUCCESS",
"transaction_id": "0.15.63-0-000002062",
"transfers": [
{
"account": "0.15.2",
"amount": 1
},
{
"account": "0.15.63",
"amount": -71
},
{
"account": "0.15.82",
"amount": 70
}
{
"account": "0.15.2",
"amount": 1
},
{
"account": "0.15.63",
"amount": -71
},
{
"account": "0.15.82",
"amount": 70
}
],
"valid_duration_seconds": "7000",
"valid_start_timestamp": "0.000002062"
Expand All @@ -239,18 +239,18 @@
"result": "SUCCESS",
"transaction_id": "0.15.82-0-000002063",
"transfers": [
{
"account": "0.15.2",
"amount": 1
},
{
"account": "0.15.63",
"amount": 20
},
{
"account": "0.15.82",
"amount": -21
}
{
"account": "0.15.2",
"amount": 1
},
{
"account": "0.15.63",
"amount": 20
},
{
"account": "0.15.82",
"amount": -21
}
],
"valid_duration_seconds": "8000",
"valid_start_timestamp": "0.000002063"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ const validateAccNumRange = function(transactions, low, high) {
}

if (!ret) {
console.log(`validateAccNumRange check failed: No transfer with account between ${low} and ${high} was found in transaction : ${JSON.stringify(tx)}`);
console.log(
`validateAccNumRange check failed: No transfer with account between ${low} and ${high} was found in transaction : ${JSON.stringify(
tx
)}`
);
return false;
}

Expand Down
Loading

0 comments on commit 5a8ce85

Please sign in to comment.