Skip to content

Commit 80ff0ef

Browse files
committed
Added installModule test
1 parent c3d8f49 commit 80ff0ef

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

subprojects/admin/src/main/java/com/redis/enterprise/Admin.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,17 @@ public ModuleInstallResponse installModule(String filename, byte[] bytes) throws
223223
builder.setMode(HttpMultipartMode.STRICT);
224224
builder.addPart("module", new ByteArrayBody(bytes, ContentType.MULTIPART_FORM_DATA, filename));
225225
post.setEntity(builder.build());
226-
return read(post, ModuleInstallResponse.class, HttpStatus.SC_ACCEPTED);
226+
ModuleInstallResponse response = read(post, ModuleInstallResponse.class, HttpStatus.SC_ACCEPTED);
227+
Awaitility.await().until(() -> {
228+
log.info("Checking status of action {}", response.getActionUID());
229+
Action status = getAction(response.getActionUID());
230+
if ("completed".equals(status.getStatus())) {
231+
return true;
232+
}
233+
log.info("Action {} status: {}", response.getActionUID(), status.getStatus());
234+
return false;
235+
});
236+
return response;
227237
}
228238

229239
public Bootstrap getBootstrap() throws ParseException, IOException {

subprojects/admin/src/test/java/com/redis/enterprise/AdminTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.redis.enterprise;
22

3+
import java.io.ByteArrayOutputStream;
34
import java.io.IOException;
5+
import java.io.InputStream;
46
import java.security.GeneralSecurityException;
57
import java.util.List;
68
import java.util.stream.Collectors;
@@ -19,9 +21,11 @@
1921
import org.slf4j.LoggerFactory;
2022
import org.testcontainers.junit.jupiter.Container;
2123
import org.testcontainers.junit.jupiter.Testcontainers;
24+
import org.testcontainers.shaded.org.apache.commons.io.IOUtils;
2225

2326
import com.redis.enterprise.rest.Database;
2427
import com.redis.testcontainers.RedisEnterpriseContainer;
28+
import com.redis.testcontainers.RedisEnterpriseContainer.RedisModule;
2529

2630
@Testcontainers
2731
@TestInstance(Lifecycle.PER_CLASS)
@@ -77,4 +81,17 @@ void deleteDatabase() throws ParseException, GeneralSecurityException, IOExcepti
7781
Awaitility.await().until(() -> admin.getDatabases().stream().noneMatch(d -> d.getUid() == database.getUid()));
7882
}
7983

84+
@Test
85+
void installModule() throws IOException, ParseException {
86+
String gearsModuleFile = "redisgears.linux-bionic-x64.1.0.6.zip";
87+
try (InputStream zipInputStream = getClass().getClassLoader().getResourceAsStream(gearsModuleFile)) {
88+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
89+
IOUtils.copy(zipInputStream, baos);
90+
log.info("Installing module {}", gearsModuleFile);
91+
admin.installModule(gearsModuleFile, baos.toByteArray()).getActionUID();
92+
Assertions.assertTrue(
93+
admin.getModules().stream().anyMatch(m -> m.getName().equals(RedisModule.GEARS.getName())));
94+
}
95+
}
96+
8097
}
Binary file not shown.

0 commit comments

Comments
 (0)