!36008 Add Test Case for Compression && Encrypt

Merge pull request !36008 from zhangzhaoju/master_jdk_change
This commit is contained in:
i-robot 2022-06-21 03:47:08 +00:00 committed by Gitee
commit 01ca00b92d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 180 additions and 21 deletions

View File

@ -175,4 +175,5 @@ if __name__ == "__main__":
import time
time.sleep(0.3)
print(cmd_server)
subprocess.call(['bash', '-c', cmd_server])

View File

@ -71,18 +71,19 @@ fi
# get resources for v1.8.0
# to support rollback we provide multi version of data
mkdir -p ${base_path}/fl_resources
if [ ! -f ${FL_RESOURCE_PATH}/v1.8.0.tar ]; then
echo "${FL_RESOURCE_PATH}/v1.8.0.tar not exist."
if [ ! -f ${FL_RESOURCE_PATH}/v1.8.0_encrypt_st.tar ]; then
echo "${FL_RESOURCE_PATH}/v1.8.0_encrypt_st not exist."
exit 1
fi
tar -xf ${FL_RESOURCE_PATH}/v1.8.0.tar -C ${base_path}/fl_resources
tar -xf ${FL_RESOURCE_PATH}/v1.8.0_encrypt_st.tar -C ${base_path}/fl_resources
export FL_RESOURCE_PATH=${base_path}/fl_resources
export X86_PKG_PATH=${X86_PKG_PATH}
export FL_JDK_PATH=${FL_JDK_PATH}
export FL_MODELS_PATH=${FL_MODELS_PATH}
pytest -s -v -m fl_cluster st_script
pytest -s -v st_script
ret=$?
exit $ret

View File

@ -33,6 +33,8 @@ class BaseCase:
start_fl_job_time_window = 30000
update_model_time_window = 30000
encrypt_type = "NOT_ENCRYPT"
download_compress_type = "NO_COMPRESS"
upload_compress_type = "NO_COMPRESS"
# ENV for Client
lite_lib_path = os.path.join(script_path, "libs")

View File

