From b0495698eea6e6d0ede55c149fa6e026e58e9152 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 7 Jun 2026 16:54:08 +0200 Subject: [PATCH] Improvements in `apache-release-profile` IT - Added `selector.groovy` to verify the presence of a Git executable. - Added `setup.groovy` for initializing a local Git repository. - Added `verify.1.groovy` for release preparation verification logic. - Split invoker goals into `release:prepare` and `release:perform`. - Enhanced POM with local SCM configuration to avoid remote changes during tests. --- .../apache-release-profile/invoker.properties | 5 ++- src/it/apache-release-profile/pom.xml | 7 ++++ src/it/apache-release-profile/selector.groovy | 32 ++++++++++++++++ src/it/apache-release-profile/setup.groovy | 38 +++++++++++++++++++ src/it/apache-release-profile/verify.1.groovy | 37 ++++++++++++++++++ src/it/apache-release-profile/verify.groovy | 20 +++++++--- 6 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 src/it/apache-release-profile/selector.groovy create mode 100644 src/it/apache-release-profile/setup.groovy create mode 100644 src/it/apache-release-profile/verify.1.groovy diff --git a/src/it/apache-release-profile/invoker.properties b/src/it/apache-release-profile/invoker.properties index 3d2376a..4ac65a3 100644 --- a/src/it/apache-release-profile/invoker.properties +++ b/src/it/apache-release-profile/invoker.properties @@ -15,5 +15,6 @@ # specific language governing permissions and limitations # under the License. -# Test with apache-release profile activated -invoker.goals = deploy -Papache-release +# Test with apache-release profile +invoker.goals.1 = release:clean release:prepare +invoker.goals.2 = release:perform diff --git a/src/it/apache-release-profile/pom.xml b/src/it/apache-release-profile/pom.xml index b523169..af6dbe7 100644 --- a/src/it/apache-release-profile/pom.xml +++ b/src/it/apache-release-profile/pom.xml @@ -37,8 +37,15 @@ under the License. UTF-8 true true + + false + + + scm:git:file://${project.basedir} + + diff --git a/src/it/apache-release-profile/selector.groovy b/src/it/apache-release-profile/selector.groovy new file mode 100644 index 0000000..9d29b2a --- /dev/null +++ b/src/it/apache-release-profile/selector.groovy @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// check if git executable exist +def proc = ["git", "--version"].execute() +proc.waitFor() + +println "return code: ${proc.exitValue()}" +println "stdout: ${proc.in.text}" +println "stderr: ${proc.err.text}" + +if (proc.exitValue() == 0) { + return true +} + +return false diff --git a/src/it/apache-release-profile/setup.groovy b/src/it/apache-release-profile/setup.groovy new file mode 100644 index 0000000..e6ac47a --- /dev/null +++ b/src/it/apache-release-profile/setup.groovy @@ -0,0 +1,38 @@ +/* + * 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. + */ + +def execute(def cmd) { + println "execute: ${cmd}" + def proc = cmd.execute(null, basedir) + proc.waitFor() + println "return code: ${proc.exitValue()}" + println "stderr: ${proc.err.text}" + println "stdout: ${proc.in.text}" + if (proc.exitValue() != 0) { + throw new RuntimeException("Command failed: ${cmd}\nstdout: ${proc.in.text}\nstderr: ${proc.err.text}") + } +} + +// setup local git repository +execute(["git", "init"]) +execute(["git", "config", "user.email", "test@example.com"]) +execute(["git", "config", "user.name", "Test User"]) +execute(["git", "add", "pom.xml", "src"]) +execute(["git", "commit", "-m", "initial commit"]) + diff --git a/src/it/apache-release-profile/verify.1.groovy b/src/it/apache-release-profile/verify.1.groovy new file mode 100644 index 0000000..fcc2ea4 --- /dev/null +++ b/src/it/apache-release-profile/verify.1.groovy @@ -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. + */ + +// verification after first goal - release:perform was only executed + +def buildLog = new File(basedir, 'build.log') +assert buildLog.exists() + +// release preparation finished +assert buildLog.text.contains('prepare:run-preparation-goals') : + 'Expected message not found in build log' + +assert !buildLog.text.contains('perform:run-perform-goals') : + 'Release perform should not be performed during release preparation' + +// there are no interactions with ATR client during release preparation, +// as the profile apache-release is not active +assert !buildLog.text.contains('[Mock ATR client]') : + 'Should be no interaction with ATR client during release preparation' + + diff --git a/src/it/apache-release-profile/verify.groovy b/src/it/apache-release-profile/verify.groovy index b24b4cd..24ead32 100644 --- a/src/it/apache-release-profile/verify.groovy +++ b/src/it/apache-release-profile/verify.groovy @@ -21,21 +21,29 @@ def buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.count('[INFO] [Mock ATR client] creating new JWT for username: dummy-asfuid') == 1 +// in final log we have both goal executed - prepare and perform +assert buildLog.text.contains('prepare:run-preparation-goals') : 'Expected message not found in build log' -assert buildLog.text.count('[INFO] [Mock ATR client] using cached JWT: mock-jwt-dummy-asfuid') == 1 +assert buildLog.text.contains('perform:run-perform-goals') : 'Expected message not found in build log' -assert buildLog.text.count('[INFO] [Mock ATR client] created base URL: https://release-test.apache.org/, username: dummy-asfuid, password: dummy-token') == 2: +// interaction with ATR client should be visible after perform goal execution +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] creating new JWT for username: dummy-asfuid') == 1 : 'Expected message not found in build log' -assert buildLog.text.count('[INFO] [Mock ATR client] getRelease: tooling-atr-test-apache-release, 1.0-SNAPSHOT') == 1 : +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] using cached JWT: mock-jwt-dummy-asfuid') == 1 : 'Expected message not found in build log' -assert buildLog.text.count('[INFO] [Mock ATR client] uploadFile: tooling-atr-test-apache-release, 1.0-SNAPSHOT, tooling-atr-test-apache-release-1.0-SNAPSHOT-source-release.zip, ') == 1 : +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] created base URL: https://release-test.apache.org/, username: dummy-asfuid, password: dummy-token') == 2 : 'Expected message not found in build log' -assert buildLog.text.count('[INFO] [Mock ATR client] uploadFile: tooling-atr-test-apache-release, 1.0-SNAPSHOT, tooling-atr-test-apache-release-1.0-SNAPSHOT-source-release.zip.sha512, ') == 1 : +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] getRelease: tooling-atr-test-apache-release, 1.0') == 1 : + 'Expected message not found in build log' + +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] uploadFile: tooling-atr-test-apache-release, 1.0, tooling-atr-test-apache-release-1.0-source-release.zip, ') == 1 : + 'Expected message not found in build log' + +assert buildLog.text.count('[INFO] [INFO] [Mock ATR client] uploadFile: tooling-atr-test-apache-release, 1.0, tooling-atr-test-apache-release-1.0-source-release.zip.sha512, ') == 1 : 'Expected message not found in build log'