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
88 changes: 78 additions & 10 deletions tests/gold_tests/autest-site/trafficserver_plugins.test.ext
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,101 @@ Builds, installs, and enables an ATS plugin in the sandbox environment

import os

import hosts.output as host

def prepare_plugin(self, so_path, tsproc, plugin_args=""):

def prepare_plugin_helper(so_name, tsproc, plugin_args="", copy_plugin=True):
"""
Installs and enables an ATS plugin in the sandbox environment.

Args:
so_path (str): The path to a built .so file.
so_name (str): The path or filename of a built .so file.

tsproc (Process): The Traffic Server process whose plugin.config should
be configured to use the provided plugin.

plugin_args (str): The arguments to provide the plugin in the
plugin.config.

copy_plugin (bool): Whether to copy the plugin to the sandbox's plugin
directory.
"""

filename, extension = os.path.splitext(so_path)
filename, extension = os.path.splitext(so_name)
if extension != ".so":
raise ValueError('so_path argument must have a ".so" extension. '
'Received: {}'.format(so_path))
raise ValueError('so_name argument must have a ".so" extension. '
'Received: {}'.format(so_name))

# Copy the shared object to the sandbox directory.
plugin_dir = tsproc.Env['PROXY_CONFIG_PLUGIN_PLUGIN_DIR']
tsproc.Setup.Copy(so_path, plugin_dir)
if copy_plugin:
host.WriteVerbose(
"prepare_plugin",
"Copying down {} into {}.".format(so_name, plugin_dir))
tsproc.Setup.Copy(so_name, plugin_dir)
else:
host.WriteVerbose(
"prepare_plugin",
"Skipping copying {} into {} due to configuration.".format(
so_name, plugin_dir))

# Add an entry to plugin.config.
basename = os.path.basename(so_path)
tsproc.Disk.plugin_config.AddLine("{0} {1}".format(basename, plugin_args))
basename = os.path.basename(so_name)
config_line = "{0} {1}".format(basename, plugin_args)
host.WriteVerbose(
"prepare_plugin",
'Adding line to plugin.config: "{}"'.format(config_line))
tsproc.Disk.plugin_config.AddLine(config_line)


def prepare_test_plugin(self, so_path, tsproc, plugin_args=""):
"""
Installs and enables an ATS plugin in the sandbox environment.

Args:
so_path (str): The path to a built .so file.

tsproc (Process): The Traffic Server process whose plugin.config should
be configured to use the provided plugin.

plugin_args (str): The arguments to provide the plugin in the
plugin.config.
"""
if not os.path.exists(so_path):
raise ValueError(
'PrepareTestPlugin: file does not exist: "{}"'.format(so_path))

prepare_plugin_helper(so_path, tsproc, plugin_args, copy_plugin=True)


def prepare_installed_plugin(self, so_name, tsproc, plugin_args=""):
"""
Configures an already-installed ATS plugin in the sandbox environment.

Args:
so_name (str): The name of a plugin to configure.

tsproc (Process): The Traffic Server process whose plugin.config should
be configured to use the provided plugin.

plugin_args (str): The arguments to provide the plugin in the
plugin.config.
"""
if os.path.dirname(so_name):
raise ValueError(
'PrepareInstalledPlugin expects a filename not a path: '
'"{}"'.format(so_name))
prepare_plugin_helper(so_name, tsproc, plugin_args, copy_plugin=False)


"""
PrepareTestPlugin should be used for the test-specific plugins that need to
be copied down into the sandbox directory.
"""
ExtendTest(prepare_test_plugin, name="PrepareTestPlugin")

ExtendTest(prepare_plugin, name="PreparePlugin")
"""
PrepareInstalledPlugin should be used for the plugins installed via Automake
make install. They are already sym linked into the test directory via the
MakeATSProcess extension.
"""
ExtendTest(prepare_installed_plugin, name="PrepareInstalledPlugin")
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
ts.Disk.MakeConfigFile(regex_remap_conf_file).AddLine('//.*/ http://donotcare.test @status=204')

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'custom204plugin.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'custom204plugin.so'), ts)

