updating version along with litmus-proxy unit test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
FROM 193044292705.dkr.ecr.ap-south-1.amazonaws.com/common/maven:3.8.3-openjdk-17-slim as builder
|
||||
ARG ARTIFACT_VERSION=2.0.4-RELEASE
|
||||
ARG ARTIFACT_VERSION=2.0.5-SNAPSHOT
|
||||
RUN mkdir -p /build
|
||||
WORKDIR /build
|
||||
COPY . /build
|
||||
@@ -7,7 +7,7 @@ RUN mvn clean install
|
||||
RUN mvn clean verify -DskipTests -Dartifact.version=${ARTIFACT_VERSION}
|
||||
|
||||
FROM 193044292705.dkr.ecr.ap-south-1.amazonaws.com/common/openjdk:17-slim-bullseye
|
||||
ARG ARTIFACT_VERSION=2.0.4-RELEASE
|
||||
ARG ARTIFACT_VERSION=2.0.5-SNAPSHOT
|
||||
RUN mkdir -p /usr/local
|
||||
RUN apt-get update -y && apt-get -y install fontconfig libpng-dev
|
||||
WORKDIR /usr/local/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM 193044292705.dkr.ecr.ap-south-1.amazonaws.com/common/maven:3.8.3-openjdk-17-slim as builder
|
||||
ARG ARTIFACT_VERSION=2.0.4-RELEASE
|
||||
ARG ARTIFACT_VERSION=2.0.5-SNAPSHOT
|
||||
RUN mkdir -p /build
|
||||
WORKDIR /build
|
||||
COPY . /build
|
||||
@@ -7,7 +7,7 @@ RUN mvn clean install -DskipTests
|
||||
RUN mvn clean verify -DskipTests -Dartifact.version=${ARTIFACT_VERSION}
|
||||
|
||||
FROM 193044292705.dkr.ecr.ap-south-1.amazonaws.com/common/openjdk:17-slim-bullseye
|
||||
ARG ARTIFACT_VERSION=2.0.4-RELEASE
|
||||
ARG ARTIFACT_VERSION=2.0.5-SNAPSHOT
|
||||
RUN mkdir -p /usr/local
|
||||
RUN apt-get update -y && apt-get -y install fontconfig libpng-dev
|
||||
WORKDIR /usr/local/
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-cache</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-cache</name>
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-client</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-client</name>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-core</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-core</name>
|
||||
|
||||
@@ -31,25 +31,25 @@
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-db</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-cache</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-util</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -57,17 +57,6 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
@@ -92,7 +81,6 @@
|
||||
<version>1.6.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
server.servlet.context-path=/litmus-core
|
||||
spring.main.banner-mode=off
|
||||
spring.application.name = litmus-core
|
||||
server.port = ${PORT:12000}
|
||||
spring.datasource.hikari.maximum-pool-size=${DB_POOL_MAX_SIZE:2}
|
||||
spring.datasource.hikari.minimum-idle=${DB_POOL_MIN_IDLE:1}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-db</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-db</name>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-liquibase</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-liquibase</name>
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-mock</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-mock</name>
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-client</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-model</name>
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-proxy</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>litmus-proxy</name>
|
||||
|
||||
@@ -17,13 +17,19 @@
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-model</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-client</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<artifactId>litmus-util</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -33,21 +39,16 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>1.6.8</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.navi.medici;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.navi.medici"})
|
||||
public class LitmusProxyApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.navi.medici.model.request.v1.FetchBatchExperimentRequest;
|
||||
import com.navi.medici.model.request.v1.FetchBatchVariantRequest;
|
||||
import com.navi.medici.service.LitmusService;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -18,10 +19,13 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/v1/proxy")
|
||||
@Log4j2
|
||||
public record LitmusProxyController(Litmus litmus, LitmusService litmusService) {
|
||||
@RequiredArgsConstructor
|
||||
public class LitmusProxyController {
|
||||
|
||||
private final LitmusService litmusService;
|
||||
|
||||
@GetMapping(value = "/experiment", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Timed(value = "litmus.proxy.fetch.experiment", percentiles = {0.95, 0.99}, extraTags = {"mt", "fetch"} )
|
||||
@Timed(percentiles = {0.95, 0.99}, extraTags = {"mt", "fetch"} )
|
||||
public ResponseEntity<?> fetch(@RequestParam("name") String experimentName) {
|
||||
var result = litmusService.fetchExperimentResponse(experimentName);
|
||||
|
||||
@@ -29,7 +33,7 @@ public record LitmusProxyController(Litmus litmus, LitmusService litmusService)
|
||||
}
|
||||
|
||||
@GetMapping(value = "/variant", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Timed(value = "litmus.proxy.fetch.experiment", percentiles = {0.95, 0.99}, extraTags = {"mt", "fetchVariants"})
|
||||
@Timed(percentiles = {0.95, 0.99}, extraTags = {"mt", "fetchVariants"})
|
||||
public ResponseEntity<?> fetchVariants(@RequestParam("name") String variantName) {
|
||||
var variant = litmusService.fetchVariant(variantName);
|
||||
|
||||
@@ -37,6 +41,7 @@ public record LitmusProxyController(Litmus litmus, LitmusService litmusService)
|
||||
}
|
||||
|
||||
@PostMapping(value = "/batch/experiments", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Timed(percentiles = {0.95, 0.99}, extraTags = {"mt", "fetchBatchExperiment"})
|
||||
public ResponseEntity<?> fetchBatchExperiment(@RequestBody FetchBatchExperimentRequest fetchBatchExperimentRequest) {
|
||||
var response = litmusService.batchExperimentResponse(fetchBatchExperimentRequest);
|
||||
|
||||
@@ -44,6 +49,7 @@ public record LitmusProxyController(Litmus litmus, LitmusService litmusService)
|
||||
}
|
||||
|
||||
@PostMapping(value = "/batch/variants", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Timed(percentiles = {0.95, 0.99}, extraTags = {"mt", "fetchBatchVariantExperiment"})
|
||||
public ResponseEntity<?> fetchBatchVariantExperiment(@RequestBody FetchBatchVariantRequest fetchBatchVariantRequest) {
|
||||
var response = litmusService.batchVariantResponse(fetchBatchVariantRequest);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
spring.main.banner-mode=off
|
||||
server.port=${PORT:13000}
|
||||
server.servlet.context-path=/litmus-proxy
|
||||
spring.application.name = litmus-proxy
|
||||
|
||||
management.server.port=4001
|
||||
management.endpoints.web.exposure.include=prometheus,health,info,metric,heapdump,threaddump
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.navi.medici.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.navi.medici.litmus.Litmus;
|
||||
import com.navi.medici.model.request.v1.ExperimentResponse;
|
||||
import com.navi.medici.model.request.v1.ExperimentVariantResponse;
|
||||
import com.navi.medici.model.request.v1.FetchBatchExperimentRequest;
|
||||
import com.navi.medici.model.request.v1.FetchBatchVariantRequest;
|
||||
import com.navi.medici.variants.Variant;
|
||||
import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class LitmusServiceImplTest {
|
||||
@Mock
|
||||
Litmus litmus;
|
||||
|
||||
@InjectMocks
|
||||
LitmusServiceImpl litmusService;
|
||||
|
||||
@Test
|
||||
public void testBatchExperimentResponse() {
|
||||
var request = FetchBatchExperimentRequest.builder()
|
||||
.experimentNames(List.of("dummy-1", "dummy-2"))
|
||||
.build();
|
||||
var response = litmusService.batchExperimentResponse(request);
|
||||
|
||||
response.stream().map(ExperimentResponse::getResult).forEach(Assert::assertFalse);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchExperimentResponse100Rollout() {
|
||||
var request = FetchBatchExperimentRequest.builder()
|
||||
.experimentNames(List.of("dummy-1", "dummy-2"))
|
||||
.build();
|
||||
when(litmus.isEnabled(anyString())).thenReturn(true);
|
||||
|
||||
var response = litmusService.batchExperimentResponse(request);
|
||||
|
||||
response.stream().map(ExperimentResponse::getResult).forEach(Assert::assertTrue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleExperimentResponse() {
|
||||
when(litmus.isEnabled(anyString())).thenReturn(true);
|
||||
|
||||
var response = litmusService.fetchExperimentResponse("random-string");
|
||||
|
||||
assertTrue(response.getResult());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVariant() {
|
||||
when(litmus.getVariant(anyString())).thenReturn(Variant.builder()
|
||||
.name("test-variant-name")
|
||||
.build());
|
||||
|
||||
var response = litmusService.fetchVariant("random-variant");
|
||||
|
||||
assertEquals(response.getVariant().getName(), "test-variant-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchVariant() {
|
||||
var request = FetchBatchVariantRequest.builder()
|
||||
.experimentNames(List.of("dummy-1", "dummy-2"))
|
||||
.build();
|
||||
|
||||
when(litmus.getVariant(anyString())).thenReturn(Variant.builder().build());
|
||||
var response = litmusService.batchVariantResponse(request);
|
||||
|
||||
response.stream()
|
||||
.map(ExperimentVariantResponse::getVariant)
|
||||
.map(Variant::isEnabled)
|
||||
.forEach(Assert::assertFalse);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
<parent>
|
||||
<artifactId>litmus</artifactId>
|
||||
<groupId>com.navi.medici</groupId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>litmus-util</artifactId>
|
||||
<version>2.0.4-RELEASE</version>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
|
||||
<name>litmus-util</name>
|
||||
|
||||
@@ -16,13 +16,19 @@
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<version>1.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -3,21 +3,27 @@ package com.navi.medici.metrics;
|
||||
import com.navi.medici.exceptions.LitmusException;
|
||||
import io.micrometer.core.aop.TimedAspect;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Component
|
||||
@Configuration
|
||||
public class MetricsRegistry {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
@Bean
|
||||
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
|
||||
InetAddress inetAddress = inetAddress();
|
||||
return registry -> registry.config()
|
||||
.commonTags("app.name", "litmus")
|
||||
.commonTags("app.name", appName)
|
||||
.commonTags("host.ip", inetAddress.getHostAddress().trim())
|
||||
.commonTags("host.name", inetAddress.getHostName().trim());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user