Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding CI workflow for Windows OS #262

Closed
wants to merge 14 commits into from
Closed
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
34 changes: 32 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ on:
- "*"

jobs:
build:
linux-build:
strategy:
matrix:
java: [11, 17]

# Job name
name: Build and Test
# This job runs on Linux
runs-on: ubuntu-latest

steps:
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v2

# This step uses the setup-java Github action: https://github.com/actions/setup-java
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
Expand All @@ -37,4 +40,31 @@ jobs:
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
windows-build:
strategy:
matrix:
java: [11, 17]

# Job name
name: Build and Test
# This job runs on Windows
runs-on: windows-latest

steps:
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v2
# This step uses the setup-java Github action: https://github.com/actions/setup-java
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Build and Test
run: |
./gradlew build

- name: Publish to Maven Local
run: |
./gradlew publishToMavenLocal

53 changes: 0 additions & 53 deletions .github/workflows/version.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build
bin/
.classpath
.vscode
sample-extension-plugin/src/test/resources/
4 changes: 2 additions & 2 deletions build-tools/opensearchplugin-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jacocoTestReport {
getSourceDirectories().from(sourceSets.main.allSource)
getClassDirectories().from(sourceSets.main.output)
reports {
html.enabled = true // human readable
xml.enabled = true // for coverlay
html.required = true // human readable
xml.required = true // for coverlay
}
}

