Skip to content

Commit

Permalink
merge upstream/master
Browse files Browse the repository at this point in the history
  • Loading branch information
iosdev747 committed Nov 6, 2024
2 parents 752ca74 + e5e120c commit 4cdc0ba
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 118 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,20 @@ on:
required: false

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'oracle'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle 5.6.4
uses: gradle/[email protected]
- name: Setup Gradle 8.x
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 5.6.4
gradle-version: "8.10.2"
- name: Execute Gradle build
run: ./gradlew clean build copyDependencies :server:copyJacocoAgent -x test
- name: Build the Docker image
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@ on:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

permissions:
checks: write
pull-requests: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'oracle'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle 5.6.4
uses: gradle/[email protected]
- name: Setup Gradle 8.x
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 5.6.4
gradle-version: "8.10.2"
- name: Execute Gradle build
run: ./gradlew clean build copyDependencies :server:copyJacocoAgent -x test
- name: Prepare mount directory for Web container - to write code coverage file.
Expand All @@ -53,13 +49,12 @@ jobs:
uses: jwalton/gh-docker-logs@v2
with:
images: 'varadhi.docker.registry/varadhi,apachepulsar/pulsar,zookeeper'

- name: Restart the server process to force the code coverage dump
run: docker exec server pkill java
- name: Generate Code Coverage report
run: ./gradlew jacocoTestReport
- name: Publish code coverage (uses CodeCov.io)
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: |
*/build/reports/jacoco/test/jacocoTestReport.xml
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/gradlebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'oracle'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle 5.6.4
uses: gradle/[email protected]
- name: Setup Gradle 8.x
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 5.6.4
gradle-version: "8.10.2"
- name: Execute Gradle build
run: ./gradlew clean build
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ repositories {
}

ext {
lombok_version = "1.18.32"
slf4j_version = "2.0.13"
log4j2_version = "2.23.1"
vertx_version = "4.5.7"

otl_version = "1.37.0"
otl_semconv_version = "1.30.1-alpha"
micrometer_version = "1.12.5"
jersey_version = "3.1.6"
guava_version = "33.1.0-jre"
curator_version = "5.6.0"
jackson_version = "2.17.0"
jakarta_validation_version = "3.0.2"
jakarta_annotation_version = "2.1.1"
jakarta_ws_version = "3.1.0"
commons_lang_version = "3.14.0"
lombok_version = "1.18.34"
slf4j_version = "2.0.16"
log4j2_version = "2.24.1"
vertx_version = "4.5.10"

otl_version = "1.43.0"
otl_semconv_version = "1.28.0-alpha"
micrometer_version = "1.13.6"
jersey_version = "3.1.9"
guava_version = "33.3.1-jre"
curator_version = "5.7.1"
jackson_version = "2.18.1"
jakarta_validation_version = "3.1.0"
jakarta_annotation_version = "3.0.0"
jakarta_ws_version = "4.0.0"
commons_lang_version = "3.17.0"
commons_collections_version = "4.4"
jctools_version = "4.0.3"
jctools_version = "4.0.5"

hibernate_validator_version = "8.0.1.Final"
failsafe_version="3.3.2"

junit_version = "5.10.2"
mockito_version = "5.11.0"
junit_version = "5.11.3"
mockito_version = "5.14.2"
jmh_version = "1.37"
awaitility_version = "4.2.1"
awaitility_version = "4.2.2"
jacoco_version = "0.8.10"
}

