Skip to content

Commit

Permalink
Add tests for create starter
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Feb 4, 2025
1 parent 3b4f7c7 commit 0bfff9e
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 2 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/build-test-create-starter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2025 Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.

# ---------------------------------------------------------------------------
# Coherence CLI GitHub Actions CI build - Test Create Starter
# ---------------------------------------------------------------------------
name: CI Test Create Starter

on:
workflow_dispatch:
push:
branches-ignore:
- gh-pages

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
javaVersion:
- 21
- 22

# Checkout the source, we need a depth of zero to fetch all of the history otherwise
# the copyright check cannot work out the date of the files from Git.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.javaVersion }}
distribution: 'zulu'

- name: Cache Go Modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mods-
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Build cohctl
shell: bash
run: make cohctl

- name: Setup Gradle and Run Create Cluster Tests
shell: bash
run: |
DIR=`pwd`
INSTALL=${DIR}/gradle-install
mkdir -p ${DIR}/gradle-home ${INSTALL}
VERSION=7.4.2
wget -q -c https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P ${INSTALL}
ls -l ${INSTALL}
unzip -d ${DIR}/gradle-home ${INSTALL}/gradle-${VERSION}-bin.zip
export GRADLE_HOME=${DIR}/gradle-home/gradle-${VERSION}
export PATH=$GRADLE_HOME/bin:$PATH
COHERENCE_VERSION=${{ matrix.coherenceVersion }} make test-create-cluster
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-output-${{ matrix.coherenceVersion }}
path: build/_output/test-logs
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ test-discovery: test-clean gotestsum $(BUILD_PROPS) ## Run Discovery tests with
test-create-cluster: test-clean gotestsum $(BUILD_PROPS) ## Run create cluster tests
./scripts/test-create-cluster.sh $(COHERENCE_VERSION)

# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go create starter tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-create-starter
test-create-starter: test-clean $(BUILD_PROPS) ## Run create starter tests
./scripts/test-create-starter.sh

# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go monitor cluster tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const (
framework = "framework"
frameworkURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/templates"
frameworkTypesURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/templates/templates.yaml"
frameworkTypesURL = frameworkURL + "/templates.yaml"
)

// FrameworkTemplate contains the contents read from the coherence-cli repository.
Expand Down
92 changes: 92 additions & 0 deletions scripts/test-create-starter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

#
# Copyright (c) 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.
#

# Test various command related to creating starter projects
# environment variables COM and COHERENCE_VERSION accepted

pwd


CONFIG_DIR=/tmp/$$.create.starter
DIR=`pwd`
OUTPUT=/tmp/$$.output
STARTER_DIR=`mktemp -d`
LOGS_DIR=$DIR/build/_output/test-logs

mkdir -p ${CONFIG_DIR} ${STARTER_DIR} ${LOGS_DIR}
trap "cp ${CONFIG_DIR}/cohctl.log /tmp && rm -rf ${CONFIG_DIR} $OUTPUT" 0 1 2 3

echo
echo "Config Dir: ${CONFIG_DIR}"
echo "Starter Dir: ${STARTER_DIR}"
echo "Logs Dir: ${LOGS_DIR}"
echo

# Default command
COHCTL="$DIR/bin/cohctl --config-dir ${CONFIG_DIR}"

function runCommand() {
echo "========================================================="
echo "Running command: cohctl $*"
$COHCTL $* > $OUTPUT 2>&1
ret=$?
cat $OUTPUT
if [ $ret -ne 0 ] ; then
echo "Command failed"
# copy the log files
save_logs
exit 1
fi
}

runCommand version

cd ${STARTER_DIR}

function run_test() {
curl -X POST -H "Content-Type: application/json" -d '{"id": 1, "name": "Tim", "balance": 1000}' http://localhost:8080/api/customers
curl -s http://localhost:8080/api/customers/1
curl -s http://localhost:8080/api/customers
curl -X DELETE http://localhost:8080/api/customers/1
}

echo "Testing Helidon Starter"
runCommand create starter helidon-starter -y -f helidon
cd helidon-starter
mvn clean install
java -jar target/helidon.jar > ${LOGS_DIR}/helidon.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..

echo "Testing Spring Boot Starter"
runCommand create starter springboot-starter -y -f springboot
cd springboot-starter
mvn clean install
java -jar target/springboot-1.0-SNAPSHOT.jar > ${LOGS_DIR}/springboot.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..

echo "Testing Micronaut Starter"
runCommand create starter micronaut-starter -y -f micronaut
cd micronaut-starter
mvn clean install
java -jar target/micronaut-1.0-SNAPSHOT-shaded.jar > ${LOGS_DIR}/micronaut.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
public class CustomerResource {

@Inject
@Name("tasks")
private NamedMap<Integer, Customer> customers;

@POST
Expand Down

0 comments on commit 0bfff9e

Please # to comment.