feat(Tracer Bullet)

This commit is contained in:
2025-08-11 23:47:05 +02:00
parent 582678e226
commit a50b1b3822
43 changed files with 1665 additions and 292 deletions
+17
View File
@@ -0,0 +1,17 @@
FROM openjdk:17-jre-slim
# Set working directory
WORKDIR /app
# Copy the ping-service JAR file
COPY temp/ping-service/build/libs/*.jar app.jar
# Expose port (will be assigned dynamically by Spring Boot)
EXPOSE 8080
# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=20s --retries=3 \
CMD curl -f http://localhost:8080/ping || exit 1
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]
+33
View File
@@ -0,0 +1,33 @@
// Simple Spring Boot ping service for testing microservice architecture
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependencyManagement)
}
// Configure the main class for the executable JAR
springBoot {
mainClass.set("at.mocode.temp.pingservice.PingServiceApplicationKt")
}
dependencies {
// Ensure all versions come from the central BOM
implementation(platform(projects.platform.platformBom))
// Provide common dependencies
implementation(projects.platform.platformDependencies)
// Spring Boot Web starter for REST endpoints
implementation(libs.spring.boot.starter.web)
// Spring Boot Actuator for health checks
implementation(libs.spring.boot.starter.actuator)
// Spring Cloud Consul for service discovery
implementation(libs.spring.cloud.starter.consul.discovery)
// Testing dependencies
testImplementation(projects.platform.platformTesting)
testImplementation(libs.bundles.testing.jvm)
testImplementation(libs.spring.boot.starter.test)
}
@@ -0,0 +1,13 @@
package at.mocode.temp.pingservice
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
class PingController {
@GetMapping("/ping")
fun ping(): Map<String, String> {
return mapOf("status" to "pong")
}
}
@@ -0,0 +1,11 @@
package at.mocode.temp.pingservice
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class PingServiceApplication
fun main(args: Array<String>) {
runApplication<PingServiceApplication>(*args)
}
@@ -0,0 +1,23 @@
spring:
application:
name: ping-service
cloud:
consul:
host: localhost
port: 8500
discovery:
register: true
health-check-path: /actuator/health
health-check-interval: 10s
server:
port: 8082
management:
endpoints:
web:
exposure:
include: health,info
endpoint:
health:
show-details: always
@@ -0,0 +1,23 @@
package at.mocode.temp.pingservice
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.*
@WebMvcTest(PingController::class)
class PingControllerTest {
@Autowired
private lateinit var mockMvc: MockMvc
@Test
fun `ping endpoint should return pong status`() {
mockMvc.perform(get("/ping"))
.andExpect(status().isOk)
.andExpect(content().contentType("application/json"))
.andExpect(jsonPath("$.status").value("pong"))
}
}