Skip to content

Commit

Permalink
Bugfix/2.20 (#241)
Browse files Browse the repository at this point in the history
* feat: TOOLS-2766 add support for `manage sindex create blob`

* test: Update e2e tests to use server 7.0

* fix: Remove `bins` from `show statistics` default in -cf mode
  • Loading branch information
Jesse S authored Dec 6, 2023
1 parent fb75941 commit 57ef5cd
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 147 deletions.
12 changes: 12 additions & 0 deletions lib/collectinfo_analyzer/get_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,15 @@ def get_role(
] = self.log_handler.admin_acl(stanza=constants.ADMIN_ROLES, nodes=nodes)

return GetAclController.new_dict_with_key(data, role_name)


class GetClusterMetadataController:
# TODO: do we need this? Technically asadm only really ever deals with metadata. I
# want this to handle things that arn't configs or stats . . .

def __init__(self, log_analyzer: CollectinfoLogHandler):
self.log_handler = log_analyzer

def get_builds(self) -> TimestampDict[NodeDict[str]]:
builds = self.log_handler.info_meta_data(stanza="asd_build")
return util.filter_exceptions(builds)
20 changes: 18 additions & 2 deletions lib/collectinfo_analyzer/show_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

from lib.collectinfo_analyzer.get_controller import (
GetAclController,
GetClusterMetadataController,
GetConfigController,
GetStatisticsController,
)
from lib.utils import common, constants, util
from lib.utils import common, constants, util, version
from lib.base_controller import CommandHelp, CommandName, ModifierHelp

from .collectinfo_command_controller import CollectinfoCommandController
Expand Down Expand Up @@ -785,12 +786,12 @@ def __init__(self):
self.getter = GetStatisticsController(
self.log_handler
) # TODO: Use this getter for more than just xdr
self.meta_getter = GetClusterMetadataController(self.log_handler)

@CommandHelp(
"Displays bin, set, service, and namespace statistics",
)
def _do_default(self, line):
self.do_bins(line[:])
self.do_sets(line[:])
self.do_service(line[:])
self.do_namespace(line[:])
Expand Down Expand Up @@ -1004,6 +1005,21 @@ def do_bins(self, line):
mods=self.mods,
)

builds = self.meta_getter.get_builds()

for timestamp in sorted(builds.keys()):
nodes_builds = builds[timestamp]
if any(
[
version.LooseVersion(build)
>= version.LooseVersion(constants.SERVER_INFO_BINS_REMOVAL_VERSION)
for build in nodes_builds.values()
]
):
self.logger.error(
f"Server version {constants.SERVER_INFO_BINS_REMOVAL_VERSION} removed namespace bin-name limits and statistics."
)

new_bin_stats = self.log_handler.info_statistics(
stanza=constants.STAT_BINS, flip=True
)
Expand Down
2 changes: 1 addition & 1 deletion lib/live_cluster/client/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def wrapper(*args, raise_exception=False, **kwargs):
except OSError as e:
args[0].alive = False
exception = e
except (ASInfoError, ASProtocolError, Exception) as e:
except Exception as e:
exception = e

if raise_exception:
Expand Down
24 changes: 22 additions & 2 deletions lib/live_cluster/manage_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
CDTContext,
)
from .live_cluster_command_controller import LiveClusterCommandController
from lib.live_cluster.get_controller import GetJobsController
from lib.live_cluster.get_controller import (
GetClusterMetadataController,
GetJobsController,
)

logger = logging.getLogger(__name__)
logger.setLevel(logging.CRITICAL)
Expand Down Expand Up @@ -1082,6 +1085,7 @@ class ManageSIndexCreateController(ManageLeafCommandController):
def __init__(self):
self.required_modifiers = set(["line", "ns", "bin"])
self.modifiers = set(["set", "in", "ctx"])
self.meta_getter = GetClusterMetadataController(self.cluster)

@staticmethod
def _split_ctx_list(ctx_str: str) -> list[str]:
Expand Down Expand Up @@ -1267,7 +1271,7 @@ async def _do_create(self, line, bin_type: str):
cdt_ctx = None

if ctx_list:
builds = await self.cluster.info_build(nodes=self.nodes)
builds = await self.meta_getter.get_builds(nodes=self.nodes)

