From 675ef7b8148c9f808f448101c1855716557c4636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 12:05:01 +0200 Subject: [PATCH 01/19] etcd --- dependencies.gradle | 4 ++ metadata-drivers/etcd/build.gradle | 45 +++++++++++++++++++ .../metadata/etcd/EtcdMetadataDriverBase.java | 2 +- settings.gradle | 1 + stream/clients/java/all/pom.xml | 2 +- 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 metadata-drivers/etcd/build.gradle diff --git a/dependencies.gradle b/dependencies.gradle index 6b019f814ed..fd842d560ac 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -39,6 +39,7 @@ depVersions = [ dockerJava: "3.2.5", dropwizard: "3.2.5", errorprone: "2.4.0", + etcd: "0.5.4", freebuilder: "2.7.0", googleHTTPClient: "1.34.0", gradleTooling: "4.0.1", @@ -112,6 +113,9 @@ depLibs = [ }, dockerJava: "com.github.docker-java:docker-java:${depVersions.dockerJava}", errorprone: "com.google.errorprone:error_prone_annotations:${depVersions.errorprone}", + etcd: dependencies.create("io.etcd:jetcd-core:${depVersions.etcd}") { + exclude group: 'io.grpc' + }, freebuilder: "org.inferred:freebuilder:${depVersions.freebuilder}", googleHTTPClient: dependencies.create("com.google.http-client:google-http-client:${depVersions.googleHTTPClient}") { exclude group: 'com.google.code.findbugs', module: 'jsr305' diff --git a/metadata-drivers/etcd/build.gradle b/metadata-drivers/etcd/build.gradle new file mode 100644 index 00000000000..eeb9a9d344e --- /dev/null +++ b/metadata-drivers/etcd/build.gradle @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +plugins { + id 'java' +} + +dependencies { + implementation project(":bookkeeper-server") + implementation project(":bookkeeper-common") + implementation project(":bookkeeper-stats") + implementation depLibs.etcd + implementation depLibs.commonsConfiguration + implementation depLibs.grpc + implementation depLibs.zookeeper + + compileOnly depLibs.lombok + + testImplementation depLibs.arquillianCubeDocker + testImplementation depLibs.arquillianJunitStandalone + testImplementation depLibs.testcontainers + testImplementation project(path: ':bookkeeper-common', configuration: 'testArtifacts') + testImplementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') + testImplementation depLibs.dockerJava + testCompileOnly depLibs.lombok + + annotationProcessor depLibs.lombok + testAnnotationProcessor depLibs.lombok + +} diff --git a/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdMetadataDriverBase.java b/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdMetadataDriverBase.java index dec40ad74ac..2938770de85 100644 --- a/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdMetadataDriverBase.java +++ b/metadata-drivers/etcd/src/main/java/org/apache/bookkeeper/metadata/etcd/EtcdMetadataDriverBase.java @@ -17,7 +17,7 @@ */ package org.apache.bookkeeper.metadata.etcd; -import com.beust.jcommander.internal.Lists; +import com.google.common.collect.Lists; import io.etcd.jetcd.Client; import java.io.IOException; import java.util.List; diff --git a/settings.gradle b/settings.gradle index 336afccee3c..f3ef04541e6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -59,6 +59,7 @@ include(':bookkeeper-benchmark', 'cpu-affinity:src:main:affinity', 'dev:release', 'microbenchmarks', + 'metadata-drivers:etcd', 'shaded:distributedlog-core-shaded', 'stats:utils', 'stream:api', diff --git a/stream/clients/java/all/pom.xml b/stream/clients/java/all/pom.xml index 1aa66fd526a..dd95a504ee6 100644 --- a/stream/clients/java/all/pom.xml +++ b/stream/clients/java/all/pom.xml @@ -35,7 +35,7 @@ org.apache.bookkeeper stream-storage-java-client-base ${project.parent.version} - test-jar + *test-jar test From 991bc11720676eef25e7db02768a9ed1fcb13c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 12:17:11 +0200 Subject: [PATCH 02/19] servlet-http-server --- .../servlet-http-server/build.gradle | 44 +++++++++++++++++++ dependencies.gradle | 1 + metadata-drivers/etcd/build.gradle | 10 +++++ settings.gradle | 1 + 4 files changed, 56 insertions(+) create mode 100644 bookkeeper-http/servlet-http-server/build.gradle diff --git a/bookkeeper-http/servlet-http-server/build.gradle b/bookkeeper-http/servlet-http-server/build.gradle new file mode 100644 index 00000000000..ea341bf0f31 --- /dev/null +++ b/bookkeeper-http/servlet-http-server/build.gradle @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + implementation project(':bookkeeper-http:http-server') + implementation depLibs.slf4j + implementation depLibs.javaxServlet + implementation depLibs.commonsIO + + compileOnly depLibs.lombok + annotationProcessor depLibs.lombok + + testImplementation depLibs.junit + testImplementation depLibs.jettyWebapp +} + +publishing { + publications { + maven(MavenPublication) { + groupId = 'org.apache.bookkeeper.http' + artifactId = 'servlet-http-server' + } + } +} diff --git a/dependencies.gradle b/dependencies.gradle index fd842d560ac..570ce8ca3cc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -156,6 +156,7 @@ depLibs = [ jettyServlet: dependencies.create("org.eclipse.jetty:jetty-servlet:${depVersions.jetty}") { exclude group: 'javax.servlet', module: 'javax.servlet-api' }, + jettyWebapp: "org.eclipse.jetty:jetty-webapp:${depVersions.jetty}", jmock: "org.jmock:jmock:${depVersions.jmock}", jmhCore: "org.openjdk.jmh:jmh-core:${depVersions.jmh}", jmhGeneratorAnnprocess: "org.openjdk.jmh:jmh-generator-annprocess:${depVersions.jmh}", diff --git a/metadata-drivers/etcd/build.gradle b/metadata-drivers/etcd/build.gradle index eeb9a9d344e..85af22a04a9 100644 --- a/metadata-drivers/etcd/build.gradle +++ b/metadata-drivers/etcd/build.gradle @@ -18,6 +18,7 @@ */ plugins { id 'java' + id 'com.adarshr.test-logger' } dependencies { @@ -41,5 +42,14 @@ dependencies { annotationProcessor depLibs.lombok testAnnotationProcessor depLibs.lombok +} +publishing { + publications { + maven(MavenPublication) { + groupId = 'org.apache.bookkeeper.metadata.drivers' + artifactId = 'metadata-stores-etcd' + } + } } + diff --git a/settings.gradle b/settings.gradle index f3ef04541e6..f35a3edd4a2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,6 +44,7 @@ include(':bookkeeper-benchmark', 'bookkeeper-dist-src', 'bookkeeper-dist:storage-bench', 'bookkeeper-http:http-server', + 'bookkeeper-http:servlet-http-server', 'bookkeeper-http:vertx-http-server', 'bookkeeper-proto', 'bookkeeper-server', From 2faca014fc06434d5b0d5cf3d5ee08af2e21f238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 13:05:22 +0200 Subject: [PATCH 03/19] bk-grpc-name-resolver --- settings.gradle | 1 + stream/bk-grpc-name-resolver/build.gradle | 54 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 stream/bk-grpc-name-resolver/build.gradle diff --git a/settings.gradle b/settings.gradle index f35a3edd4a2..80c738ba8a7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -71,6 +71,7 @@ include(':bookkeeper-benchmark', 'stream:distributedlog:common', 'stream:distributedlog:core', 'stream:distributedlog:protocol', + 'stream:bk-grpc-name-resolver', 'stream:proto', 'stream:server', 'stream:statelib', diff --git a/stream/bk-grpc-name-resolver/build.gradle b/stream/bk-grpc-name-resolver/build.gradle new file mode 100644 index 00000000000..950bb61724a --- /dev/null +++ b/stream/bk-grpc-name-resolver/build.gradle @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + implementation project(':bookkeeper-server') + implementation project(':bookkeeper-common') + implementation project(':bookkeeper-stats') + implementation project(':stream:common') + implementation depLibs.grpc + implementation depLibs.slf4j + implementation depLibs.commonsConfiguration + + compileOnly depLibs.jsr305 + compileOnly depLibs.lombok + annotationProcessor depLibs.lombok + + testImplementation project(':stream:clients:java:base') + testImplementation project(path: ':bookkeeper-common', configuration: 'testArtifacts') + testImplementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') + testImplementation depLibs.junit + testImplementation depLibs.zookeeper + + testCompileOnly depLibs.lombok + testAnnotationProcessor depLibs.lombok +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'bk-grpc-name-resolver' + } + } +} From 6a243441da6a4cbea40929229129be57f9cff89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 13:10:36 +0200 Subject: [PATCH 04/19] bc-non-fips --- settings.gradle | 1 + .../backward-compat/bc-non-fips/build.gradle | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/backward-compat/bc-non-fips/build.gradle diff --git a/settings.gradle b/settings.gradle index 80c738ba8a7..8519b6705ba 100644 --- a/settings.gradle +++ b/settings.gradle @@ -78,6 +78,7 @@ include(':bookkeeper-benchmark', 'stream:storage:api', 'stream:storage:impl', 'stream:tests-common', + 'tests:backward-compat:bc-non-fips', 'tests:integration-tests-base', 'tests:integration-tests-topologies', 'tests:integration-tests-utils', diff --git a/tests/backward-compat/bc-non-fips/build.gradle b/tests/backward-compat/bc-non-fips/build.gradle new file mode 100644 index 00000000000..b87df1bc510 --- /dev/null +++ b/tests/backward-compat/bc-non-fips/build.gradle @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + + testImplementation project(path: ':bookkeeper-common', configuration: 'testArtifacts') + testImplementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') + testImplementation depLibs.junit + testImplementation depLibs.slf4j + testImplementation depLibs.bcpkixJdk15on + testImplementation depLibs.bcproveExtJdk15on + + testCompileOnly depLibs.lombok + testAnnotationProcessor depLibs.lombok +} + From 8388e11114a85c74bd5add4362c1bfb78878858e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 13:13:01 +0200 Subject: [PATCH 05/19] current-server-old-clients --- settings.gradle | 1 + .../current-server-old-clients/build.gradle | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/backward-compat/current-server-old-clients/build.gradle diff --git a/settings.gradle b/settings.gradle index 8519b6705ba..8ff98f65772 100644 --- a/settings.gradle +++ b/settings.gradle @@ -79,6 +79,7 @@ include(':bookkeeper-benchmark', 'stream:storage:impl', 'stream:tests-common', 'tests:backward-compat:bc-non-fips', + 'tests:backward-compat:current-server-old-clients', 'tests:integration-tests-base', 'tests:integration-tests-topologies', 'tests:integration-tests-utils', diff --git a/tests/backward-compat/current-server-old-clients/build.gradle b/tests/backward-compat/current-server-old-clients/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/current-server-old-clients/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} From 2361f794f7e7024d76b722490a487c36f4ed6404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 13:14:18 +0200 Subject: [PATCH 06/19] hierarchical-ledger-manager --- settings.gradle | 1 + .../hierarchical-ledger-manager/build.gradle | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/backward-compat/hierarchical-ledger-manager/build.gradle diff --git a/settings.gradle b/settings.gradle index 8ff98f65772..6eeea078b45 100644 --- a/settings.gradle +++ b/settings.gradle @@ -80,6 +80,7 @@ include(':bookkeeper-benchmark', 'stream:tests-common', 'tests:backward-compat:bc-non-fips', 'tests:backward-compat:current-server-old-clients', + 'tests:backward-compat:hierarchical-ledger-manager', 'tests:integration-tests-base', 'tests:integration-tests-topologies', 'tests:integration-tests-utils', diff --git a/tests/backward-compat/hierarchical-ledger-manager/build.gradle b/tests/backward-compat/hierarchical-ledger-manager/build.gradle new file mode 100644 index 00000000000..c2e6825c312 --- /dev/null +++ b/tests/backward-compat/hierarchical-ledger-manager/build.gradle @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + + From 08dcc396392b109ec30f6e231a52adfb5b21c349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 13:17:38 +0200 Subject: [PATCH 07/19] backwards --- settings.gradle | 6 +++ .../hostname-bookieid/build.gradle | 37 +++++++++++++++++++ .../old-cookie-new-cluster/build.gradle | 23 ++++++++++++ .../recovery-no-password/build.gradle | 23 ++++++++++++ .../upgrade-direct/build.gradle | 23 ++++++++++++ tests/backward-compat/upgrade/build.gradle | 23 ++++++++++++ .../yahoo-custom-version/build.gradle | 23 ++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 tests/backward-compat/hostname-bookieid/build.gradle create mode 100644 tests/backward-compat/old-cookie-new-cluster/build.gradle create mode 100644 tests/backward-compat/recovery-no-password/build.gradle create mode 100644 tests/backward-compat/upgrade-direct/build.gradle create mode 100644 tests/backward-compat/upgrade/build.gradle create mode 100644 tests/backward-compat/yahoo-custom-version/build.gradle diff --git a/settings.gradle b/settings.gradle index 6eeea078b45..f7ba5e720b9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -81,6 +81,12 @@ include(':bookkeeper-benchmark', 'tests:backward-compat:bc-non-fips', 'tests:backward-compat:current-server-old-clients', 'tests:backward-compat:hierarchical-ledger-manager', + 'tests:backward-compat:hostname-bookieid', + 'tests:backward-compat:old-cookie-new-cluster', + 'tests:backward-compat:recovery-no-password', + 'tests:backward-compat:upgrade', + 'tests:backward-compat:upgrade-direct', + 'tests:backward-compat:yahoo-custom-version', 'tests:integration-tests-base', 'tests:integration-tests-topologies', 'tests:integration-tests-utils', diff --git a/tests/backward-compat/hostname-bookieid/build.gradle b/tests/backward-compat/hostname-bookieid/build.gradle new file mode 100644 index 00000000000..b87df1bc510 --- /dev/null +++ b/tests/backward-compat/hostname-bookieid/build.gradle @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + + testImplementation project(path: ':bookkeeper-common', configuration: 'testArtifacts') + testImplementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') + testImplementation depLibs.junit + testImplementation depLibs.slf4j + testImplementation depLibs.bcpkixJdk15on + testImplementation depLibs.bcproveExtJdk15on + + testCompileOnly depLibs.lombok + testAnnotationProcessor depLibs.lombok +} + diff --git a/tests/backward-compat/old-cookie-new-cluster/build.gradle b/tests/backward-compat/old-cookie-new-cluster/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/old-cookie-new-cluster/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} diff --git a/tests/backward-compat/recovery-no-password/build.gradle b/tests/backward-compat/recovery-no-password/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/recovery-no-password/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} diff --git a/tests/backward-compat/upgrade-direct/build.gradle b/tests/backward-compat/upgrade-direct/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/upgrade-direct/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} diff --git a/tests/backward-compat/upgrade/build.gradle b/tests/backward-compat/upgrade/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/upgrade/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} diff --git a/tests/backward-compat/yahoo-custom-version/build.gradle b/tests/backward-compat/yahoo-custom-version/build.gradle new file mode 100644 index 00000000000..557abe4593c --- /dev/null +++ b/tests/backward-compat/yahoo-custom-version/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.adarshr.test-logger' +} From e0032bc6f71edd3bc595e35ae932686a011a7720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 14:07:06 +0200 Subject: [PATCH 08/19] actually run arquillian groovy tests --- dependencies.gradle | 1 + settings.gradle | 1 + tests/backward-compat/build.gradle | 44 +++++++++++++++++++ .../current-server-old-clients/build.gradle | 4 -- .../hierarchical-ledger-manager/build.gradle | 4 -- .../hostname-bookieid/build.gradle | 18 -------- .../old-cookie-new-cluster/build.gradle | 5 --- .../recovery-no-password/build.gradle | 5 --- .../upgrade-direct/build.gradle | 5 --- tests/backward-compat/upgrade/build.gradle | 5 --- .../yahoo-custom-version/build.gradle | 5 --- 11 files changed, 46 insertions(+), 51 deletions(-) create mode 100644 tests/backward-compat/build.gradle diff --git a/dependencies.gradle b/dependencies.gradle index 570ce8ca3cc..39b65921ede 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -93,6 +93,7 @@ depLibs = [ commonsCli: "commons-cli:commons-cli:${depVersions.commonsCli}", arquillianCubeDocker: "org.arquillian.cube:arquillian-cube-docker:${depVersions.arquillianCubeDocker}", arquillianJunitContainer: "org.jboss.arquillian.junit:arquillian-junit-container:${depVersions.arquillianJunit}", + arquillianJunitCore: "org.jboss.arquillian.junit:arquillian-junit-core:${depVersions.arquillianJunit}", arquillianJunitStandalone: "org.jboss.arquillian.junit:arquillian-junit-standalone:${depVersions.arquillianJunit}", commonsCodec: "commons-codec:commons-codec:${depVersions.commonsCodec}", commonsCollections4: "org.apache.commons:commons-collections4:${depVersions.commonsCollections4}", diff --git a/settings.gradle b/settings.gradle index f7ba5e720b9..3acbf695a19 100644 --- a/settings.gradle +++ b/settings.gradle @@ -78,6 +78,7 @@ include(':bookkeeper-benchmark', 'stream:storage:api', 'stream:storage:impl', 'stream:tests-common', + 'tests:backward-compat', 'tests:backward-compat:bc-non-fips', 'tests:backward-compat:current-server-old-clients', 'tests:backward-compat:hierarchical-ledger-manager', diff --git a/tests/backward-compat/build.gradle b/tests/backward-compat/build.gradle new file mode 100644 index 00000000000..863c12fd690 --- /dev/null +++ b/tests/backward-compat/build.gradle @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'groovy' + id 'com.adarshr.test-logger' +} + +subprojects { + if (project.name == "bc-non-fips") { + return + } + + apply plugin: 'groovy' + apply plugin: 'com.adarshr.test-logger' + + + dependencies { + testImplementation 'org.codehaus.groovy:groovy-all:2.4.15' + testImplementation project(":tests:integration-tests-utils") + testImplementation project(":tests:integration-tests-topologies") + testImplementation depLibs.arquillianJunitContainer + testImplementation depLibs.junit + testImplementation depLibs.slf4j + testImplementation depLibs.arquillianCubeDocker + } + +} \ No newline at end of file diff --git a/tests/backward-compat/current-server-old-clients/build.gradle b/tests/backward-compat/current-server-old-clients/build.gradle index 557abe4593c..bd244d07ab4 100644 --- a/tests/backward-compat/current-server-old-clients/build.gradle +++ b/tests/backward-compat/current-server-old-clients/build.gradle @@ -17,7 +17,3 @@ * under the License. */ -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/hierarchical-ledger-manager/build.gradle b/tests/backward-compat/hierarchical-ledger-manager/build.gradle index c2e6825c312..0392f371268 100644 --- a/tests/backward-compat/hierarchical-ledger-manager/build.gradle +++ b/tests/backward-compat/hierarchical-ledger-manager/build.gradle @@ -17,9 +17,5 @@ * under the License. */ -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/hostname-bookieid/build.gradle b/tests/backward-compat/hostname-bookieid/build.gradle index b87df1bc510..bd244d07ab4 100644 --- a/tests/backward-compat/hostname-bookieid/build.gradle +++ b/tests/backward-compat/hostname-bookieid/build.gradle @@ -17,21 +17,3 @@ * under the License. */ -plugins { - id 'java' - id 'com.adarshr.test-logger' -} - -dependencies { - - testImplementation project(path: ':bookkeeper-common', configuration: 'testArtifacts') - testImplementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') - testImplementation depLibs.junit - testImplementation depLibs.slf4j - testImplementation depLibs.bcpkixJdk15on - testImplementation depLibs.bcproveExtJdk15on - - testCompileOnly depLibs.lombok - testAnnotationProcessor depLibs.lombok -} - diff --git a/tests/backward-compat/old-cookie-new-cluster/build.gradle b/tests/backward-compat/old-cookie-new-cluster/build.gradle index 557abe4593c..042f3ce1f39 100644 --- a/tests/backward-compat/old-cookie-new-cluster/build.gradle +++ b/tests/backward-compat/old-cookie-new-cluster/build.gradle @@ -16,8 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/recovery-no-password/build.gradle b/tests/backward-compat/recovery-no-password/build.gradle index 557abe4593c..042f3ce1f39 100644 --- a/tests/backward-compat/recovery-no-password/build.gradle +++ b/tests/backward-compat/recovery-no-password/build.gradle @@ -16,8 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/upgrade-direct/build.gradle b/tests/backward-compat/upgrade-direct/build.gradle index 557abe4593c..042f3ce1f39 100644 --- a/tests/backward-compat/upgrade-direct/build.gradle +++ b/tests/backward-compat/upgrade-direct/build.gradle @@ -16,8 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/upgrade/build.gradle b/tests/backward-compat/upgrade/build.gradle index 557abe4593c..042f3ce1f39 100644 --- a/tests/backward-compat/upgrade/build.gradle +++ b/tests/backward-compat/upgrade/build.gradle @@ -16,8 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -plugins { - id 'java' - id 'com.adarshr.test-logger' -} diff --git a/tests/backward-compat/yahoo-custom-version/build.gradle b/tests/backward-compat/yahoo-custom-version/build.gradle index 557abe4593c..042f3ce1f39 100644 --- a/tests/backward-compat/yahoo-custom-version/build.gradle +++ b/tests/backward-compat/yahoo-custom-version/build.gradle @@ -16,8 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -plugins { - id 'java' - id 'com.adarshr.test-logger' -} From 6d39e33db5031b548b649f3b81d047d51e0df01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 14:39:18 +0200 Subject: [PATCH 09/19] sh tests --- bin/common.sh | 13 +++--- settings.gradle | 1 + tests/scripts/build.gradle | 43 +++++++++++++++++++ tests/scripts/pom.xml | 3 ++ tests/scripts/src/test/bash/bk_test.sh | 1 + .../src/test/bash/bk_test_bin_common.sh | 6 +-- tests/scripts/src/test/bash/bk_test_helpers | 2 +- 7 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 tests/scripts/build.gradle diff --git a/bin/common.sh b/bin/common.sh index c287535a778..776c64b2ef1 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -61,6 +61,7 @@ else JAVA=${JAVA_HOME}/bin/java fi +PROJECT_TARGET_DIR=${PROJECT_TARGET_DIR:-target} BINDIR=${BK_BINDIR:-"`dirname "$0"`"} BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"} BK_CONFDIR=${BK_HOME}/conf @@ -196,7 +197,7 @@ find_module_jar() { fi if [ -z "${MODULE_JAR}" ]; then - BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME}) + BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME}) if [ -z "${BUILT_JAR}" ]; then echo "Couldn't find module '${MODULE_NAME}' jar." >&2 read -p "Do you want me to run \`mvn package -DskipTests\` for you ? (y|n) " answer @@ -212,7 +213,7 @@ find_module_jar() { ;; esac - BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME}) + BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME}) fi if [ -n "${BUILT_JAR}" ]; then MODULE_JAR=${BUILT_JAR} @@ -237,12 +238,12 @@ add_maven_deps_to_classpath() { # Need to generate classpath from maven pom. This is costly so generate it # and cache it. Save the file into our target dir so a mvn clean will get # clean it up and force us create a new one. - f="${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt" - output="${BK_HOME}/${MODULE_PATH}/target/build_classpath.out" + f="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt" + output="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/build_classpath.out" if [ ! -f ${f} ]; then echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2 echo "see output at ${output} for the progress ..." >&2 - ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &> ${output} + ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="${PROJECT_TARGET_DIR}/cached_classpath.txt" &> ${output} echo "the classpath of module '${MODULE_PATH}' is generated at '${f}'." >&2 fi } @@ -257,7 +258,7 @@ set_module_classpath() { echo ${BK_CLASSPATH} else add_maven_deps_to_classpath ${MODULE_PATH} >&2 - cat ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt + cat ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt fi return } diff --git a/settings.gradle b/settings.gradle index 3acbf695a19..4794b26702a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -94,6 +94,7 @@ include(':bookkeeper-benchmark', 'tests:integration:cluster', 'tests:integration:smoke', 'tests:integration:standalone', + 'tests:scripts', 'tools:framework') project(':bookkeeper-tools').projectDir = file('tools/all') diff --git a/tests/scripts/build.gradle b/tests/scripts/build.gradle new file mode 100644 index 00000000000..ef1fe0243e6 --- /dev/null +++ b/tests/scripts/build.gradle @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +plugins { + id "de.undercouch.download" version "4.1.2" +} + + + +task downloadShunit2(type: Download) { + src 'https://github.com/kward/shunit2/archive/v2.1.7.zip' + dest new File(buildDir, "shunit2-2.1.7.zip") +} + +task extractShunit2(dependsOn: downloadShunit2, type: Copy) { + from zipTree(downloadShunit2.dest) + into new File(buildDir, "lib") +} + +task executeShTests(dependsOn: extractShunit2, type: Exec) { + + workingDir "src/test/bash" + commandLine "./bk_test.sh" + args "build" +} +tasks.test.dependsOn("executeShTests") diff --git a/tests/scripts/pom.xml b/tests/scripts/pom.xml index 4bbc9e80021..daa00cf7aa3 100644 --- a/tests/scripts/pom.xml +++ b/tests/scripts/pom.xml @@ -66,6 +66,9 @@ ${skipTests} ${project.basedir}/src/test/bash ${project.basedir}/src/test/bash/bk_test.sh + + target + diff --git a/tests/scripts/src/test/bash/bk_test.sh b/tests/scripts/src/test/bash/bk_test.sh index 3c7b02e6fe1..20ee97d4c46 100755 --- a/tests/scripts/src/test/bash/bk_test.sh +++ b/tests/scripts/src/test/bash/bk_test.sh @@ -21,6 +21,7 @@ # */ ARGV0=`basename "$0"` +export PROJECT_TARGET_DIR="build" PREFIX="bk_test_" SHELLS="/bin/sh /bin/bash" diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index e41455cbf26..18e898c74bc 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -123,7 +123,7 @@ testFindModuleJar() { TEST_FILES=( "${MODULE}-${VERSION}.jar" "lib/${MODULE}-${VERSION}.jar" - "${MODULE_PATH}/target/${MODULE}-${VERSION}.jar" + "${MODULE_PATH}/${PROJECT_TARGET_DIR}/${MODULE}-${VERSION}.jar" ) count=0 while [ "x${TEST_FILES[count]}" != "x" ] @@ -187,8 +187,8 @@ testSetModuleClasspath() { MODULE_PATH="testmodule" - mkdir -p ${BK_HOME}/${MODULE_PATH}/target - echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt + mkdir -p ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} + echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt local result=$(set_module_classpath ${MODULE_PATH}) assertEquals "test-classpath" ${result} diff --git a/tests/scripts/src/test/bash/bk_test_helpers b/tests/scripts/src/test/bash/bk_test_helpers index 6f43e79d1ac..8620c876d5a 100644 --- a/tests/scripts/src/test/bash/bk_test_helpers +++ b/tests/scripts/src/test/bash/bk_test_helpers @@ -24,7 +24,7 @@ BK_ARGV0=`basename "$0"` # path to shUnit2 library. can be overridden by setting BK_SHUNIT_INC. -BK_SHUNIT=${BK_SHUNIT_INC:-../../../target/lib/shunit2-2.1.7/shunit2} +BK_SHUNIT=${BK_SHUNIT_INC:-../../../${PROJECT_TARGET_DIR}/lib/shunit2-2.1.7/shunit2} # path to bk bin directory. TESTDIR=`dirname "$0"` From ba891324022dba08653dca8a24ebb8845968c720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 15:47:29 +0200 Subject: [PATCH 10/19] shaded tests --- settings.gradle | 2 ++ shaded/bookkeeper-server-shaded/build.gradle | 1 + .../distributedlog-core-shaded/build.gradle | 2 +- .../build.gradle | 29 ++++++++++++++++ .../build.gradle | 33 +++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/shaded/bookkeeper-server-shaded-test/build.gradle create mode 100644 tests/shaded/distributedlog-core-shaded-test/build.gradle diff --git a/settings.gradle b/settings.gradle index 4794b26702a..bca44eb56ec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -95,6 +95,8 @@ include(':bookkeeper-benchmark', 'tests:integration:smoke', 'tests:integration:standalone', 'tests:scripts', + 'tests:shaded:bookkeeper-server-shaded-test', + 'tests:shaded:distributedlog-core-shaded-test', 'tools:framework') project(':bookkeeper-tools').projectDir = file('tools/all') diff --git a/shaded/bookkeeper-server-shaded/build.gradle b/shaded/bookkeeper-server-shaded/build.gradle index 07cee929d9a..d79e7d9b937 100644 --- a/shaded/bookkeeper-server-shaded/build.gradle +++ b/shaded/bookkeeper-server-shaded/build.gradle @@ -30,6 +30,7 @@ dependencies { shadowJar { dependencies { + } relocate 'com.google', 'org.apache.bookkeeper.shaded.com.google' archiveBaseName.set("bookkeeper-server-shaded") diff --git a/shaded/distributedlog-core-shaded/build.gradle b/shaded/distributedlog-core-shaded/build.gradle index 2bafc330aaa..d8306f62701 100644 --- a/shaded/distributedlog-core-shaded/build.gradle +++ b/shaded/distributedlog-core-shaded/build.gradle @@ -26,7 +26,7 @@ plugins { description = 'Apache BookKeeper :: Shaded :: distributedlog-core-shaded' dependencies { - implementation project(':stream:distributedlog:core') + project(':stream:distributedlog:core') } shadowJar { diff --git a/tests/shaded/bookkeeper-server-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-shaded-test/build.gradle new file mode 100644 index 00000000000..c7453bed53b --- /dev/null +++ b/tests/shaded/bookkeeper-server-shaded-test/build.gradle @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + testImplementation depLibs.slf4j + testImplementation depLibs.junit + testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-shaded/', include: ['**/*.jar']) +} + diff --git a/tests/shaded/distributedlog-core-shaded-test/build.gradle b/tests/shaded/distributedlog-core-shaded-test/build.gradle new file mode 100644 index 00000000000..f681150d73c --- /dev/null +++ b/tests/shaded/distributedlog-core-shaded-test/build.gradle @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + testImplementation depLibs.slf4j + testImplementation depLibs.junit + testImplementation depLibs.mockito + testImplementation depLibs.powermockMockito + testImplementation depLibs.powermockJunit + testImplementation depLibs.commonsConfiguration + testImplementation fileTree(dir: '../../../shaded/distributedlog-core-shaded/', include: ['**/*.jar']) +} + From 3bc0b2627fa63b1f5148530d3bb49e79ed07e45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 16:13:24 +0200 Subject: [PATCH 11/19] bookkeeper-server-shaded-tests --- bookkeeper-server/build.gradle | 1 + settings.gradle | 1 + .../build.gradle | 36 +++++++++++++++++++ .../build.gradle | 30 ++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 shaded/bookkeeper-server-tests-shaded/build.gradle create mode 100644 tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle diff --git a/bookkeeper-server/build.gradle b/bookkeeper-server/build.gradle index bdfccc3d69d..60d715006af 100644 --- a/bookkeeper-server/build.gradle +++ b/bookkeeper-server/build.gradle @@ -74,6 +74,7 @@ dependencies { testImplementation depLibs.powermockJunit testImplementation depLibs.powermockMockito testImplementation depLibs.snappy + testImplementation depLibs.zookeeper testImplementation depLibs.zookeeperTest annotationProcessor depLibs.lombok testAnnotationProcessor depLibs.lombok diff --git a/settings.gradle b/settings.gradle index bca44eb56ec..9cdf810a583 100644 --- a/settings.gradle +++ b/settings.gradle @@ -96,6 +96,7 @@ include(':bookkeeper-benchmark', 'tests:integration:standalone', 'tests:scripts', 'tests:shaded:bookkeeper-server-shaded-test', + 'tests:shaded:bookkeeper-server-tests-shaded-test', 'tests:shaded:distributedlog-core-shaded-test', 'tools:framework') diff --git a/shaded/bookkeeper-server-tests-shaded/build.gradle b/shaded/bookkeeper-server-tests-shaded/build.gradle new file mode 100644 index 00000000000..6a3009f6d2c --- /dev/null +++ b/shaded/bookkeeper-server-tests-shaded/build.gradle @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +plugins { + id 'java' + id 'com.github.johnrengelman.shadow' + id 'com.github.hierynomus.license' +} + +dependencies { + implementation project(path: ':bookkeeper-server', configuration: 'testArtifacts') +} + +shadowJar { + dependencies { + } + relocate 'com.google', 'org.apache.bookkeeper.shaded.com.google' + archiveBaseName.set("bookkeeper-server-tests-shaded") + archiveClassifier.set("") +} diff --git a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle new file mode 100644 index 00000000000..9ad1b71b2f9 --- /dev/null +++ b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +plugins { + id 'java' + id 'com.adarshr.test-logger' +} + +dependencies { + testImplementation depLibs.slf4j + testImplementation depLibs.junit + testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-shaded/', include: ['**/*.jar']) + testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-tests-shaded/', include: ['**/*.jar']) +} + From 2c32ac1178e3b47e30ba66c1404c16499f4c1d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 16:18:16 +0200 Subject: [PATCH 12/19] fixes --- bin/common.sh | 2 +- bookkeeper-server/build.gradle | 1 - dependencies.gradle | 1 - shaded/bookkeeper-server-shaded/build.gradle | 1 - .../distributedlog-core-shaded/build.gradle | 2 +- stream/clients/java/all/pom.xml | 2 +- .../current-server-old-clients/build.gradle | 19 ----------------- .../hierarchical-ledger-manager/build.gradle | 21 ------------------- .../hostname-bookieid/build.gradle | 19 ----------------- .../old-cookie-new-cluster/build.gradle | 18 ---------------- .../recovery-no-password/build.gradle | 18 ---------------- .../upgrade-direct/build.gradle | 18 ---------------- tests/backward-compat/upgrade/build.gradle | 18 ---------------- .../yahoo-custom-version/build.gradle | 18 ---------------- 14 files changed, 3 insertions(+), 155 deletions(-) delete mode 100644 tests/backward-compat/current-server-old-clients/build.gradle delete mode 100644 tests/backward-compat/hierarchical-ledger-manager/build.gradle delete mode 100644 tests/backward-compat/hostname-bookieid/build.gradle delete mode 100644 tests/backward-compat/old-cookie-new-cluster/build.gradle delete mode 100644 tests/backward-compat/recovery-no-password/build.gradle delete mode 100644 tests/backward-compat/upgrade-direct/build.gradle delete mode 100644 tests/backward-compat/upgrade/build.gradle delete mode 100644 tests/backward-compat/yahoo-custom-version/build.gradle diff --git a/bin/common.sh b/bin/common.sh index 776c64b2ef1..30cda1c9a9a 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -61,7 +61,7 @@ else JAVA=${JAVA_HOME}/bin/java fi -PROJECT_TARGET_DIR=${PROJECT_TARGET_DIR:-target} +PROJECT_TARGET_DIR=${PROJECT_TARGET_DIR:-build} BINDIR=${BK_BINDIR:-"`dirname "$0"`"} BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"} BK_CONFDIR=${BK_HOME}/conf diff --git a/bookkeeper-server/build.gradle b/bookkeeper-server/build.gradle index 60d715006af..bdfccc3d69d 100644 --- a/bookkeeper-server/build.gradle +++ b/bookkeeper-server/build.gradle @@ -74,7 +74,6 @@ dependencies { testImplementation depLibs.powermockJunit testImplementation depLibs.powermockMockito testImplementation depLibs.snappy - testImplementation depLibs.zookeeper testImplementation depLibs.zookeeperTest annotationProcessor depLibs.lombok testAnnotationProcessor depLibs.lombok diff --git a/dependencies.gradle b/dependencies.gradle index 39b65921ede..570ce8ca3cc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -93,7 +93,6 @@ depLibs = [ commonsCli: "commons-cli:commons-cli:${depVersions.commonsCli}", arquillianCubeDocker: "org.arquillian.cube:arquillian-cube-docker:${depVersions.arquillianCubeDocker}", arquillianJunitContainer: "org.jboss.arquillian.junit:arquillian-junit-container:${depVersions.arquillianJunit}", - arquillianJunitCore: "org.jboss.arquillian.junit:arquillian-junit-core:${depVersions.arquillianJunit}", arquillianJunitStandalone: "org.jboss.arquillian.junit:arquillian-junit-standalone:${depVersions.arquillianJunit}", commonsCodec: "commons-codec:commons-codec:${depVersions.commonsCodec}", commonsCollections4: "org.apache.commons:commons-collections4:${depVersions.commonsCollections4}", diff --git a/shaded/bookkeeper-server-shaded/build.gradle b/shaded/bookkeeper-server-shaded/build.gradle index d79e7d9b937..07cee929d9a 100644 --- a/shaded/bookkeeper-server-shaded/build.gradle +++ b/shaded/bookkeeper-server-shaded/build.gradle @@ -30,7 +30,6 @@ dependencies { shadowJar { dependencies { - } relocate 'com.google', 'org.apache.bookkeeper.shaded.com.google' archiveBaseName.set("bookkeeper-server-shaded") diff --git a/shaded/distributedlog-core-shaded/build.gradle b/shaded/distributedlog-core-shaded/build.gradle index d8306f62701..2bafc330aaa 100644 --- a/shaded/distributedlog-core-shaded/build.gradle +++ b/shaded/distributedlog-core-shaded/build.gradle @@ -26,7 +26,7 @@ plugins { description = 'Apache BookKeeper :: Shaded :: distributedlog-core-shaded' dependencies { - project(':stream:distributedlog:core') + implementation project(':stream:distributedlog:core') } shadowJar { diff --git a/stream/clients/java/all/pom.xml b/stream/clients/java/all/pom.xml index dd95a504ee6..1aa66fd526a 100644 --- a/stream/clients/java/all/pom.xml +++ b/stream/clients/java/all/pom.xml @@ -35,7 +35,7 @@ org.apache.bookkeeper stream-storage-java-client-base ${project.parent.version} - *test-jar + test-jar test diff --git a/tests/backward-compat/current-server-old-clients/build.gradle b/tests/backward-compat/current-server-old-clients/build.gradle deleted file mode 100644 index bd244d07ab4..00000000000 --- a/tests/backward-compat/current-server-old-clients/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - diff --git a/tests/backward-compat/hierarchical-ledger-manager/build.gradle b/tests/backward-compat/hierarchical-ledger-manager/build.gradle deleted file mode 100644 index 0392f371268..00000000000 --- a/tests/backward-compat/hierarchical-ledger-manager/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - - diff --git a/tests/backward-compat/hostname-bookieid/build.gradle b/tests/backward-compat/hostname-bookieid/build.gradle deleted file mode 100644 index bd244d07ab4..00000000000 --- a/tests/backward-compat/hostname-bookieid/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - diff --git a/tests/backward-compat/old-cookie-new-cluster/build.gradle b/tests/backward-compat/old-cookie-new-cluster/build.gradle deleted file mode 100644 index 042f3ce1f39..00000000000 --- a/tests/backward-compat/old-cookie-new-cluster/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/tests/backward-compat/recovery-no-password/build.gradle b/tests/backward-compat/recovery-no-password/build.gradle deleted file mode 100644 index 042f3ce1f39..00000000000 --- a/tests/backward-compat/recovery-no-password/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/tests/backward-compat/upgrade-direct/build.gradle b/tests/backward-compat/upgrade-direct/build.gradle deleted file mode 100644 index 042f3ce1f39..00000000000 --- a/tests/backward-compat/upgrade-direct/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/tests/backward-compat/upgrade/build.gradle b/tests/backward-compat/upgrade/build.gradle deleted file mode 100644 index 042f3ce1f39..00000000000 --- a/tests/backward-compat/upgrade/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ diff --git a/tests/backward-compat/yahoo-custom-version/build.gradle b/tests/backward-compat/yahoo-custom-version/build.gradle deleted file mode 100644 index 042f3ce1f39..00000000000 --- a/tests/backward-compat/yahoo-custom-version/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ From 0082e0e1a6d6e8f1efd83cdbf604efb97bc72ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 17:56:35 +0200 Subject: [PATCH 13/19] fix build --- .../recovery-no-password/build.gradle | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/backward-compat/recovery-no-password/build.gradle diff --git a/tests/backward-compat/recovery-no-password/build.gradle b/tests/backward-compat/recovery-no-password/build.gradle new file mode 100644 index 00000000000..9868c21de74 --- /dev/null +++ b/tests/backward-compat/recovery-no-password/build.gradle @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +dependencies { + testImplementation project(":bookkeeper-server") +} From 5fd03414b1cb544864b0b30a2e55e2530024ae76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 25 Oct 2021 18:39:00 +0200 Subject: [PATCH 14/19] fix build --- tests/backward-compat/recovery-no-password/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/backward-compat/recovery-no-password/build.gradle b/tests/backward-compat/recovery-no-password/build.gradle index 9868c21de74..b720198f1e4 100644 --- a/tests/backward-compat/recovery-no-password/build.gradle +++ b/tests/backward-compat/recovery-no-password/build.gradle @@ -19,4 +19,10 @@ dependencies { testImplementation project(":bookkeeper-server") + testImplementation project(":bookkeeper-common") + testImplementation project(":bookkeeper-common-allocator") + testImplementation project(":bookkeeper-stats") + testImplementation depLibs.protobuf + testImplementation project(":bookkeeper-proto") + testImplementation depLibs.commonsConfiguration } From bcab40ddbb4eac84a91b6b484a2dbc3fae79272a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 26 Oct 2021 10:56:06 +0200 Subject: [PATCH 15/19] fix build --- bin/common.sh | 14 ++++---- bin/common_gradle.sh | 13 +++---- tests/backward-compat/build.gradle | 1 - tests/scripts/build.gradle | 4 +-- tests/scripts/src/test/bash/bk_test.sh | 1 - .../src/test/bash/bk_test_bin_common.sh | 34 ++++++++++++------- .../build.gradle | 3 +- 7 files changed, 37 insertions(+), 33 deletions(-) diff --git a/bin/common.sh b/bin/common.sh index 30cda1c9a9a..a61edcfb064 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -61,7 +61,6 @@ else JAVA=${JAVA_HOME}/bin/java fi -PROJECT_TARGET_DIR=${PROJECT_TARGET_DIR:-build} BINDIR=${BK_BINDIR:-"`dirname "$0"`"} BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"} BK_CONFDIR=${BK_HOME}/conf @@ -197,7 +196,7 @@ find_module_jar() { fi if [ -z "${MODULE_JAR}" ]; then - BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME}) + BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME}) if [ -z "${BUILT_JAR}" ]; then echo "Couldn't find module '${MODULE_NAME}' jar." >&2 read -p "Do you want me to run \`mvn package -DskipTests\` for you ? (y|n) " answer @@ -213,7 +212,7 @@ find_module_jar() { ;; esac - BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME}) + BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME}) fi if [ -n "${BUILT_JAR}" ]; then MODULE_JAR=${BUILT_JAR} @@ -238,12 +237,13 @@ add_maven_deps_to_classpath() { # Need to generate classpath from maven pom. This is costly so generate it # and cache it. Save the file into our target dir so a mvn clean will get # clean it up and force us create a new one. - f="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt" - output="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/build_classpath.out" + f="${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt" + output="${BK_HOME}/${MODULE_PATH}/target/build_classpath.out" + if [ ! -f ${f} ]; then echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2 echo "see output at ${output} for the progress ..." >&2 - ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="${PROJECT_TARGET_DIR}/cached_classpath.txt" &> ${output} + ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &> ${output} echo "the classpath of module '${MODULE_PATH}' is generated at '${f}'." >&2 fi } @@ -258,7 +258,7 @@ set_module_classpath() { echo ${BK_CLASSPATH} else add_maven_deps_to_classpath ${MODULE_PATH} >&2 - cat ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt + cat ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt fi return } diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 9910d8c344a..2c873fe319d 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -155,7 +155,7 @@ is_released_binary() { find_module_jar_at() { DIR=$1 MODULE=$2 - REGEX="^${MODULE}.jar$" + REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$" if [ -d ${DIR} ]; then cd ${DIR} for f in *.jar; do @@ -213,21 +213,16 @@ find_module_jar() { echo "Could not find module '${MODULE_JAR}' jar." >&2 exit 1 fi - ##echo ${MODULE_JAR} + echo "${MODULE_JAR}" return } add_maven_deps_to_classpath() { MODULE_PATH=$1 - MVN="mvn" - if [ "$MAVEN_HOME" != "" ]; then - MVN=${MAVEN_HOME}/bin/mvn - fi - # Need to generate classpath from maven pom. This is costly so generate it # and cache it. Save the file into our target dir so a mvn clean will get # clean it up and force us create a new one. - f="${BK_HOME}/${MODULE_PATH}/build/classpath.txt" + f="${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt" if [ ! -f ${f} ]; then echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2 ${BK_HOME}/gradlew ${MODULE_PATH}:jar @@ -245,7 +240,7 @@ set_module_classpath() { echo ${BK_CLASSPATH} else add_maven_deps_to_classpath ${MODULE_PATH} >&2 - cat ${BK_HOME}/${MODULE_PATH}/build/classpath.txt + cat ${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt fi return } diff --git a/tests/backward-compat/build.gradle b/tests/backward-compat/build.gradle index 863c12fd690..c64d49171e9 100644 --- a/tests/backward-compat/build.gradle +++ b/tests/backward-compat/build.gradle @@ -30,7 +30,6 @@ subprojects { apply plugin: 'groovy' apply plugin: 'com.adarshr.test-logger' - dependencies { testImplementation 'org.codehaus.groovy:groovy-all:2.4.15' testImplementation project(":tests:integration-tests-utils") diff --git a/tests/scripts/build.gradle b/tests/scripts/build.gradle index ef1fe0243e6..5f67058f191 100644 --- a/tests/scripts/build.gradle +++ b/tests/scripts/build.gradle @@ -31,13 +31,13 @@ task downloadShunit2(type: Download) { task extractShunit2(dependsOn: downloadShunit2, type: Copy) { from zipTree(downloadShunit2.dest) - into new File(buildDir, "lib") + into new File(buildDir, "libs/lib") } task executeShTests(dependsOn: extractShunit2, type: Exec) { workingDir "src/test/bash" commandLine "./bk_test.sh" - args "build" + args "-e PROJECT_BUILD_SYSTEM=gradle" } tasks.test.dependsOn("executeShTests") diff --git a/tests/scripts/src/test/bash/bk_test.sh b/tests/scripts/src/test/bash/bk_test.sh index 20ee97d4c46..3c7b02e6fe1 100755 --- a/tests/scripts/src/test/bash/bk_test.sh +++ b/tests/scripts/src/test/bash/bk_test.sh @@ -21,7 +21,6 @@ # */ ARGV0=`basename "$0"` -export PROJECT_TARGET_DIR="build" PREFIX="bk_test_" SHELLS="/bin/sh /bin/bash" diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index 18e898c74bc..c0fc934e7c7 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -19,6 +19,16 @@ # * See the License for the specific language governing permissions and # * limitations under the License. # */ +PROJECT_BUILD_SYSTEM=${PROJECT_BUILD_SYSTEM:-maven} +if [[ $PROJECT_BUILD_SYSTEM == "gradle" ]]; then + PROJECT_TARGET_DIR=build/libs + TEST_CLASSPATH_DIR=build + BK_COMMON_EXEC=common_gradle.sh +else + PROJECT_TARGET_DIR=target + TEST_CLASSPATH_DIR=target + BK_COMMON_EXEC=common.sh +fi # load test helpers . ./bk_test_helpers @@ -28,7 +38,7 @@ # testDefaultVariables() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}" assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}" assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}" @@ -49,7 +59,7 @@ testDefaultVariables() { } testFindModuleJarAt() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} MODULE="test-module" @@ -114,7 +124,7 @@ testFindModuleJar() { echo "" > ${BK_HOME}/conf/bkenv.sh echo "" > ${BK_HOME}/conf/bk_cli_env.sh - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} MODULE="test-module" MODULE_PATH="testmodule" @@ -159,8 +169,8 @@ testLoadEnvfiles() { echo "BOOKIE_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bkenv.sh echo "CLI_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bk_cli_env.sh - # load the common.sh - source ${BK_BINDIR}/common.sh + # load the ${BK_COMMON_EXEC} + source ${BK_BINDIR}/${BK_COMMON_EXEC} assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "enabled" "${NETTY_LEAK_DETECTION_LEVEL}" assertEquals "BOOKIE_MAX_HEAP_MEMORY is not set correctly" "2048M" "${BOOKIE_MAX_HEAP_MEMORY}" @@ -183,19 +193,19 @@ testSetModuleClasspath() { echo "" > ${BK_HOME}/conf/bkenv.sh echo "" > ${BK_HOME}/conf/bk_cli_env.sh - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} MODULE_PATH="testmodule" - mkdir -p ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} - echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt + mkdir -p ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR} + echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR}/cached_classpath.txt local result=$(set_module_classpath ${MODULE_PATH}) assertEquals "test-classpath" ${result} } testBuildBookieJVMOpts() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} TEST_LOG_DIR=${BK_TMPDIR}/logdir TEST_GC_LOG_FILENAME="test-gc.log" @@ -210,7 +220,7 @@ testBuildBookieJVMOpts() { } testBuildCLIJVMOpts() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} TEST_LOG_DIR=${BK_TMPDIR}/logdir TEST_GC_LOG_FILENAME="test-gc.log" @@ -225,7 +235,7 @@ testBuildCLIJVMOpts() { } testBuildNettyOpts() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} ACTUAL_NETTY_OPTS=$(build_netty_opts) EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled \ @@ -236,7 +246,7 @@ testBuildNettyOpts() { } testBuildBookieOpts() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} ACTUAL_OPTS=$(build_bookie_opts) EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" diff --git a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle index 9ad1b71b2f9..eae3130f711 100644 --- a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle +++ b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle @@ -24,7 +24,8 @@ plugins { dependencies { testImplementation depLibs.slf4j testImplementation depLibs.junit - testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-shaded/', include: ['**/*.jar']) + testImplementation depLibs.commonsConfiguration + testImplementation project(':shaded:bookkeeper-server-shaded') testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-tests-shaded/', include: ['**/*.jar']) } From d1f95e40fe3c16844f218f62cad9f284ca71d385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 26 Oct 2021 11:45:20 +0200 Subject: [PATCH 16/19] fix shaded deps --- tests/scripts/build.gradle | 6 +----- tests/scripts/pom.xml | 3 --- tests/shaded/bookkeeper-server-shaded-test/build.gradle | 2 +- .../shaded/bookkeeper-server-tests-shaded-test/build.gradle | 4 ++-- tests/shaded/distributedlog-core-shaded-test/build.gradle | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/scripts/build.gradle b/tests/scripts/build.gradle index 5f67058f191..bffbc2df9ad 100644 --- a/tests/scripts/build.gradle +++ b/tests/scripts/build.gradle @@ -16,14 +16,10 @@ * specific language governing permissions and limitations * under the License. */ - - plugins { id "de.undercouch.download" version "4.1.2" } - - task downloadShunit2(type: Download) { src 'https://github.com/kward/shunit2/archive/v2.1.7.zip' dest new File(buildDir, "shunit2-2.1.7.zip") @@ -35,9 +31,9 @@ task extractShunit2(dependsOn: downloadShunit2, type: Copy) { } task executeShTests(dependsOn: extractShunit2, type: Exec) { - workingDir "src/test/bash" commandLine "./bk_test.sh" args "-e PROJECT_BUILD_SYSTEM=gradle" } + tasks.test.dependsOn("executeShTests") diff --git a/tests/scripts/pom.xml b/tests/scripts/pom.xml index daa00cf7aa3..4bbc9e80021 100644 --- a/tests/scripts/pom.xml +++ b/tests/scripts/pom.xml @@ -66,9 +66,6 @@ ${skipTests} ${project.basedir}/src/test/bash ${project.basedir}/src/test/bash/bk_test.sh - - target - diff --git a/tests/shaded/bookkeeper-server-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-shaded-test/build.gradle index c7453bed53b..78a05a3bc1e 100644 --- a/tests/shaded/bookkeeper-server-shaded-test/build.gradle +++ b/tests/shaded/bookkeeper-server-shaded-test/build.gradle @@ -24,6 +24,6 @@ plugins { dependencies { testImplementation depLibs.slf4j testImplementation depLibs.junit - testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-shaded/', include: ['**/*.jar']) + testImplementation project(path: ':shaded:bookkeeper-server-shaded', configuration: 'shadow') } diff --git a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle index eae3130f711..cc6dcd8f488 100644 --- a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle +++ b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle @@ -25,7 +25,7 @@ dependencies { testImplementation depLibs.slf4j testImplementation depLibs.junit testImplementation depLibs.commonsConfiguration - testImplementation project(':shaded:bookkeeper-server-shaded') - testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-tests-shaded/', include: ['**/*.jar']) + testImplementation project(path: ':shaded:bookkeeper-server-shaded', configuration: 'shadow') + testImplementation project(path: ':shaded:bookkeeper-server-tests-shaded', configuration: 'shadow') } diff --git a/tests/shaded/distributedlog-core-shaded-test/build.gradle b/tests/shaded/distributedlog-core-shaded-test/build.gradle index f681150d73c..bc783ee7981 100644 --- a/tests/shaded/distributedlog-core-shaded-test/build.gradle +++ b/tests/shaded/distributedlog-core-shaded-test/build.gradle @@ -28,6 +28,6 @@ dependencies { testImplementation depLibs.powermockMockito testImplementation depLibs.powermockJunit testImplementation depLibs.commonsConfiguration - testImplementation fileTree(dir: '../../../shaded/distributedlog-core-shaded/', include: ['**/*.jar']) + testImplementation project(path: ':shaded:distributedlog-core-shaded', configuration: 'shadow') } From 43230ba2fb3e7df8d29e1212b9664627a02ef7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Wed, 27 Oct 2021 09:47:15 +0200 Subject: [PATCH 17/19] revert sh files. Avoid to modify maven files, create gradle versions to faciltate migration --- bin/common_gradle.sh | 6 +- tests/scripts/build.gradle | 3 +- .../src/test/bash/bk_test_bin_common.sh | 36 +-- tests/scripts/src/test/bash/bk_test_helpers | 2 +- tests/scripts/src/test/bash/gradle/bk_test.sh | 141 ++++++++++ .../test/bash/gradle/bk_test_bin_common.sh | 263 ++++++++++++++++++ .../src/test/bash/gradle/bk_test_helpers | 94 +++++++ tests/scripts/src/test/bash/gradle/versions | 173 ++++++++++++ 8 files changed, 689 insertions(+), 29 deletions(-) create mode 100755 tests/scripts/src/test/bash/gradle/bk_test.sh create mode 100644 tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh create mode 100644 tests/scripts/src/test/bash/gradle/bk_test_helpers create mode 100644 tests/scripts/src/test/bash/gradle/versions diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 2c873fe319d..f009ac9259d 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -155,7 +155,7 @@ is_released_binary() { find_module_jar_at() { DIR=$1 MODULE=$2 - REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$" + REGEX="^${MODULE}.jar$" if [ -d ${DIR} ]; then cd ${DIR} for f in *.jar; do @@ -222,7 +222,7 @@ add_maven_deps_to_classpath() { # Need to generate classpath from maven pom. This is costly so generate it # and cache it. Save the file into our target dir so a mvn clean will get # clean it up and force us create a new one. - f="${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt" + f="${BK_HOME}/${MODULE_PATH}/build/classpath.txt" if [ ! -f ${f} ]; then echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2 ${BK_HOME}/gradlew ${MODULE_PATH}:jar @@ -240,7 +240,7 @@ set_module_classpath() { echo ${BK_CLASSPATH} else add_maven_deps_to_classpath ${MODULE_PATH} >&2 - cat ${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt + cat ${BK_HOME}/${MODULE_PATH}/build/classpath.txt fi return } diff --git a/tests/scripts/build.gradle b/tests/scripts/build.gradle index bffbc2df9ad..d15c9411cc1 100644 --- a/tests/scripts/build.gradle +++ b/tests/scripts/build.gradle @@ -31,9 +31,8 @@ task extractShunit2(dependsOn: downloadShunit2, type: Copy) { } task executeShTests(dependsOn: extractShunit2, type: Exec) { - workingDir "src/test/bash" + workingDir "src/test/bash/gradle" commandLine "./bk_test.sh" - args "-e PROJECT_BUILD_SYSTEM=gradle" } tasks.test.dependsOn("executeShTests") diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index c0fc934e7c7..e41455cbf26 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -19,16 +19,6 @@ # * See the License for the specific language governing permissions and # * limitations under the License. # */ -PROJECT_BUILD_SYSTEM=${PROJECT_BUILD_SYSTEM:-maven} -if [[ $PROJECT_BUILD_SYSTEM == "gradle" ]]; then - PROJECT_TARGET_DIR=build/libs - TEST_CLASSPATH_DIR=build - BK_COMMON_EXEC=common_gradle.sh -else - PROJECT_TARGET_DIR=target - TEST_CLASSPATH_DIR=target - BK_COMMON_EXEC=common.sh -fi # load test helpers . ./bk_test_helpers @@ -38,7 +28,7 @@ fi # testDefaultVariables() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}" assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}" assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}" @@ -59,7 +49,7 @@ testDefaultVariables() { } testFindModuleJarAt() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh MODULE="test-module" @@ -124,7 +114,7 @@ testFindModuleJar() { echo "" > ${BK_HOME}/conf/bkenv.sh echo "" > ${BK_HOME}/conf/bk_cli_env.sh - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh MODULE="test-module" MODULE_PATH="testmodule" @@ -133,7 +123,7 @@ testFindModuleJar() { TEST_FILES=( "${MODULE}-${VERSION}.jar" "lib/${MODULE}-${VERSION}.jar" - "${MODULE_PATH}/${PROJECT_TARGET_DIR}/${MODULE}-${VERSION}.jar" + "${MODULE_PATH}/target/${MODULE}-${VERSION}.jar" ) count=0 while [ "x${TEST_FILES[count]}" != "x" ] @@ -169,8 +159,8 @@ testLoadEnvfiles() { echo "BOOKIE_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bkenv.sh echo "CLI_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bk_cli_env.sh - # load the ${BK_COMMON_EXEC} - source ${BK_BINDIR}/${BK_COMMON_EXEC} + # load the common.sh + source ${BK_BINDIR}/common.sh assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "enabled" "${NETTY_LEAK_DETECTION_LEVEL}" assertEquals "BOOKIE_MAX_HEAP_MEMORY is not set correctly" "2048M" "${BOOKIE_MAX_HEAP_MEMORY}" @@ -193,19 +183,19 @@ testSetModuleClasspath() { echo "" > ${BK_HOME}/conf/bkenv.sh echo "" > ${BK_HOME}/conf/bk_cli_env.sh - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh MODULE_PATH="testmodule" - mkdir -p ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR} - echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR}/cached_classpath.txt + mkdir -p ${BK_HOME}/${MODULE_PATH}/target + echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt local result=$(set_module_classpath ${MODULE_PATH}) assertEquals "test-classpath" ${result} } testBuildBookieJVMOpts() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh TEST_LOG_DIR=${BK_TMPDIR}/logdir TEST_GC_LOG_FILENAME="test-gc.log" @@ -220,7 +210,7 @@ testBuildBookieJVMOpts() { } testBuildCLIJVMOpts() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh TEST_LOG_DIR=${BK_TMPDIR}/logdir TEST_GC_LOG_FILENAME="test-gc.log" @@ -235,7 +225,7 @@ testBuildCLIJVMOpts() { } testBuildNettyOpts() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh ACTUAL_NETTY_OPTS=$(build_netty_opts) EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled \ @@ -246,7 +236,7 @@ testBuildNettyOpts() { } testBuildBookieOpts() { - source ${BK_BINDIR}/${BK_COMMON_EXEC} + source ${BK_BINDIR}/common.sh ACTUAL_OPTS=$(build_bookie_opts) EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" diff --git a/tests/scripts/src/test/bash/bk_test_helpers b/tests/scripts/src/test/bash/bk_test_helpers index 8620c876d5a..6f43e79d1ac 100644 --- a/tests/scripts/src/test/bash/bk_test_helpers +++ b/tests/scripts/src/test/bash/bk_test_helpers @@ -24,7 +24,7 @@ BK_ARGV0=`basename "$0"` # path to shUnit2 library. can be overridden by setting BK_SHUNIT_INC. -BK_SHUNIT=${BK_SHUNIT_INC:-../../../${PROJECT_TARGET_DIR}/lib/shunit2-2.1.7/shunit2} +BK_SHUNIT=${BK_SHUNIT_INC:-../../../target/lib/shunit2-2.1.7/shunit2} # path to bk bin directory. TESTDIR=`dirname "$0"` diff --git a/tests/scripts/src/test/bash/gradle/bk_test.sh b/tests/scripts/src/test/bash/gradle/bk_test.sh new file mode 100755 index 00000000000..3c7b02e6fe1 --- /dev/null +++ b/tests/scripts/src/test/bash/gradle/bk_test.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash +# +# vim:et:ft=sh:sts=2:sw=2 +# +#/** +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +ARGV0=`basename "$0"` +PREFIX="bk_test_" +SHELLS="/bin/sh /bin/bash" + +find_tests_at() { + DIR=$1 + PREF=$2 + REGEX="^${PREF}[a-z_]*.sh$" + RESULTS="" + if [ -d ${DIR} ]; then + cd ${DIR} + for f in *.sh; do + if [[ ${f} =~ ${REGEX} ]]; then + RESULTS="${RESULTS} ${f}" + fi + done + fi + echo ${RESULTS} +} + +TESTS=$(find_tests_at "." ${PREFIX}) + +# load common unit test functions +source ./versions +source ./bk_test_helpers + +usage() { + echo "usage: ${ARGV0} [-e key=val ...] [-s shell(s)] [-t test(s)]" +} + +env='' + +# process command line flags +while getopts 'e:hs:t:' opt; do + case ${opt} in + e) # set an environment variable + key=`expr "${OPTARG}" : '\([^=]*\)='` + val=`expr "${OPTARG}" : '[^=]*=\(.*\)'` + if [ -z "${key}" -o -z "${val}" ]; then + usage + exit 1 + fi + eval "${key}='${val}'" + export ${key} + env="${env:+${env} }${key}" + ;; + h) usage; exit 0 ;; # output help + s) shells=${OPTARG} ;; # list of shells to run + t) tests=${OPTARG} ;; # list of tests to run + *) usage; exit 1 ;; + esac +done +shift `expr ${OPTIND} - 1` + +# fill shells and/or tests +shells=${shells:-${SHELLS}} +tests=${tests:-${TESTS}} + +# error checking +if [ -z "${tests}" ]; then + bk_info 'no tests found to run; exiting' + exit 0 +fi + +# print run info +cat <&1; ) + done +done diff --git a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh new file mode 100644 index 00000000000..4a70df9771e --- /dev/null +++ b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh @@ -0,0 +1,263 @@ +#!/usr/bin/env bash +# +# vim:et:ft=sh:sts=2:sw=2 +# +#/** +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ +# load test helpers +. ./bk_test_helpers_gradle + +#------------------------------------------------------------------------------ +# suite tests +# + +testDefaultVariables() { + source ${BK_BINDIR}/common_gradle.sh + assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}" + assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}" + assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}" + assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "disabled" "${NETTY_LEAK_DETECTION_LEVEL}" + assertEquals "NETTY_RECYCLER_MAXCAPACITY is not set correctly" "1000" "${NETTY_RECYCLER_MAXCAPACITY}" + assertEquals "NETTY_RECYCLER_LINKCAPACITY is not set correctly" "1024" "${NETTY_RECYCLER_LINKCAPACITY}" + assertEquals "BOOKIE_MAX_HEAP_MEMORY is not set correctly" "1g" "${BOOKIE_MAX_HEAP_MEMORY}" + assertEquals "BOOKIE_MIN_HEAP_MEMORY is not set correctly" "1g" "${BOOKIE_MIN_HEAP_MEMORY}" + assertEquals "BOOKIE_MAX_DIRECT_MEMORY is not set correctly" "2g" "${BOOKIE_MAX_DIRECT_MEMORY}" + assertEquals "BOOKIE_MEM_OPTS is not set correctly" "-Xms1g -Xmx1g -XX:MaxDirectMemorySize=2g" "${BOOKIE_MEM_OPTS}" + assertEquals "BOOKIE_GC_OPTS is not set correctly" "${DEFAULT_BOOKIE_GC_OPTS}" "${BOOKIE_GC_OPTS}" + assertEquals "BOOKIE_GC_LOGGING_OPTS is not set correctly" "${DEFAULT_BOOKIE_GC_LOGGING_OPTS}" "${BOOKIE_GC_LOGGING_OPTS}" + assertEquals "CLI_MAX_HEAP_MEMORY is not set correctly" "512M" "${CLI_MAX_HEAP_MEMORY}" + assertEquals "CLI_MIN_HEAP_MEMORY is not set correctly" "256M" "${CLI_MIN_HEAP_MEMORY}" + assertEquals "CLI_MEM_OPTS is not set correctly" "-Xms256M -Xmx512M" "${CLI_MEM_OPTS}" + assertEquals "CLI_GC_OPTS is not set correctly" "${DEFAULT_CLI_GC_OPTS}" "${CLI_GC_OPTS}" + assertEquals "CLI_GC_LOGGING_OPTS is not set correctly" "${DEFAULT_CLI_GC_LOGGING_OPTS}" "${CLI_GC_LOGGING_OPTS}" +} + +testFindModuleJarAt() { + source ${BK_BINDIR}/common_gradle.sh + + MODULE="test-module" + + # case 1: empty dir + TEST_DIR1=${BK_TMPDIR}/testdir1 + mkdir -p ${TEST_DIR1} + MODULE_JAR1=$(find_module_jar_at ${TEST_DIR1} ${MODULE}) + assertEquals "No module jar should be found at empty dir" "" "${MODULE_JAR1}" + + # case 2: SNAPSHOT jar + TEST_FILES=( + "invalid-${MODULE}.jar" + "invalid-${MODULE}-4.8.0.jar" + "invalid-${MODULE}-4.8.0-SNAPSHOT.jar" + "${MODULE}.jar.invalid" + "${MODULE}-4.8.0.jar.invalid" + "${MODULE}-4.8.0-SNAPSHOT.jar.invalid" + "${MODULE}.jar" + "${MODULE}-4.8.0-SNAPSHOT.jar" + ) + + TEST_DIR2=${BK_TMPDIR}/testdir2 + mkdir -p ${TEST_DIR2} + count=0 + while [ "x${TEST_FILES[count]}" != "x" ] + do + touch ${TEST_DIR2}/${TEST_FILES[count]} + count=$(( $count + 1 )) + done + MODULE_JAR2=$(find_module_jar_at ${TEST_DIR2} ${MODULE}) + assertEquals "${MODULE}-4.8.0-SNAPSHOT.jar is not found" "${TEST_DIR2}/${MODULE}-4.8.0-SNAPSHOT.jar" "${MODULE_JAR2}" + + # case 3: release jar + TEST_FILES=( + "invalid-${MODULE}.jar" + "invalid-${MODULE}-4.8.0.jar" + "invalid-${MODULE}-4.8.0-SNAPSHOT.jar" + "${MODULE}.jar.invalid" + "${MODULE}-4.8.0.jar.invalid" + "${MODULE}-4.8.0-SNAPSHOT.jar.invalid" + "${MODULE}.jar" + "${MODULE}-4.8.0.jar" + ) + + TEST_DIR3=${BK_TMPDIR}/testdir3 + mkdir -p ${TEST_DIR3} + count=0 + while [ "x${TEST_FILES[count]}" != "x" ] + do + touch ${TEST_DIR3}/${TEST_FILES[count]} + count=$(( $count + 1 )) + done + MODULE_JAR3=$(find_module_jar_at ${TEST_DIR3} ${MODULE}) + assertEquals "${MODULE}-4.8.0.jar is not found" "${TEST_DIR3}/${MODULE}-4.8.0.jar" "${MODULE_JAR3}" +} + +testFindModuleJar() { + BK_HOME=${BK_TMPDIR} + # prepare the env files + mkdir -p ${BK_HOME}/conf + echo "" > ${BK_HOME}/conf/nettyenv.sh + echo "" > ${BK_HOME}/conf/bkenv.sh + echo "" > ${BK_HOME}/conf/bk_cli_env.sh + + source ${BK_BINDIR}/common_gradle.sh + + MODULE="test-module" + MODULE_PATH="testmodule" + VERSION="4.8.0" + + TEST_FILES=( + "${MODULE}-${VERSION}.jar" + "lib/${MODULE}-${VERSION}.jar" + "${MODULE_PATH}/build/libs/${MODULE}-${VERSION}.jar" + ) + count=0 + while [ "x${TEST_FILES[count]}" != "x" ] + do + DIR=`dirname ${BK_TMPDIR}/${TEST_FILES[count]}` + mkdir -p ${DIR} + touch ${BK_TMPDIR}/${TEST_FILES[count]} + count=$(( $count + 1 )) + done + + count=0 + while [ "x${TEST_FILES[count]}" != "x" ] + do + FILE="${BK_TMPDIR}/${TEST_FILES[count]}" + ACTUAL_FILE=$(find_module_jar ${MODULE_PATH} ${MODULE}) + + assertEquals "Module file is not found" "${FILE}" "${ACTUAL_FILE}" + + # delete the file + rm ${FILE} + count=$(( $count + 1 )) + done + + unset BK_HOME +} + +testLoadEnvfiles() { + BK_HOME=${BK_TMPDIR} + + # prepare the env files + mkdir -p ${BK_HOME}/conf + echo "NETTY_LEAK_DETECTION_LEVEL=enabled" > ${BK_HOME}/conf/nettyenv.sh + echo "BOOKIE_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bkenv.sh + echo "CLI_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bk_cli_env.sh + + # load the common_gradle.sh + source ${BK_BINDIR}/common_gradle.sh + + assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "enabled" "${NETTY_LEAK_DETECTION_LEVEL}" + assertEquals "BOOKIE_MAX_HEAP_MEMORY is not set correctly" "2048M" "${BOOKIE_MAX_HEAP_MEMORY}" + assertEquals "CLI_MAX_HEAP_MEMORY is not set correctly" "2048M" "${CLI_MAX_HEAP_MEMORY}" + + unset NETTY_LEAK_DETECTION_LEVEL + unset BOOKIE_MAX_HEAP_MEMORY + unset CLI_MAX_HEAP_MEMORY + unset BK_HOME +} + +testBuildBookieJVMOpts() { + source ${BK_BINDIR}/common_gradle.sh + + TEST_LOG_DIR=${BK_TMPDIR}/logdir + TEST_GC_LOG_FILENAME="test-gc.log" + ACTUAL_JVM_OPTS=$(build_bookie_jvm_opts ${TEST_LOG_DIR} ${TEST_GC_LOG_FILENAME}) + USEJDK8=$(detect_jdk8) + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_JVM_OPTS="-Xms1g -Xmx1g -XX:MaxDirectMemorySize=2g ${DEFAULT_BOOKIE_GC_OPTS} ${DEFAULT_BOOKIE_GC_LOGGING_OPTS} -Xlog:gc=info:file=${TEST_LOG_DIR}/${TEST_GC_LOG_FILENAME}::filecount=5,filesize=64m" + else + EXPECTED_JVM_OPTS="-Xms1g -Xmx1g -XX:MaxDirectMemorySize=2g ${DEFAULT_BOOKIE_GC_OPTS} ${DEFAULT_BOOKIE_GC_LOGGING_OPTS} -Xloggc:${TEST_LOG_DIR}/${TEST_GC_LOG_FILENAME}" + fi + assertEquals "JVM OPTS is not set correctly" "${EXPECTED_JVM_OPTS}" "${ACTUAL_JVM_OPTS}" +} + +testBuildCLIJVMOpts() { + source ${BK_BINDIR}/common_gradle.sh + + TEST_LOG_DIR=${BK_TMPDIR}/logdir + TEST_GC_LOG_FILENAME="test-gc.log" + ACTUAL_JVM_OPTS=$(build_cli_jvm_opts ${TEST_LOG_DIR} ${TEST_GC_LOG_FILENAME}) + USEJDK8=$(detect_jdk8) + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_JVM_OPTS="-Xms256M -Xmx512M ${DEFAULT_CLI_GC_OPTS} ${DEFAULT_CLI_GC_LOGGING_OPTS} -Xlog:gc=info:file=${TEST_LOG_DIR}/${TEST_GC_LOG_FILENAME}::filecount=5,filesize=64m" + else + EXPECTED_JVM_OPTS="-Xms256M -Xmx512M ${DEFAULT_CLI_GC_OPTS} ${DEFAULT_CLI_GC_LOGGING_OPTS} -Xloggc:${TEST_LOG_DIR}/${TEST_GC_LOG_FILENAME}" + fi + assertEquals "JVM OPTS is not set correctly" "${EXPECTED_JVM_OPTS}" "${ACTUAL_JVM_OPTS}" +} + +testBuildNettyOpts() { + source ${BK_BINDIR}/common_gradle.sh + + ACTUAL_NETTY_OPTS=$(build_netty_opts) + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled \ + -Dio.netty.recycler.maxCapacity.default=1000 \ + -Dio.netty.recycler.linkCapacity=1024" + + assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" +} + +testBuildBookieOpts() { + source ${BK_BINDIR}/common_gradle.sh + + ACTUAL_OPTS=$(build_bookie_opts) + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" + + assertEquals "Bookie OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" +} + +testBuildLoggingOpts() { + TEST_CONF_FILE="test.conf" + TEST_LOG_DIR="test_log_dir" + TEST_LOG_FILE="test_log_file" + TEST_LOGGER="INFO,TEST" + + EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ + -Dbookkeeper.root.logger=${TEST_LOGGER} \ + -Dbookkeeper.log.dir=${TEST_LOG_DIR} \ + -Dbookkeeper.log.file=${TEST_LOG_FILE}" + ACTUAL_OPTS=$(build_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_DIR} ${TEST_LOG_FILE} ${TEST_LOGGER}) + + assertEquals "Logging OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" +} + +testBuildCLILoggingOpts() { + TEST_CONF_FILE="test.conf" + TEST_LOG_DIR="test_log_dir" + TEST_LOG_FILE="test_log_file" + TEST_LOGGER="INFO,TEST" + + EXPECTED_OPTS="-Dlog4j.configuration=${TEST_CONF_FILE} \ + -Dbookkeeper.cli.root.logger=${TEST_LOGGER} \ + -Dbookkeeper.cli.log.dir=${TEST_LOG_DIR} \ + -Dbookkeeper.cli.log.file=${TEST_LOG_FILE}" + ACTUAL_OPTS=$(build_cli_logging_opts ${TEST_CONF_FILE} ${TEST_LOG_DIR} ${TEST_LOG_FILE} ${TEST_LOGGER}) + + assertEquals "Logging OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" +} + +#------------------------------------------------------------------------------ +# suite functions +# + +oneTimeSetUp() { + bk_oneTimeSetUp +} + +# load and run shUnit2 +. ${BK_SHUNIT} diff --git a/tests/scripts/src/test/bash/gradle/bk_test_helpers b/tests/scripts/src/test/bash/gradle/bk_test_helpers new file mode 100644 index 00000000000..33ae13c08fa --- /dev/null +++ b/tests/scripts/src/test/bash/gradle/bk_test_helpers @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +# +# vim:et:ft=sh:sts=2:sw=2 +# +#/** +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +# name of script +BK_ARGV0=`basename "$0"` + +# path to shUnit2 library. can be overridden by setting BK_SHUNIT_INC. +BK_SHUNIT=${BK_SHUNIT_INC:-../../../build/libs/lib/shunit2-2.1.7/shunit2} + +# path to bk bin directory. +TESTDIR=`dirname "$0"` +BK_BINDIR=`cd ${TESTDIR}/../../../../../bin;pwd` +BK_HOMEDIR=`cd ${TESTDIR}/../../../../..;pwd` +BK_CONFDIR=`cd ${TESTDIR}/../../../../../conf;pwd` + +# +# test helper functions +# + +# message functions +bk_trace() { echo "bk_test:TRACE $@" >&2; } +bk_debug() { echo "bk_test:DEBUG $@" >&2; } +bk_info() { echo "bk_test:INFO $@" >&2; } +bk_warn() { echo "bk_test:WARN $@" >&2; } +bk_error() { echo "bk_test:ERROR $@" >&2; } +bk_fatal() { echo "bk_test:FATAL $@" >&2; } + +bk_oneTimeSetUp() { + # these will be cleaned up automatically by shunit2 + BK_TMPDIR=${SHUNIT_TMPDIR} + stdoutF="${BK_TMPDIR}/stdout" + stderrF="${BK_TMPDIR}/stderr" + expectedF="${BK_TMPDIR}/expected" +} + +# Assert the success of an operation. +# +# If an operation is not successful (i.e. it returns a non-zero return code) +# dump the output of the stderrF to the screen. +# +# Args: +# message: string: message to output [optional] +# result: integer: operation result +assertSuccess() { + if [ $# -eq 2 ]; then + bk_message_=$1 + shift + else + bk_message_='' + fi + bk_result_=$1 + + assertEquals "${bk_message_}" ${SHUNIT_TRUE} ${bk_result_} + [ ${bk_result_} -eq ${SHUNIT_TRUE} ] || cat "${stderrF}" + + unset bk_message_ bk_result_ +} + +assertError() { + if [ $# -eq 2 ]; then + bk_message_="$1: " + shift + else + bk_message_='' + fi + bk_error_=$1 + + bk_file_=${stderrF} + grep "^bk_test:ERROR.*${bk_error_}" "${bk_file_}" >/dev/null + bk_result_=$? + assertTrue "${bk_message_}missing '${bk_error_}' error" ${bk_result_} + [ ${bk_result_} -eq 0 ] || cat "${bk_file_}" + + unset bk_file_ bk_error_ bk_message_ bk_result_ +} diff --git a/tests/scripts/src/test/bash/gradle/versions b/tests/scripts/src/test/bash/gradle/versions new file mode 100644 index 00000000000..9b868f509df --- /dev/null +++ b/tests/scripts/src/test/bash/gradle/versions @@ -0,0 +1,173 @@ +#!/usr/bin/env bash +# +# vim:et:ft=sh:sts=2:sw=2 +# +#/** +# * Licensed to the Apache Software Foundation (ASF) under one +# * or more contributor license agreements. See the NOTICE file +# * distributed with this work for additional information +# * regarding copyright ownership. The ASF licenses this file +# * to you under the Apache License, Version 2.0 (the +# * "License"); you may not use this file except in compliance +# * with the License. You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +ARGV0=`basename "$0"` +LSB_RELEASE="/etc/lsb-release" +VERSIONS_SHELLS="/bin/bash /bin/sh" + +true; TRUE=$? +false; FALSE=$? +ERROR=2 + +UNAME_R=`uname -r` +UNAME_S=`uname -s` + +__versions_haveStrings=${ERROR} + +versions_osName() { + os_name_='unrecognized' + os_system_=${UNAME_S} + os_release_=${UNAME_R} + case ${os_system_} in + CYGWIN_NT-*) os_name_='Cygwin' ;; + Darwin) + os_name_=`/usr/bin/sw_vers -productName` + os_version_=`versions_osVersion` + case ${os_version_} in + 10.4|10.4.[0-9]*) os_name_='Mac OS X Tiger' ;; + 10.5|10.5.[0-9]*) os_name_='Mac OS X Leopard' ;; + 10.6|10.6.[0-9]*) os_name_='Mac OS X Snow Leopard' ;; + 10.7|10.7.[0-9]*) os_name_='Mac OS X Lion' ;; + 10.8|10.8.[0-9]*) os_name_='Mac OS X Mountain Lion' ;; + 10.9|10.9.[0-9]*) os_name_='Mac OS X Mavericks' ;; + 10.10|10.10.[0-9]*) os_name_='Mac OS X Yosemite' ;; + 10.11|10.11.[0-9]*) os_name_='Mac OS X El Capitan' ;; + 10.12|10.12.[0-9]*) os_name_='macOS Sierra' ;; + 10.13|10.13.[0-9]*) os_name_='macOS High Sierra' ;; + *) os_name_='macOS' ;; + esac + ;; + FreeBSD) os_name_='FreeBSD' ;; + Linux) os_name_='Linux' ;; + SunOS) + os_name_='SunOS' + if [ -r '/etc/release' ]; then + if grep 'OpenSolaris' /etc/release >/dev/null; then + os_name_='OpenSolaris' + else + os_name_='Solaris' + fi + fi + ;; + esac + + echo ${os_name_} + unset os_name_ os_system_ os_release_ os_version_ +} + +versions_osVersion() { + os_version_='unrecognized' + os_system_=${UNAME_S} + os_release_=${UNAME_R} + case ${os_system_} in + CYGWIN_NT-*) + os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'` + ;; + Darwin) + os_version_=`/usr/bin/sw_vers -productVersion` + ;; + FreeBSD) + os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'` + ;; + Linux) + if [ -r '/etc/os-release' ]; then + os_version_=`awk -F= '$1~/PRETTY_NAME/{print $2}' /etc/os-release \ + |sed 's/"//g'` + elif [ -r '/etc/redhat-release' ]; then + os_version_=`cat /etc/redhat-release` + elif [ -r '/etc/SuSE-release' ]; then + os_version_=`head -n 1 /etc/SuSE-release` + elif [ -r "${LSB_RELEASE}" ]; then + if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then + # shellcheck disable=SC2002 + os_version_=`cat "${LSB_RELEASE}" \ + |awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \ + |sed 's/"//g;s/ /-/g'` + fi + fi + ;; + SunOS) + if [ -r '/etc/release' ]; then + if grep 'OpenSolaris' /etc/release >/dev/null; then # OpenSolaris + os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'` + else # Solaris + major_=`echo "${os_release_}" |sed 's/[0-9]*\.\([0-9]*\)/\1/'` + minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'` + os_version_="${major_}${minor_}" + fi + fi + ;; + esac + + echo "${os_version_}" + unset os_release_ os_system_ os_version_ major_ minor_ +} + +versions_shellVersion() { + shell_=$1 + + shell_present_=${FALSE} + case "${shell_}" in + ash) [ -x '/bin/busybox' ] && shell_present_=${TRUE} ;; + *) [ -x "${shell_}" ] && shell_present_=${TRUE} ;; + esac + if [ ${shell_present_} -eq ${FALSE} ]; then + echo 'not installed' + return ${FALSE} + fi + + version_='' + case ${shell_} in + */sh) + # This could be one of any number of shells. Try until one fits. + version_='' + [ -z "${version_}" ] && version_=`versions_shell_bash "${shell_}"` + ;; + */bash) version_=`versions_shell_bash "${shell_}"` ;; + *) version_='invalid' + esac + + echo "${version_:-unknown}" + unset shell_ version_ +} + +versions_shell_bash() { + $1 --version : 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/' +} + +versions_main() { + # Treat unset variables as an error. + set -u + + os_name=`versions_osName` + os_version=`versions_osVersion` + echo "os: ${os_name} version: ${os_version}" + + for shell in ${VERSIONS_SHELLS}; do + shell_version=`versions_shellVersion "${shell}"` + echo "shell: ${shell} version: ${shell_version}" + done +} + +if [ "${ARGV0}" = 'versions' ]; then + versions_main "$@" +fi From bd739fdf59c18f0bcc31f844ad9e0b5c147013f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Wed, 27 Oct 2021 09:52:42 +0200 Subject: [PATCH 18/19] fix sh tests --- bin/common_gradle.sh | 2 +- tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh | 2 +- tests/scripts/src/test/bash/gradle/bk_test_helpers | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index f009ac9259d..8accffb404a 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -155,7 +155,7 @@ is_released_binary() { find_module_jar_at() { DIR=$1 MODULE=$2 - REGEX="^${MODULE}.jar$" + REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$" if [ -d ${DIR} ]; then cd ${DIR} for f in *.jar; do diff --git a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh index 4a70df9771e..c20165f6050 100644 --- a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh @@ -20,7 +20,7 @@ # * limitations under the License. # */ # load test helpers -. ./bk_test_helpers_gradle +. ./bk_test_helpers #------------------------------------------------------------------------------ # suite tests diff --git a/tests/scripts/src/test/bash/gradle/bk_test_helpers b/tests/scripts/src/test/bash/gradle/bk_test_helpers index 33ae13c08fa..c2fb838ce64 100644 --- a/tests/scripts/src/test/bash/gradle/bk_test_helpers +++ b/tests/scripts/src/test/bash/gradle/bk_test_helpers @@ -24,13 +24,13 @@ BK_ARGV0=`basename "$0"` # path to shUnit2 library. can be overridden by setting BK_SHUNIT_INC. -BK_SHUNIT=${BK_SHUNIT_INC:-../../../build/libs/lib/shunit2-2.1.7/shunit2} +BK_SHUNIT=${BK_SHUNIT_INC:-../../../../build/libs/lib/shunit2-2.1.7/shunit2} # path to bk bin directory. TESTDIR=`dirname "$0"` -BK_BINDIR=`cd ${TESTDIR}/../../../../../bin;pwd` -BK_HOMEDIR=`cd ${TESTDIR}/../../../../..;pwd` -BK_CONFDIR=`cd ${TESTDIR}/../../../../../conf;pwd` +BK_BINDIR=`cd ${TESTDIR}/../../../../../../bin;pwd` +BK_HOMEDIR=`cd ${TESTDIR}/../../../../../..;pwd` +BK_CONFDIR=`cd ${TESTDIR}/../../../../../../conf;pwd` # # test helper functions From 00b49f4f5810b5acb0ea9fc026c43331a0da0302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Wed, 27 Oct 2021 19:26:42 +0200 Subject: [PATCH 19/19] Fix common_gradle.sh regex --- bin/common_gradle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 8accffb404a..3f65c23f3a6 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -155,7 +155,7 @@ is_released_binary() { find_module_jar_at() { DIR=$1 MODULE=$2 - REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$" + REGEX="^${MODULE}[-0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$" if [ -d ${DIR} ]; then cd ${DIR} for f in *.jar; do