Giter Site home page Giter Site logo

quarkusio / quarkus-workshops Goto Github PK

View Code? Open in Web Editor NEW
173.0 17.0 173.0 638.37 MB

Hosts Quarkus related workshops

Home Page: https://quarkus.io/quarkus-workshops/super-heroes/

License: Apache License 2.0

HTML 84.98% Java 9.47% Shell 2.84% CSS 0.80% JavaScript 1.91%
quarkus

quarkus-workshops's Introduction

Hosts Quarkus related workshops

  • quarkus-workshop-super-heroes: workshop where you build several microservices interoperating through HTTP and Kafka. Instructions are available here.

Configuring a workshop

The entry page of the workshop accepts query parameters.

For example, https://quarkus.io/quarkus-workshops/super-heroes/index.html?native=false&ai=false&kubernetes=false&contract-testing=false&observability=false&extension=false&messaging=false&hideDefined=true will present a minimal workshop with no optional components, but allow people to select an operating system. The hideDefined=true locks and hides options which have been set in the url.

As another example, https://quarkus.io/quarkus-workshops/super-heroes/index.html?os=mac would preconfigure the operating system to MacOS, and show all options.

Continuous Build

Each push and pull requests is checked using GitHub Actions.

quarkus-workshops's People

Contributors

agoncal avatar aureamunoz avatar bitkill avatar cescoffier avatar cvicens avatar dependabot[bot] avatar edeandrea avatar emmanuelbernard avatar famod avatar fdrouet avatar galderz avatar gastaldi avatar geoand avatar holly-cummins avatar jabby avatar karesti avatar lowdoll avatar manekinekko avatar mikrethor avatar oliv37 avatar omasseau avatar psiroky avatar rsvoboda avatar sgitario avatar survivant avatar vsevel avatar wtfjoke avatar xstefank avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quarkus-workshops's Issues

Discuss how to address import ambiguity

In the REST module some imports are not obvious:

  • HeroService

    • REQUIRED
  • HeroResource

    • Logger
    • Response
    • PathParam
  • HeroResourceTest

    • Random
    • CONTENT_TYPE
    • ACCEPT
    • HttpHeaders
    • assertEquals (method)
    • assertTrue (method)
    • assertNotNull (method)
    • get (method)
    • TypeRef
  • HeroService (config):

    • ConfigProperty
  • HeroREsource (OpenAPI):

    • Parameter
    • SchemaType
  • HeroApplication:

    • Application (jax-rs one I think)

Cannot build angular UI due to super pom failure

