Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gradle
build
gradle
18 changes: 17 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* groovylint-disable DuplicateListLiteral, DuplicateMapLiteral, DuplicateNumberLiteral */
// groovylint-disable DuplicateStringLiteral, NestedBlockDepth, VariableName
/* Copyright 2019-2024 Intel Corporation
* Copyright 2025 Hewlett Packard Enterprise Development LP
* Copyright 2025-2026 Hewlett Packard Enterprise Development LP
* All rights reserved.
*
* This file is part of the DAOS Project. It is subject to the license terms
Expand Down Expand Up @@ -143,6 +143,22 @@ pipeline {
expression { !skipStage() }
}
parallel {
stage('JUnit Tests') {
agent {
label 'JUnit_jdk_tests'
}
steps {
sh '''
./gradle-init.sh
./gradle spotlessCheck test --no-daemon
'''
}
post {
always {
junit 'build/test-results/test/*.xml'
}
}
}
stage('daosLatestVersion() tests') {
steps {
script {
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,25 @@ upload to validate.

The publishToRepositorySystem step should download the artifacts back to
this directory and fail the step if the contents differ.

## Unit tests

Requirements:

- JDK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Install gradle

It makes things easier if we ensure everyone uses the same version of Gradle, including in CI.

**Note**: We decided not to use gradlew to avoid committing a binary blob to the repository.

From the main directory, run:

```sh
./gradle-init.sh
'''

If it succeeds, you’ll find a `gradle` symbolic link in the main directory, which you can use like a normal Gradle installation.

### How to run unit tests

From the main directory, run:

```bash
gradlew test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gradlew test
./gradle test

```

## Formatting

**Note**: Not all Groovy files are covered yet. You are very welcome to include more though. Please see (build.gradle)[build.gradle].

```sh
gradlew spotlessApply
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gradlew spotlessApply
./gradle spotlessApply

```
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/

plugins {
id 'groovy'
id 'com.diffplug.spotless' version 'latest.release'
}

repositories {
mavenCentral()
}

dependencies {
implementation localGroovy()
testImplementation localGroovy()
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.0'
}

spotless {
groovy {
target 'src/test/**/*.groovy'
importOrder()
endWithNewline()
greclipse().configFile(rootProject.file('greclipse.properties'))
}
groovyGradle {
target '*.gradle'
endWithNewline()
greclipse().configFile(rootProject.file('greclipse.properties'))
}
}

test {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed', 'started'
exceptionFormat = 'full'
showStandardStreams = true
}
outputs.upToDateWhen { false }
}
39 changes: 39 additions & 0 deletions gradle-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
#
# Copyright 2026, Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
set -euo pipefail

DIST_FILE='gradle-9.0-bin.zip'
DIST_URL="https://artifactory.daos.hpc.amslabs.hpecorp.net/artifactory/gradle-services-proxy/distributions/$DIST_FILE"
DIST_DIR='gradle-9.0.0' # it must match the name of the directory stored inside the ZIP

GRADLE_USER_HOME='.gradle'

mkdir -p "$GRADLE_USER_HOME"

DIR="$GRADLE_USER_HOME/$DIST_DIR"
BIN="$DIR/bin/gradle"
if [ -f "$BIN" ]; then
echo "WARN: '$BIN' is already there."
echo
echo "Remove '$DIR' if you want to download it again."
else
# download and unzip
cd "$GRADLE_USER_HOME"
wget "$DIST_URL"
unzip "$DIST_FILE"
rm "$DIST_FILE"
cd -

if [ ! -f "$BIN" ]; then
echo "ERROR: There is no '$BIN' file in '$DIST_URL'."
exit 1
fi
fi

SYM=gradle
rm -f $SYM
ln -s "$BIN" $SYM
34 changes: 34 additions & 0 deletions greclipse.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#Whether to use 'space', 'tab' or 'mixed' (both) characters for indentation.
#The default value is 'tab'.
org.eclipse.jdt.core.formatter.tabulation.char=space

#Number of spaces used for indentation in case 'space' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.tabulation.size=4

#Number of spaces used for indentation in case 'mixed' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.indentation.size=4

#Whether or not indentation characters are inserted into empty lines.
#The default value is 'true'.
org.eclipse.jdt.core.formatter.indent_empty_lines=false

#Number of spaces used for multiline indentation.
#The default value is 2.
groovy.formatter.multiline.indentation=1

#Length after which list are considered too long. These will be wrapped.
#The default value is 30.
groovy.formatter.longListLength=30

#Whether opening braces position shall be the next line.
#The default value is 'same'.
groovy.formatter.braces.start=same

#Whether closing braces position shall be the next line.
#The default value is 'next'.
groovy.formatter.braces.end=next

#Remove unnecessary semicolons. The default value is 'false'.
groovy.formatter.remove.unnecessary.semicolons=true
14 changes: 14 additions & 0 deletions src/test/groovy/helpers/Asserts.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* (C) Copyright 2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/

package helpers

class Asserts {

static void assertIsSubset(Map subset, Map set) {
assert subset.every { k, v -> set[k] == v } : subset + ' is not a subset of ' + set
}
}
34 changes: 34 additions & 0 deletions src/test/groovy/helpers/Bindings.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* (C) Copyright 2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/

package helpers

import groovy.lang.Binding

class Bindings {

static void commonBindings(Binding binding) {
binding.setVariable('sh', { Map m ->
if (m.returnStdout) {
return ''
}
return 0
})

binding.setVariable('timeout', { Map m, Closure c ->
c()
})

binding.setVariable('stash', { Map m -> })
binding.setVariable('writeYaml', { Map m -> })
binding.setVariable('httpRequest', { Map m -> })
binding.setVariable('fileOperations', { List l -> })
binding.setVariable('fileCopyOperation', { Map m -> [:] })
binding.setVariable('catchError', { Map m, Closure c -> c() })
binding.setVariable('error', { String s -> })
binding.setVariable('echo', { String s -> })
}
}
Loading