Test.Setup.Copy(os.path.join(os.pardir, os.pardir, 'tools', 'tcp_client.py'))
Test.Setup.Copy('data')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify the requirement of our Plugin API.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'missing_ts_plugin_init.so'),
ts)
Expand All @@ -109,7 +109,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify a properly formed plugin works as expected.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'conf_remap_stripped.so'),
ts)
Expand All @@ -133,7 +133,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify a properly formed plugin works as expected.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'ssl_hook_test.so'),
ts)
Expand Down
6 changes: 3 additions & 3 deletions tests/gold_tests/command_argument/verify_remap_plugin.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify the requirement of our Plugin API.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'missing_ts_plugin_init.so'),
ts)
Expand All @@ -108,7 +108,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify a global plugin argument produces warning.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'ssl_hook_test.so'),
ts)
Expand All @@ -131,7 +131,7 @@ def create_ts_process():
"""
tr = Test.AddTestRun("Verify a properly formed plugin works as expected.")
ts = create_ts_process()
Test.PreparePlugin(
Test.PrepareTestPlugin(
os.path.join(Test.Variables.AtsTestPluginsDir,
'conf_remap_stripped.so'),
ts)
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/cont_schedule/schedule_on_pool.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'pool')
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'pool')

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/cont_schedule/schedule_on_thread.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'thread')
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'thread')

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/cont_schedule/thread_affinity.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'affinity')
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'affinity')

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/continuations/double.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
})

# add plugin to assist with test metrics
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
'continuations_verify.so'), ts)

comparator_command = '''
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/continuations/double_h2.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
})

# add plugin to assist with test metrics
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
'continuations_verify.so'), ts)

comparator_command = '''
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/continuations/openclose.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length:0\r\n\r\n",
"timestamp": "1469733493.993", "body": ""}

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
'ssntxnorder_verify.so'), ts)

# add response to the server dictionary
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/continuations/openclose_h2.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
ts.addSSLfile("ssl/server.pem")
ts.addSSLfile("ssl/server.key")

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir,
'ssntxnorder_verify.so'), ts)

# add response to the server dictionary
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/continuations/session_id.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ts.addSSLfile("ssl/server.pem")
ts.addSSLfile("ssl/server.key")

Test.PreparePlugin(os.path.join(Test.TestDirectory, 'plugins', '.libs', 'session_id_verify.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.TestDirectory, 'plugins', '.libs', 'session_id_verify.so'), ts)

ts.Disk.records_config.update({
'proxy.config.diags.debug.enabled': 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/logging/log_retention.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def get_command_to_rotate_thrice(self):
#
test = TestLogRetention(twelve_meg_log_space,
"Verify log rotation and deletion of plugin logs.")
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_log_interface.so'), test.ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_log_interface.so'), test.ts)

# Verify that the plugin's logs and other core logs were registered for deletion.
test.ts.Streams.stderr = Testers.ContainsExpression(
Expand Down
7 changes: 5 additions & 2 deletions tests/gold_tests/null_transform/null_transform.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
# limitations under the License.


import os
Test.Summary = '''
Test a basic null transform plugin
'''

Test.SkipUnless(
Condition.PluginExists('null_transform.so')
)

Test.ContinueOnFail = True

# Define default ATS
Expand Down Expand Up @@ -51,7 +54,7 @@
)

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'null_transform.so'), ts)
Test.PrepareInstalledPlugin('null_transform.so', ts)

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
6 changes: 3 additions & 3 deletions tests/gold_tests/pluginTest/cert_update/cert_update.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import ports

Test.Summary = '''
Test cert_update plugin.
'''

Test.SkipUnless(
Condition.HasProgram("openssl", "Openssl need to be installed on system for this test to work")
Condition.HasProgram("openssl", "Openssl need to be installed on system for this test to work"),
Condition.PluginExists('cert_update.so')
)

# Set up origin server
Expand Down Expand Up @@ -73,7 +73,7 @@
])

# Set up plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsExampleDir, 'plugins', 'c-api', '.libs', 'cert_update.so'), ts)
Test.PrepareInstalledPlugin('cert_update.so', ts)

# Server-Cert-Pre
# curl should see that Traffic Server presents bar.com cert from alice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os


Test.Summary = '''
Test client_context_dump plugin
'''

Test.SkipUnless(Condition.PluginExists('client_context_dump.so'))

# Set up ATS
ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True, enable_tls=True)

Expand Down Expand Up @@ -53,7 +53,7 @@
])

# Set up plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsExampleDir, 'plugins', 'c-api', '.libs', 'client_context_dump.so'), ts)
Test.PrepareInstalledPlugin('client_context_dump.so', ts)

# custom log comparison. Verify the two certs we have loaded are dumped
log = Test.Disk.File(ts.Variables.LOGDIR + '/client_context_dump.log', exists=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/pluginTest/cppapi/cppapi.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

ts = Test.MakeATSProcess("ts")

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_cppapi.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_cppapi.so'), ts)

tr = Test.AddTestRun()
tr.Processes.Default.StartBefore(Test.Processes.ts)
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/pluginTest/test_hooks/hook_add.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'proxy.config.url_remap.remap_required': 0,
})

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'hook_add_plugin.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'hook_add_plugin.so'), ts)

ts.Disk.remap_config.AddLine(
"map http://one http://127.0.0.1:{0}".format(server.Variables.Port)
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key'
)

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_hooks.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_hooks.so'), ts)

ts.Disk.remap_config.AddLine(
"map http://one http://127.0.0.1:{0}".format(server.Variables.Port)
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/pluginTest/tsapi/tsapi.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"map https://myhost.test:{0} http://127.0.0.1:{0}".format(server.Variables.Port)
)

Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_tsapi.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_tsapi.so'), ts)

tr = Test.AddTestRun()
# Probe server port to check if ready.
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/shutdown/emergency.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'emergency_shutdown.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'emergency_shutdown.so'), ts)

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/shutdown/fatal.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})

# Load plugin
Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'fatal_shutdown.so'), ts)
Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'fatal_shutdown.so'), ts)

# www.example.com Host
tr = Test.AddTestRun()
Expand Down
Loading