forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue apache#8874]Fix the package upload failed issue (apache#8907)
--- Fixes apache#8874 *Motivation* Fix the issue when uploading a package, it will show update metadata failed. *Modifications* - Fix the issue - Enable the integration tests for this
- Loading branch information
Showing
4 changed files
with
24 additions
and
15 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
package org.apache.pulsar.tests.integration.cli; | ||
|
||
import org.apache.pulsar.tests.integration.containers.BrokerContainer; | ||
import org.apache.pulsar.tests.integration.docker.ContainerExecResult; | ||
import org.apache.pulsar.tests.integration.topologies.PulsarCluster; | ||
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec; | ||
|
@@ -60,18 +61,17 @@ public void teardown() { | |
private Map<String, String> getPackagesManagementServiceEnvs() { | ||
Map<String, String> envs = new HashMap<>(); | ||
envs.put("enablePackagesManagement", "true"); | ||
envs.put("packagesManagementLedgerRootPath", "/ledgers"); | ||
return envs; | ||
} | ||
|
||
@Test(timeOut = 60000 * 10) | ||
@Test(timeOut = 60000 * 5) | ||
public void testPackagesOperationsWithoutUploadingPackages() throws Exception { | ||
ContainerExecResult result = runPackagesCommand("list", "--type", "function", "public/default"); | ||
assertEquals(result.getExitCode(), 0); | ||
assertTrue(result.getStdout().isEmpty()); | ||
|
||
result = runPackagesCommand("list-versions", "function://public/default/test"); | ||
assertEquals(result.getExitCode(), 0); | ||
assertTrue(result.getStdout().isEmpty()); | ||
|
||
try { | ||
result = runPackagesCommand("download", "function://public/default/test@v1", "--path", "test-admin"); | ||
|
@@ -81,14 +81,24 @@ public void testPackagesOperationsWithoutUploadingPackages() throws Exception { | |
} | ||
} | ||
|
||
// TODO: the upload command has some problem when uploading packages, enable this tests when issue | ||
// https://github.com/apache/pulsar/issues/8874 is fixed. | ||
@Test(timeOut = 60000 * 8) | ||
public void testPackagesOperationsWithUploadingPackages() throws Exception { | ||
String testPackageName = "function://public/default/test@v1"; | ||
ContainerExecResult result = runPackagesCommand("upload", "--description", "a test package", | ||
"--path", PulsarCluster.ADMIN_SCRIPT, testPackageName); | ||
assertEquals(result.getExitCode(), 0); | ||
|
||
BrokerContainer container = pulsarCluster.getBroker(0); | ||
String downloadFile = "tmp-file-" + RandomStringUtils.randomAlphabetic(8); | ||
String[] downloadCmd = new String[]{PulsarCluster.ADMIN_SCRIPT, "packages", "download", | ||
"--path", downloadFile, testPackageName}; | ||
result = container.execCmd(downloadCmd); | ||
assertEquals(result.getExitCode(), 0); | ||
|
||
String[] diffCmd = new String[]{"diff", PulsarCluster.ADMIN_SCRIPT, downloadFile}; | ||
result = container.execCmd(diffCmd); | ||
assertEquals(result.getExitCode(), 0); | ||
|
||
result = runPackagesCommand("get-metadata", testPackageName); | ||
assertEquals(result.getExitCode(), 0); | ||
assertFalse(result.getStdout().isEmpty()); | ||
|
@@ -97,15 +107,16 @@ public void testPackagesOperationsWithUploadingPackages() throws Exception { | |
result = runPackagesCommand("list", "--type", "function", "public/default"); | ||
assertEquals(result.getExitCode(), 0); | ||
assertFalse(result.getStdout().isEmpty()); | ||
assertTrue(result.getStdout().contains(testPackageName)); | ||
assertTrue(result.getStdout().contains("test")); | ||
|
||
result = runPackagesCommand("list-versions", "--type", "function://public/default/test"); | ||
result = runPackagesCommand("list-versions", "function://public/default/test"); | ||
assertEquals(result.getExitCode(), 0); | ||
assertFalse(result.getStdout().isEmpty()); | ||
assertTrue(result.getStdout().contains("v1")); | ||
|
||
String contact = "[email protected]"; | ||
result = runPackagesCommand("update-metadata", "--contact", contact, "-PpropertyA=A", testPackageName); | ||
result = runPackagesCommand("update-metadata", "--description", "a test package", | ||
"--contact", contact, "-PpropertyA=A", testPackageName); | ||
assertEquals(result.getExitCode(), 0); | ||
|
||
result = runPackagesCommand("get-metadata", testPackageName); | ||
|
@@ -118,7 +129,7 @@ public void testPackagesOperationsWithUploadingPackages() throws Exception { | |
result = runPackagesCommand("delete", testPackageName); | ||
assertEquals(result.getExitCode(), 0); | ||
|
||
result = runPackagesCommand("list", "--type", "functions", "public/default"); | ||
result = runPackagesCommand("list-versions", "function://public/default/test"); | ||
assertEquals(result.getExitCode(), 0); | ||
assertTrue(result.getStdout().isEmpty()); | ||
} | ||
|