1 ################################################################################
2 # Copyright (c) 2020 AT&T Intellectual Property. #
4 # Licensed under the Apache License, Version 2.0 (the "License"); #
5 # you may not use this file except in compliance with the License. #
6 # You may obtain a copy of the License at #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
10 # Unless required by applicable law or agreed to in writing, software #
11 # distributed under the License is distributed on an "AS IS" BASIS, #
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13 # See the License for the specific language governing permissions and #
14 # limitations under the License. #
15 ################################################################################
19 from xapp_onboarder.server import settings
20 from xapp_onboarder.helm_controller.artifacts_manager import format_artifact_dir_size, get_dir_size, trim_artifact_dir
21 def test_trim_thread():
22 path = settings.CHART_WORKSPACE_PATH
23 if os.path.exists(path):
27 size_limit = format_artifact_dir_size()
28 f = open(path+'/mock_size_file',"wb")
29 f.seek(int(size_limit)+100000000)
33 artifact_dir_size = get_dir_size(start_path=path)
34 assert size_limit < artifact_dir_size, 'Fail to write large files'
37 artifact_dir_size = get_dir_size(start_path=path)
39 assert size_limit > artifact_dir_size, 'Fail to trim'