Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ testpaths =
tests/where_test.py
norecursedirs = .git dist build *egg* tests/deprecated/*
python_functions = test*
env =
ARKOUDA_SERVER_HOST=localhost
ARKOUDA_SERVER_PORT=5555
ARKOUDA_FULL_STACK_TEST=True
ARKOUDA_NUMLOCALES=2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In our nightly XC/CS testing we export ARKOUDA_NUMLOCALES=16 -- does the env var take priority, or does the value in the .ini file? (Based on a quick test it seems like the value in the ini file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deferring to you for pytest expertise, but maybe we can prefix these with D: to not override command line settings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho You are correct and it sounds like it's dorking up your nightly test so I will take that out of pytest.ini.

@ronawho ronawho May 19, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine leaving it in if the .ini style is what python programmers will be used to. I think it'd just need to be D:ARKOUDA_NUMLOCALES=2 so that command line settings won't be overwritten

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho gotcha, okay

ARKOUDA_VERBOSE=False
25 changes: 13 additions & 12 deletions tests/base_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unittest
import subprocess, os, signal
from context import arkouda as ak
from util.test.util import start_arkouda_server, stop_arkouda_server, get_arkouda_numlocales
from util.test.util import get_arkouda_server, get_arkouda_numlocales,\

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused get_arkouda_server import

start_arkouda_server, stop_arkouda_server

'''
ArkoudaTest defines the base Arkouda test logic for starting up the arkouda_server at the
Expand All @@ -13,26 +14,24 @@
'''
class ArkoudaTest(unittest.TestCase):

verbose = bool(os.getenv('ARKOUDA_VERBOSE', 'False'))
port = os.getenv('ARKOUDA_SERVER_PORT')
server = os.getenv('ARKOUDA_SERVER_HOST')

port_server_set = port != None and server != None
full_stack_mode = bool(os.getenv('ARKOUDA_FULL_STACK_TEST', not port_server_set))
verbose = True if os.getenv('ARKOUDA_VERBOSE') == 'True' else False
port = int(os.getenv('ARKOUDA_SERVER_PORT', 5555))
server = os.getenv('ARKOUDA_SERVER_HOST', 'localhost')
full_stack_mode = True if os.getenv('ARKOUDA_FULL_STACK_TEST') == 'True' else False

@classmethod
def setUpClass(cls):
'''
If in full stack mode, Configures and starts the arkouda_server process
If in full stack mode, Configures and starts the arkouda_server process, noop otherwise

:return: None
:raise: RuntimeError if there is an error in configuring or starting arkouda_server
'''
if ArkoudaTest.full_stack_mode:
print('starting in full stack mode')
try:
nl = get_arkouda_numlocales()
(ArkoudaTest.server, ArkoudaTest.port, ArkoudaTest.ak_server) = start_arkouda_server(nl)
nl = int(get_arkouda_numlocales())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit but get_arkouda_numlocales() should already return an int

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, will clean this up.

start_arkouda_server(numlocales=nl, host=ArkoudaTest.server, port=ArkoudaTest.port)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI this breaks our nightly XC and CS testing. The original motivation for start_arkouda_server is to launch the server, and once the server is up and running have it report the hostname and port back via a file, since on clusters/supercomputers you don't know the host ahead of time. e.g. if I'm running on cori, you'll only know the server hostname once you've made it through the slurm queue and been given your nodes.

I think you could just stop passing the server to start_arkouda_server -- I'm not sure when you would need that in full stack mode.

@hokiegeek2 hokiegeek2 May 19, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho oh wow, okay, I can take this out or set server to None. I put it in there because I am pretty sure that specifying the server was being added to Chapel and I wanted to enable configuration of the host (hostname or IP address) for situations where the are multiple NICs for the host.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho okay, made it so the host can be none. Is passing in the ServerPort param okay:

`cmd = [get_arkouda_server(),
       '--logging={}'.format('true' if log else 'false'),
       '--v={}'.format('true' if verbose else 'false'),
       '--serverConnectionInfo={}'.format(connection_file),
       '-nl {}'.format(numlocales), '--ServerPort={}'.format(port)]`

Please confirm and I'll wrap up these updates and submit a pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Think I'm missing something -- looks like that's the same code that's on master

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho yes, it was merged into the master yesterday.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ooh, sorry -- I misread, I thought you were asking me if this new code snippet looked ok, but you were just asking if the code on master that passes the port is ok.

Yeah, we don't do anything with the port, that change is good.

print('Started arkouda_server in full stack test mode')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you're making changes, would you mind adding the number of locales to this print statement just so it's easy to see how many are being used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ronawho sure thing!

except Exception as e:
raise RuntimeError('in configuring or starting the arkouda_server: {}, check ' +
Expand Down Expand Up @@ -73,5 +72,7 @@ def tearDownClass(cls):
:return: None
'''
if ArkoudaTest.full_stack_mode:
print('Stopping arkouda_server in full stack test mode')
stop_arkouda_server()
try:
stop_arkouda_server()
except Exception as e:
raise RuntimeError(e)
27 changes: 19 additions & 8 deletions util/test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import os
import socket
import subprocess
import sys
import time

from collections import namedtuple
Expand Down Expand Up @@ -121,36 +120,48 @@ def kill_server(server_process):
"""
if server_process.poll() is None:
try:
logging.info('Attemping clean server shutdown')
logging.info('Attempting clean server shutdown')
stop_arkouda_server()
except ValueError as e:
pass

if server_process.poll() is None:
logging.warn('Attemping dirty server shutdown')
logging.warn('Attempting dirty server shutdown')
server_process.kill()

def start_arkouda_server(numlocales, verbose=False, log=False):
def start_arkouda_server(numlocales, verbose=False, log=False, port=5555, host=None):
"""
Start the Arkouda server and wait for it to start running. Connection info
is written to `get_arkouda_server_info_file()`.
Returns ServerInfo(host, port, process)

:param int numlocals: the number of arkouda_server locales
:param bool verbose: indicates whether to start the arkouda_server in verbose mode
:param bool log: indicates whether to start arkouda_server with logging enabled
:param int port: the desired arkouda_server port, defaults to 5555
:param str host: the desired arkouda_server host, defaults to None
:return: server host, port, and process
:rtype: ServerInfo(host, port, process)
"""
connection_file = get_arkouda_server_info_file()
with contextlib.suppress(FileNotFoundError):
os.remove(connection_file)

cmd = [get_arkouda_server(),
'--logging={}'.format('true' if log else 'false'),
'--v={}'.format('true' if verbose else 'false'),
'--serverConnectionInfo={}'.format(connection_file),
'-nl {}'.format(numlocales)]
'-nl {}'.format(numlocales), '--ServerPort={}'.format(port)]

logging.info('Starting "{}"'.format(cmd))
process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL)
atexit.register(kill_server, process)

(host, port) = read_server_and_port_from_file(connection_file)
if not host:
'''
If host is None, this means the host and port are to be retrieved
via the read_server_and_port_from_file method
'''
host, port = read_server_and_port_from_file(connection_file)
server_info = ServerInfo(host, port, process)
set_server_info(server_info)
return server_info
Expand Down