if not all(
[
Expand Down Expand Up @@ -1323,6 +1327,22 @@ async def do_string(self, line):
async def do_geo2dsphere(self, line):
await self._do_create(line, "geo2dsphere")

# Hack for auto-complete
async def do_blob(self, line):
builds = await self.meta_getter.get_builds()
if any(
[
version.LooseVersion(build)
< version.LooseVersion(constants.SERVER_SINDEX_BLOB_TYPE_FIRST_VERSION)
for build in builds.values()
]
):
raise ShellException(
f"Blob type secondary index is not supported on server version < {constants.SERVER_SINDEX_BLOB_TYPE_FIRST_VERSION}."
)

await self._do_create(line, "blob")


@CommandHelp(
"Delete a secondary index",
Expand Down
1 change: 1 addition & 0 deletions lib/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class JobType:
# server versions with critical changes
# TODO: Change to functions on the node
SERVER_INFO_BINS_REMOVAL_VERSION = "7.0"
SERVER_SINDEX_BLOB_TYPE_FIRST_VERSION = "7.0"
SERVER_SINDEX_ON_CDT_FIRST_VERSION = "6.1"
SERVER_QUERIES_ABORT_ALL_FIRST_VERSION = "6.0"
SERVER_39_BYTE_OVERHEAD_FIRST_VERSION = "6.0"
Expand Down
9 changes: 0 additions & 9 deletions lib/view/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,15 +2051,6 @@ def print_health_output(

###########################

@staticmethod
def get_summary_line_prefix(index, key):
s = " " * 3
s += (str(index) + ".").ljust(3)
s += " " * 2
s += key.ljust(19)
s += ":" + (" " * 2)
return s

@staticmethod
def _summary_cluster_table_view(stats: SummaryClusterDict, **ignore):
title = "Cluster Summary"
Expand Down
1 change: 1 addition & 0 deletions test/e2e/aerospike.conf → test/e2e/aerospike_6.x.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
${security_stanza}

service {
cluster-name 6.x-asadm-test
feature-key-file ${feature_path}
run-as-daemon false
work-directory ${state_directory}
Expand Down
94 changes: 94 additions & 0 deletions test/e2e/aerospike_latest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Aerospike Asadm Test Configuration Template
#
# Copyright (c) 2008-2023 Aerospike, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

${security_stanza}

service {
cluster-name 7.x-asadm-test
feature-key-file ${feature_path}
run-as-daemon false
work-directory ${state_directory}
pidfile ${state_directory}/asd.pid
proto-fd-max 1024
transaction-retry-ms 10000
transaction-max-ms 10000
}

logging {
console {
context any info
context security info
}
file ${log_path} {
context any info
}
}

mod-lua {
user-path ${udf_directory}
}

network {
service {
port ${service_port}
address any
access-address ${access_address}
}

heartbeat {
mode mesh
address any
port ${heartbeat_port}
interval 100
timeout 3
connect-timeout-ms 100
${peer_connection}
}

fabric {
port ${fabric_port}
address any
}

info {
port ${info_port}
address any
}
}

namespace ${namespace} {
replication-factor 2
default-ttl 0
storage-engine memory {
file /opt/aerospike/data/test.dat
filesize 1G
}
nsup-period 60
}

xdr {
dc DC1 {
namespace ${namespace} {
}
}
}
15 changes: 12 additions & 3 deletions test/e2e/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def start_server(
first_base,
index,
access_address="127.0.0.1",
docker_tag="latest",
template_file="aerospike_latest.conf",
template_content=None,
config_content=None,
):
Expand All @@ -299,7 +301,7 @@ def start_server(
base = first_base + 1000 * (index - 1)

if template_content is None and not config_content:
template_file = absolute_path("aerospike.conf")
template_file = absolute_path(template_file)
with codecs.open(template_file, "r", "UTF-8") as file_obj:
template_content = file_obj.read()

Expand Down Expand Up @@ -329,7 +331,7 @@ def start_server(
pass

container = DOCKER_CLIENT.containers.run(
"aerospike/aerospike-server-enterprise:latest",
f"aerospike/aerospike-server-enterprise:{docker_tag}",
command=cmd,
ports={
str(base) + "/tcp": str(base),
Expand All @@ -352,7 +354,12 @@ def start_server(


def start(
do_reset=True, num_nodes=DEFAULT_N_NODES, template_content=None, config_content=None
do_reset=True,
num_nodes=DEFAULT_N_NODES,
docker_tag="latest",
template_file="aerospike_latest.conf",
template_content=None,
config_content=None,
):
global CLIENT
global NODES
Expand All @@ -373,6 +380,8 @@ def start(
ip = start_server(
first_base,
index,
docker_tag=docker_tag,
template_file=template_file,
template_content=template_content,
config_content=config_content,
)
Expand Down
Loading

0 comments on commit 57ef5cd

Please sign in to comment.