-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api][pulsar-client]Add get version command for pulsar rest api, pulsar-admin, pulsar-client #9975
Merged
codelipenghui
merged 7 commits into
apache:master
from
AmateurEvents:fix/add-version-command-for-client-and-broker
Mar 23, 2021
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb10b7a
Add get version command for pulsar rest api, pulsar-admin, pulsar-client
tuteng cfa139f
Fixed boolean flag
tuteng b7a4765
Fixed client version
tuteng b9ce866
Add integration test for version command
tuteng bb271ea
Fixed build failed
tuteng 95c6913
Fixed assertTrue
tuteng be79b07
format code, fixed space
tuteng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
pulsar-broker/src/main/java/org/apache/pulsar/PulsarVersionStarter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
package org.apache.pulsar; | ||
|
||
/** | ||
* Pulsar version entry point. | ||
*/ | ||
public class PulsarVersionStarter { | ||
|
||
public static void main(String args[]) { | ||
System.out.println("Current version of pulsar is: " + PulsarVersion.getVersion()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../integration/src/test/java/org/apache/pulsar/tests/integration/cli/PulsarVersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* 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. | ||
*/ | ||
package org.apache.pulsar.tests.integration.cli; | ||
|
||
import org.apache.pulsar.tests.integration.docker.ContainerExecResult; | ||
import org.apache.pulsar.tests.integration.topologies.PulsarCluster; | ||
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec; | ||
import org.testcontainers.shaded.org.apache.commons.lang.RandomStringUtils; | ||
|
||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* Pulsar version test class. | ||
*/ | ||
public class PulsarVersionTest { | ||
|
||
private final static String clusterNamePrefix = "pulsar-version"; | ||
private PulsarCluster pulsarCluster; | ||
|
||
@BeforeClass | ||
public void setup() throws Exception { | ||
PulsarClusterSpec spec = PulsarClusterSpec.builder() | ||
.clusterName(String.format("%s-%s", clusterNamePrefix, RandomStringUtils.randomAlphabetic(6))) | ||
.build(); | ||
pulsarCluster = PulsarCluster.forSpec(spec); | ||
pulsarCluster.start(); | ||
} | ||
|
||
@AfterClass(alwaysRun = true) | ||
public void teardown() { | ||
if (pulsarCluster != null) { | ||
pulsarCluster.stop(); | ||
pulsarCluster = null; | ||
} | ||
} | ||
|
||
@Test | ||
public void getVersion() throws Exception { | ||
ContainerExecResult result = pulsarCluster.runAdminCommandOnAnyBroker("brokers", "version"); | ||
String version = result.getStdout(); | ||
ContainerExecResult adminVersionShortOption = pulsarCluster.runAdminCommandOnAnyBroker("-v"); | ||
assertTrue(adminVersionShortOption.getStdout().contains(version)); | ||
ContainerExecResult adminVersionLongOption = pulsarCluster.runAdminCommandOnAnyBroker("--version"); | ||
assertTrue(adminVersionLongOption.getStdout().contains(version)); | ||
ContainerExecResult clientVersionShortOption = pulsarCluster.getAnyBroker().execCmd( | ||
PulsarCluster.CLIENT_SCRIPT, "-v"); | ||
assertTrue(clientVersionShortOption.getStdout().contains(version)); | ||
ContainerExecResult clientVersionLongOption = pulsarCluster.getAnyBroker().execCmd( | ||
PulsarCluster.CLIENT_SCRIPT, "--version"); | ||
assertTrue(clientVersionLongOption.getStdout().contains(version)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I found that other commands such as
pulsar broker
,pulsar proxy
are a public class with amain
function,pulsar version
as a separate command, also needs to be a class with amain
function, otherwise, it needs to be a subcommand of other commands