Skip to content

Commit

Permalink
Added support for Boot 3 and Framework 6 and CLoud 2022.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Oct 26, 2022
1 parent a454119 commit e420671
Show file tree
Hide file tree
Showing 172 changed files with 11,377 additions and 3,338 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2

[*.java]
indent_style = space
indent_size = 4
continuation_indent_size = 8
ij_java_imports_layout = *,|,javax.**,java.**,|,$*
ij_java_class_count_to_use_import_on_demand = 5
ij_java_names_count_to_use_import_on_demand = 3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ logs
.DS_STORE
out
.vscode/
tempo-data/
Empty file added .springformat
Empty file.
2 changes: 2 additions & 0 deletions .springjavaformatconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java-baseline=8
indentation-style=spaces
6 changes: 4 additions & 2 deletions acceptance-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
}

test {
exclude '**/*.*'
exclude 'io/spring/cloud/**'
}

bootJar.enabled = false
Expand All @@ -30,7 +30,9 @@ task acceptanceTests(type: Test) {
exceptionFormat = 'full'
showStandardStreams = true
}
include '**/*.*'
include 'io/spring/cloud/**'

useJUnitPlatform()

group = "Verification"
description = "Runs the acceptance tests"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package io.spring.cloud.samples.brewery.acceptance;