Expand Down
14 changes: 13 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.opensearch.gradle.test.RestIntegTestTask

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "2.1.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
}
Expand Down Expand Up @@ -122,6 +122,7 @@ publishing {
pom {
name = "opensearch-job-scheduler"
description = "OpenSearch Job Scheduler plugin"
groupId = "org.opensearch.plugin"
}
}
}
Expand Down Expand Up @@ -302,3 +303,14 @@ afterEvaluate {
}
}
}
// updateVersion: Task to auto increment to the next development iteration
task updateVersion {
onlyIf { System.getProperty('newVersion') }
doLast {
ext.newVersion = System.getProperty('newVersion')
println "Setting version to ${newVersion}."
// String tokenization to support -SNAPSHOT
// Include the required files that needs to be updated with new Version
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Version 2.1.0.0 2022-07-06

Compatible with OpenSearch 2.1.0

### Maintenance
* Bump up the OS version to 2.1. ([#195](https://github.com/opensearch-project/job-scheduler/pull/195))

### Documentation
* Added 2.1 release notes. ([#198](https://github.com/opensearch-project/job-scheduler/pull/198))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Version 2.2.0.0 2022-08-02

Compatible with OpenSearch 2.2.0

### Maintenance
* bump version to 2.2.0 ([#215](https://github.com/opensearch-project/job-scheduler/pull/215))

### Documentation
* Added 2.2 release notes. ([#217](https://github.com/opensearch-project/job-scheduler/pull/217))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Version 2.3.0.0 2022-09-08

Compatible with OpenSearch 2.3.0

### Maintenance
* Removed version.yml ([#233](https://github.com/opensearch-project/job-scheduler/pull/233)) ([#235](https://github.com/opensearch-project/job-scheduler/pull/235))
* Update to Gradle 7.5 ([#208](https://github.com/opensearch-project/job-scheduler/pull/208)) ([#228](https://github.com/opensearch-project/job-scheduler/pull/228))
* Staging for version increment automation ([#204](https://github.com/opensearch-project/job-scheduler/pull/204)) ([#212](https://github.com/opensearch-project/job-scheduler/pull/212))

30 changes: 14 additions & 16 deletions sample-extension-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,36 +127,34 @@ testClusters.integTest {
setting 'path.repo', repo.absolutePath
}

String bwcJobSchedulerVersion = "1.13.0.0"
String baseName = "jobSchedulerBwcCluster"
String bwcOpenSearchVersion = "2.4.0"
String bwcPluginVersion = bwcOpenSearchVersion + ".0"
String bwcFilePath = "src/test/resources/bwc/job-scheduler/"

String bwc_js_download_url = "https://github.com/opendistro-for-elasticsearch/job-scheduler/releases/download/v" +
bwcJobSchedulerVersion + "/job-scheduler-artifacts.zip"
String bwcJobSchedulerPlugin = "job-scheduler-artifacts.zip"
String bwcFileName = "opensearch-job-scheduler-" + bwcPluginVersion + ".zip"
String bwcDownloadUrl = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/" + bwcOpenSearchVersion + "/latest/linux/x64/tar/builds/opensearch/plugins/" + bwcFileName

2.times {i ->
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["7.10.2",opensearch_version]
versions = [bwcOpenSearchVersion, opensearch_version]
numberOfNodes = 3
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
File dir = new File(rootDir.path + "/sample-extension-plugin/" + bwcFilePath + bwcJobSchedulerVersion)

File dir = new File(rootDir.path + "/sample-extension-plugin/" + bwcFilePath + bwcPluginVersion)
if (!dir.exists()) {
dir.mkdirs()
}
File f = new File(dir, bwcJobSchedulerPlugin)
File f = new File(dir, bwcFileName)
if (!f.exists()) {
new URL(bwc_js_download_url).withInputStream{ ins -> f.withOutputStream{ it << ins }}
new URL(bwcDownloadUrl).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
return fileTree(bwcFilePath + bwcJobSchedulerVersion).getSingleFile()
return f
}
}
}
Expand Down Expand Up @@ -191,7 +189,7 @@ task prepareBwcTests {
}
systemProperty 'tests.rest.bwcsuite', 'old_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'old'
systemProperty 'tests.plugin_bwc_version', bwcJobSchedulerVersion
systemProperty 'tests.plugin_bwc_version', bwcPluginVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}$i".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}$i".getName()}")
}
Expand All @@ -211,7 +209,7 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
}
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'first'
systemProperty 'tests.plugin_bwc_version', bwcJobSchedulerVersion
systemProperty 'tests.plugin_bwc_version', bwcPluginVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
}
Expand All @@ -230,7 +228,7 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
}
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'second'
systemProperty 'tests.plugin_bwc_version', bwcJobSchedulerVersion
systemProperty 'tests.plugin_bwc_version', bwcPluginVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
}
Expand All @@ -250,7 +248,7 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
mustRunAfter "${baseName}#mixedClusterTask"
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'third'
systemProperty 'tests.plugin_bwc_version', bwcJobSchedulerVersion
systemProperty 'tests.plugin_bwc_version', bwcPluginVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
}
Expand All @@ -267,7 +265,7 @@ task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
includeTestsMatching "org.opensearch.jobscheduler.sampleextension.bwc.*IT"
}
systemProperty 'tests.rest.bwcsuite', 'upgraded_cluster'
systemProperty 'tests.plugin_bwc_version', bwcJobSchedulerVersion
systemProperty 'tests.plugin_bwc_version', bwcPluginVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}1".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}1".getName()}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package org.opensearch.jobscheduler.sampleextension;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.junit.Assert;
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,12 @@ public void testBackwardsCompatibility() throws Exception {

switch (CLUSTER_TYPE) {
case OLD:
case MIXED:
/*
* as only the old version of job-scheduler plugin is loaded, we only assert that it is loaded.
*/
Assert.assertTrue(pluginNames.contains("opendistro-job-scheduler"));
Assert.assertTrue(pluginNames.contains("opensearch-job-scheduler"));
break;
case MIXED:
/*
* for a 3-node mixedClusterTask, 1st node is upgraded, & 2 remaining nodes still have old versions.
* for a 3-node twoThirdsUpgradedClusterTask, 2 nodes are upgraded, & 1 remaining node still have old versions.
* for a 3-node rollingUpgradeClusterTask, all 3 nodes are upgraded.
* so for first 2 scenarios, we assert, 3rd node still has older version of job-scheduler plugin & 1st/2nd node is upgraded to use latest plugins.
* we cannot trigger a call for scheduling watcher job, as the older nodes do not have sample-extension plugin.
*/
Map<String, Object> responseForOldNode = getAsMap(getPluginUriForMixedCluster("third"));
Map<String, Map<String, Object>> responseMapForOldNode = (Map<String, Map<String, Object>>) responseForOldNode.get("nodes");

for (Map<String, Object> respValuesForOldNode: responseMapForOldNode.values()) {
List<Map<String, Object>> pluginsForOldNode = (List<Map<String, Object>>) respValuesForOldNode.get("plugins");
List<String> pluginNamesForOldNode = pluginsForOldNode.stream().map(plugin -> plugin.get("name").toString()).collect(Collectors.toList());
Assert.assertTrue("third".equals(System.getProperty("tests.rest.bwcsuite_round")) ||
pluginNamesForOldNode.contains("opendistro-job-scheduler"));
}
case UPGRADED:
/*
* As cluster is fully upgraded either by full restart or rolling upgrade, we assert, that all nodes are upgraded to use latest plugins.
Expand Down
20 changes: 16 additions & 4 deletions spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,38 @@ ext {

jacoco {
toolVersion = '0.8.7'
reportsDir = file("$buildDir/JacocoReport")
reportsDirectory = file("$buildDir/JacocoReport")
}

jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
xml.required = false
csv.required = false
html.destination file("${buildDir}/jacoco/")
}
}
check.dependsOn jacocoTestReport

def slf4j_version_of_cronutils = "1.7.30"
dependencies {
compileOnly "org.opensearch:opensearch:${opensearch_version}"
implementation "com.cronutils:cron-utils:9.1.6"
// slf4j is the runtime dependency of cron-utils
// if cron-utils version gets bumped, pls check the slf4j version cron-utils depending on
// and bump if needed
implementation "com.cronutils:cron-utils:9.2.0"
runtimeOnly "org.slf4j:slf4j-api:${slf4j_version_of_cronutils}"

testImplementation "org.opensearch.test:framework:${opensearch_version}"
testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
}

configurations.all {
if (it.state != Configuration.State.UNRESOLVED) return
resolutionStrategy {
force "org.slf4j:slf4j-api:${slf4j_version_of_cronutils}"
}
}

shadowJar {
relocate 'com.cronutils', 'org.opensearch.jobscheduler.repackage.com.cronutils'
relocate 'org.slf4j', 'org.opensearch.jobscheduler.repackage.org.slf4j' // dependency of cron-utils
Expand Down