From 1414bd7d85f0efddc96ba3c0b2355fada2943a8e Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 28 Jun 2022 22:34:34 +0900 Subject: [PATCH] Remove deprecated swift::test_file ... because it was deprecated during Yoga cycle[1]. [1] dd3a5bbf0dfd98fe9bf27e130a317640a1621bf5 Change-Id: Ia990bffee54f6c0344060f16cf418a6c39ee81fc --- manifests/test_file.pp | 50 -------- .../remove-test_file-b6297826dcc22267.yaml | 4 + spec/classes/swift_test_file_spec.rb | 59 --------- templates/swift_keystone_test.erb | 115 ------------------ 4 files changed, 4 insertions(+), 224 deletions(-) delete mode 100644 manifests/test_file.pp create mode 100644 releasenotes/notes/remove-test_file-b6297826dcc22267.yaml delete mode 100644 spec/classes/swift_test_file_spec.rb delete mode 100644 templates/swift_keystone_test.erb diff --git a/manifests/test_file.pp b/manifests/test_file.pp deleted file mode 100644 index 819e0cc3..00000000 --- a/manifests/test_file.pp +++ /dev/null @@ -1,50 +0,0 @@ -# == Class: swift::test_file -# -# DEPRECATED !! -# Deploys a file that can be used to verify your swift installation. -# -# === Parameters -# -# [*password*] -# password used with tenant/user combination against auth_server. Required. -# [*auth_server*] -# server hosting keystone. Optional. Defaults to 127.0.0.1. -# [*tenant*] -# tenant used for authentication (required for retrieval of catalog). Optional. Defaults to openstack. -# [*user*] -# authenticated user. Optional. Defaults to 'admin'. -# -# === Examples -# -# class { 'swift::test_file': -# auth_server => '172.16.0.25', -# tenant => 'services', -# user => 'swift', -# password => 'admin_password', -# } -# -# === Authors -# -# Dan Bode -# -# === Copyright -# -# Copyright 2011 PuppetLabs. -# -class swift::test_file ( - $password, - $auth_server = '127.0.0.1', - $tenant = 'openstack', - $user = 'admin' -) { - - include swift::deps - - warning('The swift::test_file class is deprecated and will be removed in a future release.') - - file { '/tmp/swift_test_file.rb': - mode => '0755', - content => template('swift/swift_keystone_test.erb'), - tag => 'swift-file', - } -} diff --git a/releasenotes/notes/remove-test_file-b6297826dcc22267.yaml b/releasenotes/notes/remove-test_file-b6297826dcc22267.yaml new file mode 100644 index 00000000..96e883ab --- /dev/null +++ b/releasenotes/notes/remove-test_file-b6297826dcc22267.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + The ``swift::test_file`` class has been removed. diff --git a/spec/classes/swift_test_file_spec.rb b/spec/classes/swift_test_file_spec.rb deleted file mode 100644 index b8b577a8..00000000 --- a/spec/classes/swift_test_file_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'spec_helper' - -describe 'swift::test_file' do - - let :default_params do - {:password => 'foo'} - end - - shared_examples 'swift::test_file' do - describe 'with defaults' do - let :params do - default_params - end - - it 'should create a reasonable test file' do - verify_contents(catalogue, '/tmp/swift_test_file.rb', - [ - 'proxy_local_net_ip="127.0.0.1"', - "user='openstack:admin'", - "password='foo'" - ] - ) - end - end - - describe 'when overriding' do - let :params do - default_params.merge({ - :auth_server => '127.0.0.2', - :tenant => 'tenant', - :user => 'user', - :password => 'password' - }) - end - - it 'should create a configured test file' do - verify_contents(catalogue, '/tmp/swift_test_file.rb', - [ - 'proxy_local_net_ip="127.0.0.2"', - "user='tenant:user'", - "password='password'" - ] - ) - end - end - end - - on_supported_os({ - :supported_os => OSDefaults.get_supported_os - }).each do |os,facts| - context "on #{os}" do - let (:facts) do - facts.merge(OSDefaults.get_facts()) - end - - it_configures 'swift::test_file' - end - end -end diff --git a/templates/swift_keystone_test.erb b/templates/swift_keystone_test.erb deleted file mode 100644 index 377f5890..00000000 --- a/templates/swift_keystone_test.erb +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby -# -# This is a script that uses -# instructions here: https://docs.openstack.org/swift/latest/howto_installmultinode.html -# Even though I expect this script will work with a wide range -# of swift versions, it is currently only tested with: 1.4.6 -require 'open3' -require 'fileutils' - -# connection variables -proxy_local_net_ip="<%= @auth_server %>" -user='<%= @tenant %>:<%= @user %>' -password='<%= @password %>' - -## headers for curl requests -#user_header="-H 'X-Storage-User: #{user}'" -#password_header="-H 'X-Storage-Pass: #{password}'" -#get_cred_command="curl -k -v #{user_header} #{password_header} http://#{proxy_local_net_ip}:5000/v2.0/" -# -## verify that we can retrieve credentials from our user -#result_hash = {} -#puts "getting credentials: #{get_cred_command}" -#Open3.popen3(get_cred_command) do |stdin, stdout, stderr| -# result_hash[:stderr] = stderr.read -# result_hash[:stderr].split("\n").each do |line| -# if line =~ /^< HTTP\/\d\.\d (\d\d\d)/ -# result_hash[:status_code]=$1 -# end -# if line =~ /< X-Storage-Url: (http\S+)/ -# result_hash[:auth_url]=$1 -# end -# if line =~ /< X-Storage-Token: (AUTH_\S+)/ -# result_hash[:auth_token]=$1 -# end -# end -#end -#raise(Exception, "Call to get auth tokens failed:\n#{result_hash[:stderr]}") unless result_hash[:status_code] == '200' -# -## verify that the credentials are valid -#auth_token_header="-H 'X-Auth-Token: #{result_hash[:auth_token]}'" -#puts auth_token_header -#get_account_head="curl -k -v #{auth_token_header} #{result_hash[:auth_url]}" -## what is the expected code? -#puts "verifying connection auth: #{get_account_head}" -#Open3.popen3(get_account_head) do |stdin, stdout, stderr| -# #puts stdout.read -# #puts stderr.read -#end - - -swift_command_prefix="swift -A http://#{proxy_local_net_ip}:5000/v2.0/ -V 2 -U #{user} -K #{password}" - -swift_test_command="#{swift_command_prefix} stat" - -puts "Testing swift: #{swift_test_command}" -status_hash={} -Open3.popen3(swift_test_command) do |stdin, stdout, stderr| - status_hash[:stdout] = stdout.read - status_hash[:stderr] = stderr.read - status_hash[:stdout].split("\n").each do |line| - if line =~ /\s*Containers:\s+(\d+)/ - status_hash[:containers] = $1 - end - if line =~ /\s*Objects:\s+(\d+)/ - status_hash[:objects] = $1 - end - end -end - -unless(status_hash[:containers] =~ /\d+/ and status_hash[:objects] =~ /\d+/) - raise(Exception, "Expected to find the number of containers/objects:\n#{status_hash[:stdout]}\n#{status_hash[:stderr]}") -else - puts "found containers/objects: #{status_hash[:containers]}/#{status_hash[:objects]}" -end - -# test that we can upload something -File.open('/tmp/foo1', 'w') do |fh| - fh.write('test1') -end - -container = 'my_container' - -swift_upload_command="#{swift_command_prefix} upload #{container} /tmp/foo1" -puts "Uploading file to swift with command: #{swift_upload_command}" - -Open3.popen3(swift_upload_command) do |stdin, stdout, stderr| - puts stdout.read - puts stderr.read -end - -# test that we can download the thing that we uploaded -download_test_dir = '/tmp/test/downloadtest/' -FileUtils.rm_rf download_test_dir -FileUtils.mkdir_p download_test_dir - -swift_download_command="#{swift_command_prefix} download #{container}" -puts "Downloading file with command: #{swift_download_command}" -Dir.chdir(download_test_dir) do - Open3.popen3(swift_download_command) do |stdin, stdout, stderr| - puts stdout.read - puts stderr.read - end -end - -expected_file = File.join(download_test_dir, 'tmp', 'foo1') - -if File.exists?(expected_file) - if File.read(expected_file) == 'test1' - puts "Dude!!!! It actually seems to work, we can upload and download files!!!!" - else - raise(Exception, "So close, but the contents of the downloaded file are not what I expected: Got: #{File.read(expected_file)}, expected: test1") - end -else - raise(Exception, "file #{expected_file} did not exist somehow, probably b/c swift is not installed correctly") -end