|
54 | 54 | DDPJob,
|
55 | 55 | torchx_runner,
|
56 | 56 | )
|
| 57 | +from codeflare_sdk.utils.generate_cert import ( |
| 58 | + generate_ca_cert, |
| 59 | + generate_tls_cert, |
| 60 | + export_env, |
| 61 | +) |
| 62 | + |
57 | 63 | import openshift
|
58 | 64 | from openshift import OpenShiftPythonException
|
59 | 65 | from openshift.selector import Selector
|
@@ -1980,6 +1986,35 @@ def test_AWManager_submit_remove(mocker, capsys):
|
1980 | 1986 | assert testaw.submitted == False
|
1981 | 1987 |
|
1982 | 1988 |
|
| 1989 | +def test_generate_ca_cert(): |
| 1990 | + """ |
| 1991 | + test the function codeflare_sdk.utils.generate_ca_cert generates the correct outputs |
| 1992 | + """ |
| 1993 | + key, certificate = generate_ca_cert() |
| 1994 | + assert type(key) == str |
| 1995 | + assert type(certificate) == str |
| 1996 | + |
| 1997 | + |
| 1998 | +def test_generate_tls_cert(mocker): |
| 1999 | + """ |
| 2000 | + test the function codeflare_sdk.utils.generate_ca_cert generates the correct outputs |
| 2001 | + """ |
| 2002 | + ca_private_key_bytes, _ = generate_ca_cert() |
| 2003 | + |
| 2004 | + mocker.patch("openshift.invoke", return_value=openshift.Result("fake")) |
| 2005 | + mocker.patch("openshift.Result.out", return_value=ca_private_key_bytes) |
| 2006 | + generate_tls_cert("cluster", "namespace") |
| 2007 | + assert os.path.exists("tls-cluster-namespace") |
| 2008 | + |
| 2009 | + |
| 2010 | +def test_export_env(): |
| 2011 | + """ |
| 2012 | + test the function codeflare_sdk.utils.export_ev generates the correct outputs |
| 2013 | + """ |
| 2014 | + export_env("cluster_name", "namespace") |
| 2015 | + assert os.environ["RAY_USE_TLS"] == "1" |
| 2016 | + |
| 2017 | + |
1983 | 2018 | # Make sure to keep this function and the following function at the end of the file
|
1984 | 2019 | def test_cmd_line_generation():
|
1985 | 2020 | os.system(
|
|
0 commit comments