@ -62,11 +62,12 @@ class TestMobileTrain(BaseCase):
"--fl_iteration_num={} --start_fl_job_time_window={} " \
"--update_model_time_window={} --encrypt_type={} " \
"--enable_ssl={} --config_file_path={} " \
"--upload_compress_type={} ----download_compress_type={}" \
.format(self.server_path, self.scheduler_ip, self.scheduler_port, self.fl_server_port,
self.server_num, self.worker_num, self.start_fl_job_threshold, self.client_batch_size,
self.client_epoch_num, self.fl_iteration_num, self.start_fl_job_time_window,
self.update_model_time_window, self.encrypt_type, self.enable_ssl,
self.config_file_path)
self.config_file_path, self.upload_compress_type, self.download_compress_type)
print("exec:{}".format(start_server_cmd), flush=True)
os.system(start_server_cmd)
@ -105,18 +106,94 @@ class TestMobileTrain(BaseCase):
assert info.find('none') == -1
return True
# @pytest.mark.skipif(2 > 1, reason="only support test in fl ST frame")
def test_train_lenet(self):
def test_train_lenet_nc_ne(self):
"""
fist case
:return:
Feature: FL train process
Description: test train lenet no compress, no encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "NOT_ENCRYPT"
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=30)
self.check_client_result(out_time=60)
def test_train_lenet_compress_ne(self):
"""
Feature: FL train process
Description: test train lenet with compress, no encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "QUANT"
self.upload_compress_type = "DIFF_SPARSE_QUANT"
self.encrypt_type = "NOT_ENCRYPT"
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=60)
def test_train_lenet_nc_dp(self):
"""
Feature: FL train process
Description: test train lenet with no compress, dp encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "DP_ENCRYPT"
self.client_num = 3
self.start_fl_job_threshold = 3
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
def test_train_lenet_nc_pw(self):
"""
Feature: FL train process
Description: test train lenet with no compress, pw encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "PW_ENCRYPT"
self.client_num = 4
self.start_fl_job_threshold = 4
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
def test_train_lenet_nc_signds(self):
"""
Feature: FL train process
Description: test train lenet with no compress, signds encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "SIGNDS"
self.client_num = 3
self.start_fl_job_threshold = 3
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
@pytest.mark.fl_cluster

View File

@ -69,7 +69,7 @@ class TestVaeTrain(BaseCase):
dp_delta = 0.9
dp_norm_clip = 0.01
cipher_time_window = 30000000
reconstruct_secrets_threshold = 2
reconstruct_secrets_threshold = 3
start_server_cmd = "cd {}; python run_server.py --scheduler_ip={} --scheduler_port={} --fl_server_port={} " \
"--server_num={} --worker_num={} --start_fl_job_threshold={} --client_batch_size={} " \
"--client_epoch_num={} --fl_iteration_num={} --start_fl_job_time_window={} " \
@ -77,11 +77,13 @@ class TestVaeTrain(BaseCase):
"--sign_k={} --sign_eps={} --sign_thr_ratio={} --sign_global_lr={} --dp_delta={} " \
"--dp_norm_clip={} --cipher_time_window={} " \
"--reconstruct_secrets_threshold={} --config_file_path={} " \
"--upload_compress_type={} --download_compress_type={}" \
.format(self.server_path, self.scheduler_ip, self.scheduler_port, self.fl_server_port, self.server_num,
self.worker_num, self.start_fl_job_threshold, self.client_batch_size, self.client_epoch_num,
self.fl_iteration_num, self.start_fl_job_time_window, self.update_model_time_window,
self.encrypt_type, sign_k, sign_eps, sign_thr_ratio, sign_global_lr, dp_delta, dp_norm_clip,
cipher_time_window, reconstruct_secrets_threshold, self.config_file_path)
cipher_time_window, reconstruct_secrets_threshold, self.config_file_path,
self.upload_compress_type, self.download_compress_type)
print("exec:{}".format(start_server_cmd), flush=True)
os.system(start_server_cmd)
@ -118,19 +120,95 @@ class TestVaeTrain(BaseCase):
info = result.read()
result.close()
# after refresh the resource change to int(info) == 0
assert int(info) >= 0
assert int(info) == 0
# @pytest.mark.skipif(2 > 1, reason="only support test in fl ST frame")
def test_train_vae(self):
def test_train_vae_nc_ne(self):
"""
fist case
:return:
Feature: FL train process
Description: test train vae no compress, no encrypt
Expectation: train success
"""
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "NOT_ENCRYPT"
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=30)
self.check_client_result(out_time=60)
def test_train_vae_compress_ne(self):
"""
Feature: FL train process
Description: test train vae with compress, no encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "QUANT"
self.upload_compress_type = "DIFF_SPARSE_QUANT"
self.encrypt_type = "NOT_ENCRYPT"
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=60)
def test_train_vae_nc_dp(self):
"""
Feature: FL train process
Description: test train vae with no compress, dp encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "DP_ENCRYPT"
self.client_num = 3
self.start_fl_job_threshold = 3
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
def test_train_vae_nc_pw(self):
"""
Feature: FL train process
Description: test train vae with no compress, pw encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "PW_ENCRYPT"
self.client_num = 4
self.start_fl_job_threshold = 4
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
def test_train_vae_nc_signds(self):
"""
Feature: FL train process
Description: test train vae with no compress, signds encrypt
Expectation: train success
"""
print("Class:{}, function:{}".format(self.__class__.__name__, inspect.stack()[1][3]), flush=True)
self.download_compress_type = "NO_COMPRESS"
self.upload_compress_type = "NO_COMPRESS"
self.encrypt_type = "SIGNDS"
self.client_num = 3
self.start_fl_job_threshold = 3
self.fl_iteration_num = 2
self.start_scheduler()
self.start_server()
self.wait_cluster_ready(out_time=30)
self.start_client()
self.check_client_result(out_time=300)
@pytest.mark.fl_cluster
@ -192,7 +270,7 @@ class TestVaeInference(BaseCase):
result.close()
assert int(info) == 1
def test_infer_lenet(self):
def test_infer_vae(self):
"""
fist case
:return: