Skip to content
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

System Keyspace 포함 여부 필드 추가 및 테스트 보강 #44

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public class ClusterKeyspaceCommander extends BaseClusterCommander {
* @param session
* @return
*/
public List<String> allKeyspaceNames(CqlSession session) {
public List<String> allKeyspaceNames(CqlSession session, boolean includeSystemKeyspace) {
return session.execute(SimpleStatement.newInstance("DESC KEYSPACES"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 3.x 지원 안하는거 같네요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헐.... 방법 찾아볼게요.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

지원합니다~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 1:0 no viable alternative at input 'DESC' ([DESC]...)

저희가 쓰는 라이브러리로 호출 할 때 뭔가 있는듯..

.all()
.stream()
.map(info -> info.getString("keyspace_name"))
.filter(keyspaceName -> includeSystemKeyspace || !CassandraSystemKeyspace.isSystemKeyspace(keyspaceName))
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@
class CassandraSystemKeyspaceTest {

@Test
void system_keyspace() {
void check_is_system_keyspace() {
for (CassandraSystemKeyspace keyspace : CassandraSystemKeyspace.values()) {
assertThat(CassandraSystemKeyspace.isSystemKeyspace(keyspace.getKeyspaceName())).isTrue();
}
}

@Test
void not_system_keyspace() {
assertThat(CassandraSystemKeyspace.isSystemKeyspace("demo")).isFalse();
}

@Test
void isVirtualKeyspace() {
void check_is_virtual_system_keyspace() {
assertThat(CassandraSystemKeyspace.isVirtualSystemKeyspace("system_virtual_schema")).isTrue();
assertThat(CassandraSystemKeyspace.isVirtualSystemKeyspace("system_views")).isTrue();
assertThat(CassandraSystemKeyspace.isVirtualSystemKeyspace("system_traces")).isFalse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/**
* ClusterKeyspaceCommanderTest
*
* @author seungh0
* @since 2024-07-07
*/
@Slf4j
class ClusterKeyspaceCommanderTest extends IntegrationTest {

@Autowired
private ClusterKeyspaceCommander clusterKeyspaceCommander;

@Test
void runTest() {
// try (CqlSession session = makeSession()) {
// log.info("describeResult : {}", clusterKeyspaceCommander.describe(session, ClusterKeyspaceDescribeArgs.builder()
// .keyspace(keyspaceName)
// .withChildren(true)
// .pretty(true)
// .build()));
// }
void list_all_keyspace_names_include_system_keyspace() {
List<String> sut = clusterKeyspaceCommander.allKeyspaceNames(makeSession(), true);

// then
assertThat(sut).contains("testdb");
assertThat(sut).contains(CassandraSystemKeyspace.SYSTEM.getKeyspaceName(), CassandraSystemKeyspace.SYSTEM_SCHEMA.getKeyspaceName());
}

@Test
void list_all_keyspace_names_exclude_system_keyspace() {
List<String> sut = clusterKeyspaceCommander.allKeyspaceNames(makeSession(), false);

// then
assertThat(sut).contains("testdb");
assertThat(sut).doesNotContain(CassandraSystemKeyspace.SYSTEM.getKeyspaceName(), CassandraSystemKeyspace.SYSTEM_SCHEMA.getKeyspaceName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ClusterKeyspaceReader(

public Map<String, List<String>> getKeyspaceNames(String clusterId) {
try (CqlSession session = tempClusterConnector.makeSession(clusterId)) {
List<String> keyspaceNames = clusterKeyspaceCommander.allKeyspaceNames(session);
List<String> keyspaceNames = clusterKeyspaceCommander.allKeyspaceNames(session, true);

KeyspaceFilter keyspaceFilter = ClusterUtils.makeKeyspaceFilter(session.getContext());

Expand Down
Loading