This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| class SumNumbersConfiguration { | |
| @Bean | |
| fun generateNumbers(): Supplier<Message<String>> = Supplier<Message<String>> { | |
| val randomNumber1 = Random.nextInt(100) | |
| val randomNumber2 = Random.nextInt(100) | |
| print("$randomNumber1+$randomNumber2=") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
| plugins { | |
| id("org.springframework.boot") version "2.6.9" | |
| id("io.spring.dependency-management") version "1.0.11.RELEASE" | |
| kotlin("jvm") version "1.6.21" | |
| kotlin("plugin.spring") version "1.6.21" | |
| } | |
| group = "com.raphaeldelio" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RunWith(SpringRunner::class) | |
| @SpringBootTest | |
| @ContextConfiguration( | |
| initializers = [ | |
| GoogleCloudStorageTestContainerInitializer::class | |
| ] | |
| ) | |
| class GcsIntegrationApplicationTests { | |
| @Autowired |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * This configuration is used to override the default Google Cloud Storage client with the one created by Testcontainers. | |
| */ | |
| @Configuration | |
| class GoogleCloudStorageConfiguration { | |
| @Value("\${gcs.port}") | |
| private lateinit var gcsContainerPort: String | |
| @Bean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open class GoogleCloudStorageTestContainerInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> { | |
| private lateinit var container: GoogleCloudStorageTestContainer | |
| override fun initialize(configurableApplicationContext: ConfigurableApplicationContext) { | |
| container = createContainer() | |
| container.start() | |
| applyConfiguration(configurableApplicationContext) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * [GoogleCloudStorageTestContainer] is a [GenericContainer] that provides a Google Cloud Storage service. | |
| */ | |
| class GoogleCloudStorageTestContainer : GenericContainer<GoogleCloudStorageTestContainer>( | |
| DockerImageName.parse("fsouza/fake-gcs-server") | |
| ) { | |
| init { | |
| withExposedPorts(4443) | |
| withCreateContainerCmdModifier { | |
| it.withEntrypoint("/bin/fake-gcs-server", "-scheme", "http") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @SpringBootApplication | |
| @EnableScheduling | |
| class GcsIntegrationApplication( | |
| private val storage: Storage | |
| ) { | |
| @Scheduled(fixedDelay = 100) | |
| fun schedule() { | |
| mkdirs() | |
| downloadFiles() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: heartbeat | |
| namespace: monitoring | |
| labels: | |
| k8s-app: heartbeat | |
| spec: | |
| selector: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| kind: ConfigMap | |
| metadata: | |
| name: heartbeat-deployment-config | |
| namespace: monitoring | |
| labels: | |
| k8s-app: heartbeat | |
| data: | |
| heartbeat.yml: |- | |
| heartbeat.monitors: |