sourceSets {
Expand Down Expand Up @@ -90,7 +91,7 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-logging:$otl_version")
implementation("io.opentelemetry:opentelemetry-exporter-otlp:$otl_version")
implementation("io.opentelemetry:opentelemetry-exporter-prometheus:$otl_version-alpha")
implementation("io.opentelemetry:opentelemetry-semconv:$otl_semconv_version")
implementation("io.opentelemetry.semconv:opentelemetry-semconv:$otl_semconv_version")

implementation("io.micrometer:micrometer-core:$micrometer_version")
implementation("io.micrometer:micrometer-registry-otlp:$micrometer_version")
Expand Down Expand Up @@ -137,8 +138,9 @@ dependencies {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
sourceCompatibility = JavaVersion.VERSION_21
}

tasks.register('testE2E', Test) {
Expand All @@ -153,7 +155,7 @@ tasks.register('copyDependencies', Copy) {
}

tasks.withType(JavaCompile).configureEach {
options.release.set(17)
options.release.set(21)
}

tasks.withType(JavaCompile).configureEach {
Expand Down
18 changes: 12 additions & 6 deletions common/src/main/java/com/flipkart/varadhi/utils/HostUtils.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.flipkart.varadhi.utils;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
public class HostUtils {
@Getter
private static String hostName;
@Getter
private static String hostAddress;

public static String getHostName() throws UnknownHostException {
// debug to see how much time it takes, in case DNS resolution is taking time.
log.debug("getHostName: started");
String host = InetAddress.getLocalHost().getHostName();
log.debug("getHostName: completed");
return host;
public static void initHostUtils() throws UnknownHostException {
if(hostName == null) {
hostName = InetAddress.getLocalHost().getHostName();
}
if(hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
}
}
15 changes: 15 additions & 0 deletions common/src/test/java/com/flipkart/varadhi/utils/HostUtilsTest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
package com.flipkart.varadhi.utils;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class HostUtilsTest {

@BeforeAll
public static void init() throws UnknownHostException {
HostUtils.initHostUtils();
}

@Test
public void TestGetHostName() throws UnknownHostException {
// dummy test.. no validations here.
String host = HostUtils.getHostName();
Assertions.assertNotNull(host);
Assertions.assertEquals(InetAddress.getLocalHost().getHostName(), host);
}

@Test
public void TestGetHostAddress() throws UnknownHostException {
// dummy test.. no validations here.
String address = HostUtils.getHostAddress();
Assertions.assertNotNull(address);
Assertions.assertEquals(InetAddress.getLocalHost().getHostAddress(), address);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void preTest() {
@Test
public void testAddConsumerNode() {
MemberInfo memberInfo =
new MemberInfo("Consumer.01", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
new MemberInfo("Consumer.01", "", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
ConsumerInfo consumerInfo = ConsumerInfo.from(memberInfo);
ConsumerNode consumerNode = new ConsumerNode(memberInfo);
doReturn(CompletableFuture.completedFuture(consumerInfo)).when(consumerApi).getConsumerInfo();
Expand All @@ -74,7 +74,7 @@ public void testAddConsumerNode() {
@Test
public void testAddConsumerNodeWhenGetConsumerInfoFailsExceptionally() {
MemberInfo memberInfo =
new MemberInfo("Consumer.01", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
new MemberInfo("Consumer.01", "", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
ConsumerNode consumerNode = new ConsumerNode(memberInfo);
doReturn(CompletableFuture.failedFuture(
new ReplyException(ReplyFailure.NO_HANDLERS, "Host not available."))).when(consumerApi)
Expand All @@ -89,7 +89,7 @@ public void testAddConsumerNodeWhenGetConsumerInfoFailsExceptionally() {
@Test
public void testAddConsumerNodeWhenGetConsumerInfoThrows() {
MemberInfo memberInfo =
new MemberInfo("Consumer.01", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
new MemberInfo("Consumer.01", "", 0, new ComponentKind[]{ComponentKind.Consumer}, new NodeCapacity());
ConsumerNode consumerNode = new ConsumerNode(memberInfo);
doThrow(new RuntimeException("Some unknown failure.")).when(consumerApi).getConsumerInfo();
RuntimeException re =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

public record MemberInfo(
String hostname,
String address,
int port,
ComponentKind[] roles,
NodeCapacity provisionedCapacity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public static List<ConsumerNode> getConsumerNodes(int numNodes) {
public static List<ConsumerNode> getConsumerNodes(int numNodes, NodeCapacity capacity) {
List<ConsumerNode> nodes = new ArrayList<>();
for (int i = 0; i < numNodes; i++) {
nodes.add(new ConsumerNode(new MemberInfo("test.consumer-node." + i, 0, new ComponentKind[]{ComponentKind.Consumer}, capacity)));
nodes.add(new ConsumerNode(new MemberInfo("test.consumer-node." + i, "", 0, new ComponentKind[]{ComponentKind.Consumer}, capacity)));
}
return nodes;
}

public static ConsumerNode getConsumerNode(String nodeName, NodeCapacity capacity) {
return new ConsumerNode(new MemberInfo(nodeName, 0, new ComponentKind[]{ComponentKind.Consumer}, capacity));
return new ConsumerNode(new MemberInfo(nodeName, "", 0, new ComponentKind[]{ComponentKind.Consumer}, capacity));
}

public static NodeCapacity getNodeCapacity(int qps, int throughputKbps) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public synchronized void init(MessagingStackOptions messagingStackOptions, Objec
if (initialised) {
return;
}
String hostName = getHostName();
String hostName = HostUtils.getHostName();
PulsarConfig pulsarConfig = getPulsarConfig(messagingStackOptions.getConfigFile());
TopicPlanner planner = new TopicPlanner(pulsarConfig);
topicFactory = new PulsarTopicFactory(planner);
Expand All @@ -53,15 +53,6 @@ public synchronized void init(MessagingStackOptions messagingStackOptions, Objec
initialised = true;
}

private String getHostName() {
try {
return HostUtils.getHostName();
} catch (UnknownHostException e) {
log.error("Failed to obtain the hostname. {}", e.getMessage());
throw new MessagingException(e);
}
}

public StorageTopicFactory<PulsarStorageTopic> getStorageTopicFactory() {
ensureInitialized();
return topicFactory;
Expand Down
6 changes: 2 additions & 4 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ plugins {
id "jacoco-report-aggregation"
}

def jacoco_version = "0.8.10"

dependencies {

implementation(project(":common"))
Expand Down Expand Up @@ -37,14 +35,14 @@ dependencies {

// TODO: check why still getting warning on class not found.
if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX()) {
runtimeOnly("io.netty:netty-resolver-dns-native-macos:4.1.91.Final:osx-x86_64")
runtimeOnly("io.netty:netty-resolver-dns-native-macos:4.1.114.Final:osx-x86_64")
}

implementation("io.opentelemetry:opentelemetry-sdk")
implementation("io.opentelemetry:opentelemetry-exporter-logging")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
implementation("io.opentelemetry:opentelemetry-semconv")
implementation("io.opentelemetry.semconv:opentelemetry-semconv")

implementation("io.micrometer:micrometer-registry-otlp")
implementation("io.micrometer:micrometer-registry-jmx")
Expand Down
6 changes: 3 additions & 3 deletions server/src/main/java/com/flipkart/varadhi/CoreServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import io.opentelemetry.semconv.ServiceAttributes;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -85,8 +85,8 @@ public static class ObservabilityStack {

public ObservabilityStack(AppConfiguration configuration) {

Resource resource = Resource.getDefault()
.merge(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "com.flipkart.varadhi")));
Resource resource = Resource.getDefault()
.merge(Resource.create(Attributes.of(ServiceAttributes.SERVICE_NAME, "com.flipkart.varadhi")));

// TODO: make tracing togglable and configurable.
float sampleRatio = 1.0f;
Expand Down
Loading

0 comments on commit 4cdc0ba

Please sign in to comment.