Create a Status Page

Jan 2024, 25

I do a lot of open source releases in my work.

I have a checklist to verify the necessary services are available by visiting the following status pages:

At UnityFoundation we use Basecamp. Yesterday, Basecamp was suffering a DDOS attack and I visited their status page. It uses Atlassian Statuspage. Atlassian statuspage has a free plan.

Our free plan gives you access to 100 subscribers, 25 components, two team members, two metrics, email notifications, Slack notifications, and access to REST APIs.

Atlassian statuspage is a good option if you need to set up a status page for your service.

WebJars

Jan 2024, 09

WebJars are client-side web libraries (e.g. jQuery & Bootstrap) packaged into JAR (Java Archive) files.

It's a clever project to get started with a Javascript library in a Java project.

Bash Script to run the same test multiple times in a Gradle build

Oct 2023, 17

A flaky test is a software test that yields both passing and failing results despite zero changes to the code or test

#!/bin/bash
EXIT_STATUS=0
NUM_RUNS=100
SUCCESSFUL_RUNS=0
for ((i=1; i<=$NUM_RUNS; i++)); do
  ./gradlew :micronaut-gcp-pubsub:test --tests io.micronaut.gcp.pubsub.integration.SubscriberShutdownSpec --rerun || EXIT_STATUS=$?
  if [ $EXIT_STATUS -ne 0 ]; then
	exit $EXIT_STATUS
  fi
done
exit $EXIT_STATUS

Gradle Java Test Fixtures Plugin

Oct 2023, 03

Gradle Plugin which automatically create a testFixtures source set, in which you can write your test fixtures.

Test fixtures are commonly used to setup the code under test, or provide utilities aimed at facilitating the tests of a component. Java projects can enable test fixtures support by applying the java-test-fixtures plugin, in addition to the java or java-library plugins.

This will automatically create a testFixtures source set, in which you can write your test fixtures. Test fixtures are configured so that:

  • they can see the main source set classes

test sources can see the test fixtures classes

System Stubs

Oct 2023, 03

System Stubs is used to test code which depends on methods in java.lang.System.

@ExtendWith(SystemStubsExtension.class)
class WithEnvironmentVariables {
	@SystemStub
	private EnvironmentVariables variables = new EnvironmentVariables("input", "foo");

	@Test
	void hasAccessToEnvironmentVariables() {
		assertThat(System.getenv("input")).isEqualTo("foo");
	}

	@Test
	void changeEnvironmentVariablesDuringTest() {
		variables.set("input", "bar");
		assertThat(System.getenv("input")).isEqualTo("bar");
	}
}

Method to check if GraalVM JDK Distribution

Sep 2023, 21

Method to check if you are running in GraalVM JDK distribution. I have used it often in Gradle build files to decide whether a Gradle task should be enabled.

private static boolean isGraalVMJava() {
    return
        (System.getProperty("java.home") != null && java.nio.file.Files.exists(java.nio.file.Paths.get("${System.getProperty("java.home")}/lib/graalvm")))
        || Arrays.asList("jvmci.Compiler", "java.vendor.version", "java.vendor")
            .stream()
            .anyMatch(propertyName -> {
                String value = System.getProperty(propertyName);
                return value != null && value.toLowerCase(Locale.ENGLISH).contains("graal");
            });
}