$ui-super-heroes>
$ mvn install
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/io/quarkus/workshop/super-heroes/super-parent-pom/1.0/super-parent-pom-1.0.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for io.quarkus.workshop.super-heroes:ui-super-heroes:01: Could not find artifact io.quarkus.workshop.super-heroes:sup
er-parent-pom:pom:1.0 in central (https://repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 22, column 13
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project io.quarkus.workshop.super-heroes:ui-super-heroes:01 (/Users/emmanuel/Code/quarkus/demos/workshop/quarkus-workshop-super-heroes/su
per-heroes/ui-super-heroes/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for io.quarkus.workshop.super-heroes:ui-super-heroes:01: Could not find artifact io.quarkus.workshop.super-heroes
:super-parent-pom:pom:1.0 in central (https://repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 22, column 13 ->
 [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Offer a base version of the Villain code to download as zip

Villain is pretty much the same as Hero so people learn nothing (they just increase their muscle memory. Since the lab is huge, I recommend we offer as an option (likely preferred) to fetch a zip with the state of Villain the way we want it

Add an "call to action" icon

Every time that the user must "do" something, an icon should be added. This visual sign should be visible enough so the user can scroll and find them pretty quickly.

Hero test fail after adding OpenAPI

Since in the preceding section we added a lwvel multiplier on persist, the test suite fails as it expect power level of 42 and 42*3 is returned.

Should we ask user to set back level to 1 at the end of the config section?

Add introduction demos

The workshop should start with an introduction about Quarkus and a few demos.

This task is about adding the demos to the repository. The demo could reuse the "hero" microservice.

The demos should cover:

  • project creation
  • live reload
  • REST
  • optionally Panache
  • Native compilation

Prometheus can't acces to localhost on Linux ubuntu

Pour pouvoir le faire communiquer avec le host, sur le service prometheus j'ai ajouté le mode réseau : Host.

ex:
monitoring:
image: "prom/prometheus"
container_name: "super-visor"
network_mode: host
ports:
- 9090:9090

tag::adocVolumePrometheus[]

    volumes:
      - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml

end::adocVolumePrometheus[]

Add a section about the "tracks"

After a common section the workshop is divided into tracks:

  • observability
  • event-driven and reactive
  • fault-tolerance
  • Quarkus extension

An introduction section should describe these and associate them with colors. A small list of the take-away for each track should be also written.

Cannot run Hero native IT

The guide says:
To see the NativeHeroResourceIT run against the native executable, use ./mvnw verify -Pnative:

But I get

INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.quarkus.workshop.superheroes.hero.NativeHeroResourceIT
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 s <<< FAILURE! - in io.quarkus.workshop.superheroes.hero.NativeHeroResourceIT
[ERROR] io.quarkus.workshop.superheroes.hero.NativeHeroResourceIT  Time elapsed: 0.002 s  <<< ERROR!
org.junit.jupiter.engine.execution.ConditionEvaluationException: Failed to evaluate condition [org.testcontainers.junit.jupiter.TestcontainersExtension]: Illegal state: required test class is not present in the current ExtensionContext
Caused by: org.junit.platform.commons.PreconditionViolationException: Illegal state: required test class is not present in the current ExtensionContext

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   NativeHeroResourceIT » ConditionEvaluation Failed to evaluate condition [org.t...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

Creating an invalid item should fail

At the moment, creating an invalid Hero or Villain works and it shouldn't. To test this behavior we have the HeroResourceTest class with a few test cases. The method shouldNotAddInvalidItem creates an invalid hero with a null name and a level of zero, does an HTTP POST and excepts a 400 (but it gets a 201):

    @Test
    void shouldNotAddInvalidItem() {
        Hero hero = new Hero();
        hero.name = null;
        hero.otherName = DEFAULT_OTHER_NAME;
        hero.picture = DEFAULT_PICTURE;
        hero.powers = DEFAULT_POWERS;
        hero.level = 0;

        given()
            .body(hero)
            .header(CONTENT_TYPE, APPLICATION_JSON)
            .header(ACCEPT, APPLICATION_JSON)
            .when()
            .post("/api/heroes")
            .then()
            .statusCode(BAD_REQUEST.getStatusCode());
    }

If you look at the Hero entity it has a @NotNull on name and @Min(1) on level:

@Entity
public class Hero extends PanacheEntity {

    @NotNull
    @Size(min = 3, max = 50)
    public String name;
    public String otherName;
    @NotNull
    @Min(1)
    public int level;

The HeroResource REST Endpoint has a create method that validates and invalid Hero (same for the service):

    @POST
    public Response create(@Valid Hero hero, @Context UriInfo uriInfo) {
        hero = service.createHero(hero);
        UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(hero.id));
        LOGGER.debug("New hero created with URI " + builder.build().toString());
        return Response.created(builder.build()).build();
    }

At the moment the shouldNotAddInvalidItem succeeds but it should fail.

Same for Villain

Improve profile section to show some usages

We can improve the profile section easily by adding some profile settings

  • change the log level for prod
  • change the power level multiplier for test
  • discuss that it's also useful for database and point to the Quarkus doc

The first two would be code examples (part of application.properties).

Don't know how to mock external services

To get two random fighters, the FightService.getRandomFighters() invokes two external microservices: the HeroService and the VillainService:

@ApplicationScoped
@Transactional(SUPPORTS)
public class FightService {

    @Inject
    @RestClient
    HeroService heroService;

    @Inject
    @RestClient
    VillainService villainService;

    public Fighters getRandomFighters() {
        Hero hero = heroService.findRandomHero();
        Villain villain = villainService.findRandomVillain();
        Fighters fighters = new Fighters();
        fighters.setHero(hero);
        fighters.setVillain(villain);
        return fighters;
    }

These services are registered as REST client:

@Path("/api/villains")
@Produces(MediaType.APPLICATION_JSON)
@RegisterRestClient
public interface HeroService {

    @GET
    @Path("/random")
    Hero findRandomHero();
}

To test the getRandomFighters method we need to mock the HeroService and the VillainService. This is done as follow using the @Mock annotation:

@Mock
@ApplicationScoped
public class MockHeroService implements HeroService {

    @Override
    public Hero findRandomHero() {
        Hero hero = new Hero();
        hero.setName(DEFAULT_HERO_NAME);
        hero.setPicture(DEFAULT_HERO_PICTURE);
        hero.setPowers(DEFAULT_HERO_POWERS);
        hero.setLevel(DEFAULT_HERO_LEVEL);
        return hero;
    }
}

But when executing the tests, we get:

org.junit.jupiter.api.extension.TestInstantiationException: TestInstanceFactory [io.quarkus.test.junit.QuarkusTestExtension] failed to instantiate test class [io.quarkus.workshop.superheroes.fight.FightResourceTest]: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 2 deployment problems: 
[1] Unsatisfied dependency for type io.quarkus.workshop.superheroes.fight.client.HeroService and qualifiers [@RestClient]
	- java member: io.quarkus.workshop.superheroes.fight.FightService#heroService
	- declared on CLASS bean [types=[java.lang.Object, io.quarkus.workshop.superheroes.fight.FightService], qualifiers=[@Default, @Any], target=io.quarkus.workshop.superheroes.fight.FightService]
[2] Unsatisfied dependency for type io.quarkus.workshop.superheroes.fight.client.VillainService and qualifiers [@RestClient]
	- java member: io.quarkus.workshop.superheroes.fight.FightService#villainService
	- declared on CLASS bean [types=[java.lang.Object, io.quarkus.workshop.superheroes.fight.FightService], qualifiers=[@Default, @Any], target=io.quarkus.workshop.superheroes.fight.FightService]

Get rid of RegisterForReflection

Looks like we need to add RegisterForReflection on Entities for Native Builds but this shouldn't be mandatory in the coming releases of Quarkus

Get rid of quarkus-resteasy for 0.24.0

quarkus-vertx-http should be enough for ui-super-heroes:

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http</artifactId>
        </dependency>

We should be able to get rid of:

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>

IT uses the wrong profile

IT runs un the default profile at the moment instead of the test profile. It's an issue in Quarkus.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.