Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3176 exclude cache and logs from new template based projects #3866

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
8 changes: 5 additions & 3 deletions apps/dashboard/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def add_to_lookup(operation)
File.write(Project.lookup_file, new_table.to_yaml)
true
rescue StandardError => e
errors.add(operation, "Cannot update lookup file lookup file with error #{e.class}:#{e.message}")
errors.add(operation, "Cannot update lookup file with error #{e.class}:#{e.message}")
false
end

Expand All @@ -156,7 +156,7 @@ def remove_from_lookup
File.write(Project.lookup_file, new_table.to_yaml)
true
rescue StandardError => e
errors.add(:update, "Cannot update lookup file lookup file with error #{e.class}:#{e.message}")
errors.add(:update, "Cannot update lookup file with error #{e.class}:#{e.message}")
false
end

Expand Down Expand Up @@ -278,7 +278,9 @@ def save_new_scripts

def rsync_args
[
'rsync', '-rltp', '--exclude', 'scripts/*',
'rsync', '-rltp',
'--exclude', 'scripts/*',
'--exclude', '.ondemand/job_log.yml',
"#{template}/", project_dataroot.to_s
]
end
Expand Down
27 changes: 27 additions & 0 deletions apps/dashboard/test/models/projects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,33 @@ class ProjectsTest < ActiveSupport::TestCase
end
end

test 'create project with template does not copy project specific files' do
Dir.mktmpdir do |tmp|
template_dir = File.join(tmp,'template')
job_log_path = "#{template_dir}/.ondemand/job_log.yml"
launcher_id = '50r4nd0m'
cache_json_path = "#{template_dir}/.ondemand/scripts/#{launcher_id}/cache.json"

file_content = <<~HEREDOC
some multiline content
echo 'multiline content'
description: multiline content
HEREDOC
Pathname.new("#{template_dir}/.ondemand/scripts/#{launcher_id}").mkpath
File.open(job_log_path, 'w') { |file| file.write(file_content) }
File.open(cache_json_path, 'w') { |file| file.write(file_content) }

Configuration.stubs(:project_template_dir).returns(tmp)
projects_path = Pathname.new(tmp)
project = create_project(projects_path, template: template_dir)

assert Dir.glob(cache_json_path).present? &&
Dir.glob("#{project.directory}/.ondemand/scripts/*/cache.json").empty?
assert Dir.glob(job_log_path).present? &&
Dir.glob("#{project.directory}/.ondemand/*").exclude?("#{project.directory}/.ondemand/job_log.yml")
end
end

test 'creates .ondemand configuration directory' do
Dir.mktmpdir do |tmp|
projects_path = Pathname.new(tmp)
Expand Down
Loading