JavaOne – Maven BOF

“Maven 5 BOF”

Speaker: Brian Fox, Manfred Moser & Robert Scholte

For more blog posts from JavaOne, see the table of contents


[I was late because we talked more about JUnit 5 after the BOF]

Only 26.4% of Maven Central traffic is from Maven. Nothing else is more than 10% though; not even Ivy or Gradle

Some projects don’t have snapshots; instead every commit is a release

Talked about version ranges. Depends on proximity to your project rather than the latest version. Important to clean up pom dependencies before Java 9 so not in module path. Use Maven dependency plugin (analyze) to find unused ones. Make sure to use latest version of depedency plugin.

Maven won’t generate module descriptor. Different purpose. Not all modules are dependencies. More info in module descriptor. What to export is a decision that needs to be decided by developer. jdeps can generate a rough descriptor to get started based on binaries.

Can have .mvn file inside projects with preferences startig in Maven 3.3.5. For example, you can specify to provide more memory.

Shouldn’t be issues going from 3.3.5 to 3.5.9

Maven (dependency) resolver is now a standalone project

JavaOne – JUnit 5 BOF

“JUnit 5 BOF”

Speaker: Sam Brannen

For more blog posts from JavaOne, see the table of contents


Sam invited us other JUnit presenters at JavaOne to sit on stage with him as a panel. Which was cool. I ot to sit on stage in a Moscone West room!

Sam reviewed/completed from his session earlier today

  • Tests package private
  • Create strings for message in lambda if have on where slow
  • assert timeout
  • Eclipse releases non beta support next week
  • assert all
  • nested tests – good for BDD style so can read as outline/steps with indentation in test report. there’s also an example of the bowling game where the indentation and display names make it easier to follow the output
  • Repeated tests
  • Parameterized tests – values, csv and method sources. Someone wrote an extension for a json source
  • dynamic tests – use lambdas
  • For future releases of JUnit – scenario tests (like in TestNG) where don’t do later steps if earlier fail, test ordering (good for integration tests), parallel execution, option to have new or existing instance for multiple tests, executing in user defined theads, declaration test suites for junit platform (declare which tests to run based on annotations)
  • The name JUnit sucks because we write many types of tests
  • Order of tests is based on hash code of method name since JUnit 4.8. Jupiter would give options.
  • Eclipse only provides a few options to customize which tests run. Maven/Gradle have more
  • Spring 5 – released last week, supports existing features and constructor/method injection, conditional test execution using SpEL expressions (can disable test by OS or date or other conditions – @EnabledIf/@DisabledIf, @ExtendWith(SpringExtension.class) so can use with Mockito or other former runner. @SpringJUnitConfig/@SpringJUnitWebConfig combines spring extension with spring config

Steve Moyer plugged the side project JUnit Pioneer for ope source extensions. Will be building extensions for the JUnit 4 rules that don’t have JUnit 5 equivalents. Also serves as an incubator for JUnit core. Has beta plugin for pi test.

JUnit 5 samples repo shows how to start with Gradle/Maven. Surefire team had non backward compatible change which is why need 2.19 to work. Later version of JUnit 5 will require 2.21+ to avoid this issue.

Starting surefire 2.20, recommend *Tests instead of *Test.

JavaOne – Docker, Kubernetes & Open Shift

“Project Jigsaw – Integration with Tools”

Speaker: Marek Jelen & Diogenes Rettori

Sponsored session by RedHat [I didn’t know they had sponsored sessions; I asked if they applied to JavaOne or Oracle Open World and they said neither; they paid. I was curious why they were JavaOne and yet had laptops provided by Oracle. That explains why three sessions of this class were offered.]

For more blog posts from JavaOne, see the table of contents


Can do self paced tutorials in cloud install at https://learn.openshift.com

[Nice assortment of shipping container pictures on the screen as he reviews what Docker/Kubernetes are for and why this matters. A bit of preaching to the choir here…]

“Very diverse community of contributors” The top six contributors are all from Google and RedHat. (except one who move to Microsoft) [sounds more like a strong partnership than a diverse community]

Open Shift and Kubernetes

  • OpenShift is an enterprise version of Kubernetes with extra stuff.
  • OpenShift 3.6 in lab
  • Can use kubectl with Open Shift cluster
  • OpenShift sometimes uses own version of Kubernetes objects and wrap others
  • RHEL (red hat enterprise linux) has master and nodes.
  • Nodes used to be called minions.
  • Works with cloud and non-cloud deployments
  • OpenShift adds Developer CLI,, Admin CLI, web console, REST APIs, creating an image from source, authentication and users/groups from LDAP, Also wrap namespace in a project and more

Workshop

bit.ly/javaoneworkshop

http://content-workshop.apps.javaone3.gce.pixy.io/index.html#/workshop/training/module/install

I’ve read about and played with Kubernetes. I didn’t realize OpenShift was Kubernetes with different commands.

Concepts from lab

  • pod – smallest deployable unit
  • service – group of pods
  • replication controllers – ensure correct number of pods exist
  • deployment configuration – how should be configured
  • horizonal pod auto scaler – monitors CPU and scales. See here
  • route – so external clients can access
  • service account – non-user account, get one by default

Commands in lab

  • oc login url – to login
  • oc get x – basic info
  • oc get x -o yaml – more detail in yaml
  • oc describe service x – even more detail
  • oc scale –replicas=x y – or can click up arrow in UI
  • oc delete pod x – to delete
  • oc expose service x – to create route
  • oc logs x – view logs
  • oc policy add-role-to-user view -z default – grant access to view for default user
  • oc policy add-role-to-user view user1 – grant access to view for user1

In UI

  • Add project > docker
  • Change number of replicas with up/down arrows once expand overview
  • View logs by clicking “…” on overview
  • Add project > catalog > python – use source to image so can go straight from github source code

Real world

  • 18% adults have anxiety problems
  • “not all anxiety is bad” depends on the task; issue on more complex/unfamiliar/difficult tasks
  • 20% of downtime is caused by tech failure or natural disasters. Rest caused by people
  • batch size – amount of features in a release

A/B Deployment demo

  • installed Node.JS app directly from github
  • then created a separate app from github. (so now have two apps in open shift)
  • edit route in open shift console to divide traffic between the two services. can choose percentages/weights
  • changed RAM; did rolling deployment so old one stays up until new one is ready

My take: We immediately had a problem because the laptop was setup differently than the lab; odd. not a big deal to type ./oc instead of oc. But that seems easy for them to have fixed in the VM. then the project we were supposed to switch to we were already on. then it says to login with your email vs the name we were given. I’ll stop commenting on the differences now, but this clearly wasn’t written for or tested for JavaOne. It even refers to “in the morning session” for how you find out what a pod is. I asked and they said this was written to be a full day of training. So glad that I’ve already read about Kubernetes and was able to follow it anyway. I like when they showed how to do the same task in both the UI and at the command line

[I did 9/12 of the labs. It wasn’t that they were bad or long. I was having trouble focusing. It’s 100% self paced and I wasn’t asking any questions. Or learning much. A small percentage of the lab is the UI and the rest I’ve done already with raw Kubernetes. So decided to use the remaining time to check twitter posts about other parts of the conference. I didn’t leave because the last 20 minutes are a demo of something I haven’t seen so wanted to see that.]