import io.spring.cloud.samples.brewery.acceptance.common.AbstractBreweryAcceptance;
import io.spring.cloud.samples.brewery.acceptance.common.tech.TestConditions;
import io.spring.cloud.samples.brewery.acceptance.model.CommunicationType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@Disabled
public class SleuthBreweryAcceptanceTests extends AbstractBreweryAcceptance {
public class ObservabilityBreweryAcceptanceTests extends AbstractBreweryAcceptance {
@BeforeEach
public void before() {
TestConditions.assumeSleuth();

}

@Test
public void should_successfully_pass_Trace_Id_via_rest_template() {
// setup:
warm_up_the_environment(() -> check_brewery(CommunicationType.REST_TEMPLATE));
// warm_up_the_environment(() -> check_brewery(CommunicationType.REST_TEMPLATE));
// given:
check_brewery(CommunicationType.REST_TEMPLATE);
}

@Disabled("TODO: Waiting for new release of OpenFeign")
@Test
public void should_successfully_pass_Trace_Id_via_feign() {
// setup:
warm_up_the_environment(() -> check_brewery(CommunicationType.FEIGN));
// warm_up_the_environment(() -> check_brewery(CommunicationType.FEIGN));
// given:
check_brewery(CommunicationType.FEIGN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import io.spring.cloud.samples.brewery.acceptance.model.CommunicationType
import io.spring.cloud.samples.brewery.acceptance.model.IngredientType
import io.spring.cloud.samples.brewery.acceptance.model.Order
import io.spring.cloud.samples.brewery.acceptance.model.ProcessState
import org.junit.runner.RunWith
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand All @@ -43,8 +42,8 @@ import static java.util.concurrent.TimeUnit.SECONDS
@SpringBootTest(classes = TestConfiguration)
abstract class AbstractBreweryAcceptance {

public static final String TRACE_ID_HEADER_NAME = "X-B3-TraceId"
public static final String SPAN_ID_HEADER_NAME = "X-B3-SpanId"
// W3C
public static final String TRACEPARENT_HEADER_NAME = "traceparent"
public static final Logger log = LoggerFactory.getLogger(AbstractBreweryAcceptance)

protected static final List<String> APP_NAMES = ['presenting', 'brewing', 'proxy']
Expand All @@ -67,7 +66,6 @@ abstract class AbstractBreweryAcceptance {
@Value('${zipkin.query.port:9411}') Integer zipkinQueryPort
@Value('${LOCAL_URL:http://localhost}') String zipkinQueryUrl
@Value('${test.zipkin.dependencies:true}') boolean checkZipkinDependencies
@Value('${BOM_VERSION:Greenwich.BUILD-SNAPSHOT}') String bomVersion

def setup() {
log.info("Starting test")
Expand All @@ -92,7 +90,13 @@ abstract class AbstractBreweryAcceptance {
}

void check_brewery(CommunicationType communicationType) {
String referenceProcessId = SpanUtil.idToHex(new Random().nextLong());
/*
base16(version) = 00
base16(trace-id) = 0000000000000000a3ce929d0e0e4736
base16(parent-id) = 00f067aa0ba902b7
base16(trace-flags) = 01 // sampled
*/
String referenceProcessId = "00-0000000000000000" + SpanUtil.idToHex(new Random().nextLong()) + "-" + SpanUtil.idToHex(new Random().nextLong()) + "-01"
RequestEntity requestEntity = an_order_for_all_ingredients_with_process_id(referenceProcessId, communicationType);
// when:
presenting_service_has_been_called(requestEntity);
Expand Down Expand Up @@ -221,14 +225,13 @@ abstract class AbstractBreweryAcceptance {
}

String trace_id_header(HttpEntity httpEntity) {
return httpEntity.headers.getFirst(TRACE_ID_HEADER_NAME)
return httpEntity.headers.getFirst(TRACEPARENT_HEADER_NAME)
}

RequestEntity an_order_for_all_ingredients_with_process_id(String processId, CommunicationType communicationType) {
HttpHeaders headers = new HttpHeaders()
headers.add("PROCESS-ID", processId)
headers.add(TRACE_ID_HEADER_NAME, processId)
headers.add(SPAN_ID_HEADER_NAME, SpanUtil.idToHex(new Random().nextLong()))
headers.add(TRACEPARENT_HEADER_NAME, processId)
headers.add("TEST-COMMUNICATION-TYPE", communicationType.name())
URI uri = URI.create("$presentingUrl/present/order")
Order allIngredients = allIngredients()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.spring.cloud.samples.brewery.acceptance.common;

public enum WhatToTest {
SLEUTH, ZOOKEEPER, CONSUL, EUREKA, SCS, WAVEFRONT;
ZOOKEEPER, CONSUL, EUREKA, WAVEFRONT;

public static final String WHAT_TO_TEST_SYSTEM_PROP = "WHAT_TO_TEST";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ class TestConditions {
)
}

public static final Closure<Boolean> SLEUTH = {
return whatToTestSystemPropMatchesAny(
[WhatToTest.SLEUTH]
)
}

public static final Closure<Boolean> SYSTEM_PROP_IS_VALID = {
return whatToTestSystemPropMatchesAny(WhatToTest.values().toList())
}
Expand All @@ -37,11 +31,6 @@ class TestConditions {
Assume.assumeTrue(SERVICE_DISCOVERY())
}

static void assumeSleuth() {
assumeSystemPropIsValid()
Assume.assumeTrue(SLEUTH())
}

static void assumeSystemPropIsValid() {
Assume.assumeTrue(whatToTestSystemPropMatchesAny(WhatToTest.values ().toList()))
}
Expand All @@ -62,4 +51,4 @@ class TestConditions {
super(msg)
}
}
}
}
1 change: 0 additions & 1 deletion acceptance-tests/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ spring.cloud.zookeeper.enabled: false
spring.cloud.zookeeper.discovery.enabled: false
ribbon.zookeeper.enabled: false
spring.autoconfigure.exclude: org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
spring.zipkin.enabled: false
15 changes: 11 additions & 4 deletions brewing/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
createDockerTaskWithPort(9992)
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
}
implementation project(":common")
implementation "org.springframework.boot:spring-boot-starter-web"
// Why do we need this?
implementation "org.springframework.cloud:spring-cloud-starter-bootstrap"
implementation "org.springframework.cloud:spring-cloud-starter-config"
implementation "org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j"
}

bootRun {
jvmArgs = systemPropsFromGradle()
}
18 changes: 0 additions & 18 deletions brewing/manifest-brewery.yml

This file was deleted.

18 changes: 0 additions & 18 deletions brewing/manifest-docsbrewing.yml

This file was deleted.

14 changes: 0 additions & 14 deletions brewing/manifest-scsbrewery.yml

This file was deleted.

1 change: 0 additions & 1 deletion brewing/manifest.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package io.spring.cloud.samples.brewery;

import io.spring.cloud.samples.brewery.common.TestConfiguration;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;

import io.spring.cloud.samples.brewery.common.TestConfiguration;

@SpringBootApplication
@EnableAsync
@EnableFeignClients
@Import(TestConfiguration.class)
public class Application {
public class BrewingApplication {

public static void main(String[] args) {
new SpringApplication(Application.class).run(args);
}
public static void main(String[] args) {
new SpringApplication(BrewingApplication.class).run(args);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.spring.cloud.samples.brewery.aggregating;

import io.micrometer.tracing.BaggageManager;
import io.spring.cloud.samples.brewery.common.MaturingService;
import io.spring.cloud.samples.brewery.common.TestConfiguration;
import io.spring.cloud.samples.brewery.common.events.EventGateway;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -13,32 +15,27 @@

@Configuration
@Import(TestConfiguration.class)
@EnableConfigurationProperties(IngredientsProperties.class)
class AggregationConfiguration {

@Bean
IngredientsProperties ingredientsProperties() {
return new IngredientsProperties();
}

@Bean
@LoadBalanced
@ConditionalOnMissingBean
public RestTemplate aggregationLoadBalancedRestTemplate() {
return new RestTemplate();
RestTemplate aggregationLoadBalancedRestTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder.build();
}

@Bean
MaturingServiceUpdater maturingServiceUpdater(IngredientsProperties ingredientsProperties,
IngredientWarehouse ingredientWarehouse,
MaturingService maturingService,
EventGateway eventGateway) {
IngredientWarehouse ingredientWarehouse,
MaturingService maturingService,
EventGateway eventGateway) {
return new MaturingServiceUpdater(ingredientsProperties,
ingredientWarehouse, maturingService, eventGateway);
ingredientWarehouse, maturingService, eventGateway);
}

@Bean
IngredientsCollector ingredientsCollector(@LoadBalanced RestTemplate restTemplate,
IngredientsProxy ingredientsProxy) {
return new IngredientsCollector(restTemplate, ingredientsProxy);
IngredientsCollector ingredientsCollector(RestTemplateBuilder restTemplateBuilder,
IngredientsProxy ingredientsProxy, BaggageManager baggageManager) {
return new IngredientsCollector(aggregationLoadBalancedRestTemplate(restTemplateBuilder), ingredientsProxy, baggageManager);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.spring.cloud.samples.brewery.aggregating;

class Collaborators {
public static final String PROXY = "proxy";
public static final String PROXY = "proxy";
}
Loading

0 comments on commit e420671

Please sign in to comment.