Skip to content

Commit

Permalink
feat: add lh canary first version (#637)
Browse files Browse the repository at this point in the history
Included:

- Metronome (synthetic monitoring simulator)
- Aggregator (kafka stream topology) for calculating metrics
- TaskRunLatency metric
- Configurations
- do-canary.sh script
- Log level improvements
- Protobuf classes
- Docker build

Future:

- Finish DuplicatedTaskRun metric
- Kafka Stream tests
- gRPC server
- gRPC health check
- Prometheus integration

---------

Co-authored-by: Mijail Rondon <[email protected]>
Refers: #637
  • Loading branch information
sauljabin and mijailr authored Feb 5, 2024
1 parent fc0fe12 commit 1e998ff
Show file tree
Hide file tree
Showing 98 changed files with 2,060 additions and 257 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ignore everything
*
!canary/
!server/
!sdk-java/
!sdk-go/
Expand Down
45 changes: 38 additions & 7 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ on:
branches-ignore:
- "master"
paths:
- dashboard/**
- .github/workflows/branch.yml
- docker/dashboard/**
- server/**
- docker/server/**
- .github/workflows/branch.yml
- docker/standalone/**
- docker/canary/**
- server/**
- dashboard/**
- canary/**
permissions:
id-token: write
contents: read
Expand All @@ -28,21 +31,49 @@ jobs:
java-version: 17

- name: Tests and Build
run: ./gradlew server:test server:shadowJar
run: ./gradlew server:build

- uses: actions/upload-artifact@v4
with:
name: server-jar
path: server/build/libs/server-*-all.jar

- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-server
dockerfile: docker/server/Dockerfile
registry: ecr
prefix: branch-

lh-canary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Tests and Build
run: ./gradlew canary:build

- uses: actions/upload-artifact@v4
with:
name: canary-jar
path: canary/build/libs/canary-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-canary
dockerfile: docker/canary/Dockerfile
registry: ecr
prefix: branch-

lh-dashboard:
runs-on: ubuntu-latest
steps:
Expand All @@ -66,7 +97,7 @@ jobs:
pnpm install
pnpm build
- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-dashboard
Expand Down Expand Up @@ -105,7 +136,7 @@ jobs:
name: server-jar
path: server/build/libs/

- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-standalone
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,46 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Dowload Server Jar artifact
- name: Download Server Jar artifact
uses: actions/download-artifact@v4
with:
name: server-jar
path: server/build/libs/

- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-server
dockerfile: docker/server/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}

lh-canary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Tests and Build
run: ./gradlew canary:build

- uses: actions/upload-artifact@v4
with:
name: canary-jar
path: canary/build/libs/canary-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-canary
dockerfile: docker/canary/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}

lhctl:
runs-on: ubuntu-latest
needs:
Expand All @@ -54,7 +81,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lhctl
Expand Down Expand Up @@ -84,7 +111,7 @@ jobs:
pnpm install
pnpm build
- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-dashboard
Expand Down Expand Up @@ -122,7 +149,7 @@ jobs:
name: server-jar
path: server/build/libs/

- name: Build and publish
- name: Build and Publish
uses: ./.github/actions/publish-image
with:
image-name: lh-standalone
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ jobs:
- name: Tests
working-directory: ./sdk-python
run: poetry run python -m unittest -v
tests-canary:
if: ${{ !contains(github.event.head_commit.message, '[skip main]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17
- name: Tests
run: ./gradlew canary:test canary:build
tests-server:
if: ${{ !contains(github.event.head_commit.message, '[skip main]') }}
runs-on: ubuntu-latest
Expand Down
26 changes: 5 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
define: &exclude |
exclude: |
(?x)(
^server/src/main/java/io/littlehorse/common/proto/|
^sdk-java/src/main/java/io/littlehorse/sdk/common/proto/|
Expand All @@ -10,17 +10,15 @@ define: &exclude |
^dashboard/apps/web/littlehorse-public-api/|
^docs/images/
)

fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
name: Trailing Whitespace
exclude: *exclude
- id: end-of-file-fixer
name: Check End of Files
exclude: *exclude
- id: check-added-large-files
name: Check For Any Large Added File
- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down Expand Up @@ -89,26 +87,12 @@ repos:
# Tests

- id: java-build
name: Tests Build
name: Tests Java Projects
language: system
always_run: true
pass_filenames: false
entry: ./gradlew build

- id: server-tests
name: Running Server Tests
language: system
always_run: true
pass_filenames: false
entry: ./gradlew server:test

- id: java-tests
name: Running SDK Java Tests
language: system
always_run: true
pass_filenames: false
entry: ./gradlew sdk-java:test

- id: javadoc
name: Running JavaDoc
language: system
Expand All @@ -130,8 +114,8 @@ repos:
pass_filenames: false
entry: poetry -C ./sdk-python run python -m unittest discover -s sdk-python/

- id: js-linting
name: Verify Build & Linting Dashboard Code
- id: js-build
name: Verify Build
language: system
always_run: true
pass_filenames: false
Expand Down
19 changes: 19 additions & 0 deletions canary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# LittleHorse Canary App

Start a local kafka cluster:

```
../local-dev/setup.sh
```

Start LH Server:

```
../local-dev/do-server.sh
```

Start LH Canary:

```
../local-dev/do-canary.sh
```
96 changes: 96 additions & 0 deletions canary/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
plugins {
id 'java'
id 'application'
id 'checkstyle'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.freefair.lombok' version '8.4'
id 'com.google.protobuf' version '0.9.4'
}

repositories {
mavenCentral()
}

dependencies {
// LittleHorse
implementation project(':sdk-java')

// Tools
implementation 'com.google.guava:guava:33.0.0-jre'

// Configurations
implementation 'io.smallrye.config:smallrye-config:3.5.2'

// Logging
implementation 'org.slf4j:slf4j-api:2.0.11'
// implementation 'ch.qos.logback:logback-classic:1.4.14'
implementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.22.1'

// Kafka
implementation 'org.apache.kafka:kafka-streams:3.6.1'

// Tests
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.junit-pioneer:junit-pioneer:2.2.0'
testImplementation 'org.mockito:mockito-core:5.10.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.10.0'
testImplementation 'net.datafaker:datafaker:2.1.0'
testImplementation 'org.apache.kafka:kafka-streams-test-utils:3.6.1'
}

test {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
exceptionFormat = 'full'
}
jvmArgs = ['--add-opens', 'java.base/java.lang=ALL-UNNAMED', '--add-opens', 'java.base/java.util=ALL-UNNAMED']
}

spotless {
java {
target('**/*.java')
palantirJavaFormat()
}
}

application {
mainClass = 'io.littlehorse.canary.Main'
}

shadowJar {
mergeServiceFiles()
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-parameters'
}

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.25.2'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.61.0'
}
}
}

checkstyle {
configFile = file("${rootDir}/canary/checkstyle.xml")
checkstyleTest.enabled = false
}

tasks.withType(Checkstyle).configureEach {
exclude('**io/littlehorse/canary/proto**')
}
14 changes: 14 additions & 0 deletions canary/canary.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Canary settings
lh.canary.client.id=dev
lh.canary.topic.creation.enable=true
lh.canary.topic.creation.replicas=1
lh.canary.topic.creation.partitions=1

# Aggregator settings
lh.canary.aggregator.enable=true

# Metronome settings
lh.canary.metronome.enable=true
lh.canary.metronome.frequency.ms=1000
lh.canary.metronome.threads=1
lh.canary.metronome.runs=1
9 changes: 9 additions & 0 deletions canary/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="FinalParameters"/>
<module name="FinalLocalVariable"/>
</module>
</module>
Loading

0 comments on commit 1e998ff

Please sign in to comment.