@@ -26,7 +26,7 @@ describe "SampleUtils" do
26
26
$? .success?.should be_true
27
27
end
28
28
29
- it " 'wait_for_install' should wait for a cnf to be installed" , tags: " happy-path" do
29
+ it " 'CNFManager. wait_for_install' should wait for a cnf to be installed" , tags: " happy-path" do
30
30
` ./cnf-conformance sample_coredns_setup`
31
31
$? .success?.should be_true
32
32
@@ -36,118 +36,118 @@ describe "SampleUtils" do
36
36
LOGGING .info helm
37
37
helm_install = ` #{ helm } install coredns stable/coredns`
38
38
LOGGING .info helm_install
39
- wait_for_install(" coredns-coredns" )
39
+ CNFManager . wait_for_install(" coredns-coredns" )
40
40
current_replicas = ` kubectl get deployments coredns-coredns -o=jsonpath='{.status.readyReplicas}'`
41
41
(current_replicas.to_i > 0 ).should be_true
42
42
end
43
43
44
- it " 'sample_setup' should set up a sample cnf" , tags: " happy-path" do
44
+ it " 'CNFManager. sample_setup' should set up a sample cnf" , tags: " happy-path" do
45
45
args = Sam ::Args .new
46
- sample_setup(config_file: " sample-cnfs/sample-generic-cnf" , release_name: " coredns" , deployment_name: " coredns-coredns" , helm_chart: " stable/coredns" , helm_directory: " helm_chart" , git_clone_url: " https://github.com/coredns/coredns.git" , wait_count: 0 )
46
+ CNFManager . sample_setup(config_file: " sample-cnfs/sample-generic-cnf" , release_name: " coredns" , deployment_name: " coredns-coredns" , helm_chart: " stable/coredns" , helm_directory: " helm_chart" , git_clone_url: " https://github.com/coredns/coredns.git" , wait_count: 0 )
47
47
# check if directory exists
48
48
(Dir .exists? " cnfs/coredns-coredns" ).should be_true
49
49
(File .exists?(" cnfs/coredns-coredns/cnf-conformance.yml" )).should be_true
50
50
(File .exists?(" cnfs/coredns-coredns/helm_chart/Chart.yaml" )).should be_true
51
- sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
51
+ CNFManager . sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
52
52
(Dir .exists? " cnfs/coredns-coredns" ).should be_false
53
53
end
54
54
55
- it " 'sample_setup_args' should set up a sample cnf from a argument" , tags: " happy-path" do
55
+ it " 'CNFManager. sample_setup_args' should set up a sample cnf from a argument" , tags: " happy-path" do
56
56
args = Sam ::Args .new
57
- sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 0 )
57
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 0 )
58
58
# check if directory exists
59
59
(Dir .exists? " cnfs/coredns-coredns" ).should be_true
60
60
(File .exists?(" cnfs/coredns-coredns/cnf-conformance.yml" )).should be_true
61
61
(File .exists?(" cnfs/coredns-coredns/helm_chart/Chart.yaml" )).should be_true
62
- sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
62
+ CNFManager . sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
63
63
(Dir .exists? " cnfs/coredns-coredns" ).should be_false
64
64
end
65
65
66
- it " 'sample_setup_args' should set up a sample cnf from a config file" , tags: " happy-path" do
66
+ it " 'CNFManager. sample_setup_args' should set up a sample cnf from a config file" , tags: " happy-path" do
67
67
args = Sam ::Args .new
68
- sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf/cnf-conformance.yml" , args: args, verbose: true , wait_count: 0 )
68
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf/cnf-conformance.yml" , args: args, verbose: true , wait_count: 0 )
69
69
# check if directory exists
70
70
(Dir .exists? " sample-cnfs/sample-generic-cnf" ).should be_true
71
71
(File .exists?(" cnfs/coredns-coredns/cnf-conformance.yml" )).should be_true
72
72
(File .exists?(" cnfs/coredns-coredns/helm_chart/Chart.yaml" )).should be_true
73
- sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
73
+ CNFManager . sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
74
74
(Dir .exists? " cnfs/coredns-coredns" ).should be_false
75
75
end
76
76
77
- it " 'sample_cleanup' should clean up a sample cnf from a argument" , tags: " happy-path" do
77
+ it " 'CNFManager. sample_cleanup' should clean up a sample cnf from a argument" , tags: " happy-path" do
78
78
args = Sam ::Args .new
79
- sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 0 )
80
- cleanup = sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
79
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 0 )
80
+ cleanup = CNFManager . sample_cleanup(config_file: " sample-cnfs/sample-generic-cnf" , verbose: true )
81
81
(cleanup).should be_true
82
82
(Dir .exists? " cnfs/coredns-coredns" ).should be_false
83
83
(File .exists?(" cnfs/coredns-coredns/cnf-conformance.yml" )).should be_false
84
84
(File .exists?(" cnfs/coredns-coredns/helm_chart/Chart.yaml" )).should be_false
85
85
end
86
86
87
- it " 'sample_setup_args' should be able to deploy using a helm_directory" , tags: " happy-path" do
87
+ it " 'CNFManager. sample_setup_args' should be able to deploy using a helm_directory" , tags: " happy-path" do
88
88
args = Sam ::Args .new
89
- sample_setup_args(sample_dir: " sample-cnfs/sample_privileged_cnf" , deploy_with_chart: false , args: args, verbose: true , wait_count: 0 )
89
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample_privileged_cnf" , deploy_with_chart: false , args: args, verbose: true , wait_count: 0 )
90
90
(Dir .exists? " cnfs/privileged-coredns-coredns" ).should be_true
91
91
# should not clone
92
92
(Dir .exists? " cnfs/privileged-coredns-coredns/privileged-coredns" ).should be_false
93
93
(File .exists? " cnfs/privileged-coredns-coredns/cnf-conformance.yml" ).should be_true
94
94
(File .exists? " cnfs/privileged-coredns-coredns/chart/Chart.yaml" ).should be_true
95
- sample_cleanup(config_file: " sample-cnfs/sample_privileged_cnf" , verbose: true )
95
+ CNFManager . sample_cleanup(config_file: " sample-cnfs/sample_privileged_cnf" , verbose: true )
96
96
(Dir .exists? " cnfs/privileged-coredns-coredns" ).should be_false
97
97
end
98
98
99
99
it " 'cnf_destination_dir' should return the full path of the potential destination cnf directory based on the deployment name" , tags: " WIP" do
100
100
args = Sam ::Args .new
101
- cnf_destination_dir(" spec/fixtures/cnf-conformance.yml" ).should contain(" /cnfs/coredns-coredns" )
101
+ CNFManager . cnf_destination_dir(" spec/fixtures/cnf-conformance.yml" ).should contain(" /cnfs/coredns-coredns" )
102
102
end
103
103
104
- it " 'cnf_config_list' should return a list of all of the config files from the cnf directory" , tags: " happy-path" do
104
+ it " 'CNFManager. cnf_config_list' should return a list of all of the config files from the cnf directory" , tags: " happy-path" do
105
105
args = Sam ::Args .new
106
- sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 1 )
107
- sample_setup_args(sample_dir: " sample-cnfs/sample_privileged_cnf" , args: args, verbose: true )
108
- cnf_config_list()[0 ].should contain(" coredns-coredns/#{ CONFIG_FILE } " )
106
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 1 )
107
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample_privileged_cnf" , args: args, verbose: true )
108
+ CNFManager . cnf_config_list()[0 ].should contain(" coredns-coredns/#{ CONFIG_FILE } " )
109
109
end
110
110
111
- it " 'helm_repo_add' should add a helm repo if the helm repo is valid" , tags: " happy-path" do
111
+ it " 'CNFManager. helm_repo_add' should add a helm repo if the helm repo is valid" , tags: " happy-path" do
112
112
args = Sam ::Args .new
113
- sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 1 )
114
- # helm_repo_add.should eq(true)
113
+ CNFManager . sample_setup_args(sample_dir: " sample-cnfs/sample-generic-cnf" , args: args, verbose: true , wait_count: 1 )
114
+ # CNFManager. helm_repo_add.should eq(true)
115
115
args = Sam ::Args .new([" cnf-config=./sample-cnfs/sample-generic-cnf/cnf-conformance.yml" ])
116
- helm_repo_add(args: args).should eq(true )
116
+ CNFManager . helm_repo_add(args: args).should eq(true )
117
117
end
118
118
119
- it " 'helm_repo_add' should return false if the helm repo is invalid" , tags: " happy-path" do
120
- helm_repo_add(" invalid" , " invalid" ).should eq(false )
119
+ it " 'CNFManager. helm_repo_add' should return false if the helm repo is invalid" , tags: " happy-path" do
120
+ CNFManager . helm_repo_add(" invalid" , " invalid" ).should eq(false )
121
121
end
122
122
123
- it " 'validate_cnf_conformance_yml' (function) should pass, when a cnf has a valid config file yml" , tags: [" unhappy-path" , " validate_config" ] do
123
+ it " 'CNFManager. validate_cnf_conformance_yml' (function) should pass, when a cnf has a valid config file yml" , tags: [" unhappy-path" , " validate_config" ] do
124
124
args = Sam ::Args .new([" cnf-config=sample-cnfs/sample-coredns-cnf/cnf-conformance.yml" ])
125
125
126
- yml = parsed_config_file(ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
126
+ yml = CNFManager . parsed_config_file(CNFManager . ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
127
127
LOGGING .info yml.inspect
128
128
(" #{ yml.get(" release_name" ).as_s? } " ).should eq(" coredns" )
129
129
130
- valid, command_output = validate_cnf_conformance_yml(yml)
130
+ valid, command_output = CNFManager . validate_cnf_conformance_yml(yml)
131
131
132
132
(valid).should eq(true )
133
133
(command_output).should eq (nil )
134
134
end
135
135
136
- it " 'validate_cnf_conformance_yml' (command) should pass, when a cnf has a valid config file yml" , tags: [" unhappy-path" , " validate_config" ] do
136
+ it " 'CNFManager. validate_cnf_conformance_yml' (command) should pass, when a cnf has a valid config file yml" , tags: [" unhappy-path" , " validate_config" ] do
137
137
response_s = ` ./cnf-conformance validate_config cnf-config=sample-cnfs/sample-coredns-cnf/cnf-conformance.yml`
138
138
$? .success?.should be_true
139
139
(/PASSED: CNF configuration validated/ =~ response_s).should_not be_nil
140
140
end
141
141
142
142
143
- it " 'validate_cnf_conformance_yml' (function) should warn, but be valid when a cnf config file yml has fields that are not a part of the validation type" , tags: [" unhappy-path" , " validate_config" ] do
143
+ it " 'CNFManager. validate_cnf_conformance_yml' (function) should warn, but be valid when a cnf config file yml has fields that are not a part of the validation type" , tags: [" unhappy-path" , " validate_config" ] do
144
144
args = Sam ::Args .new([" cnf-config=./spec/fixtures/cnf-conformance-unmapped-keys-and-subkeys.yml" ])
145
145
146
- yml = parsed_config_file(ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
146
+ yml = CNFManager . parsed_config_file(CNFManager . ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
147
147
LOGGING .info yml.inspect
148
148
(" #{ yml.get(" release_name" ).as_s? } " ).should eq(" coredns" )
149
149
150
- status, warning_output = validate_cnf_conformance_yml(yml)
150
+ status, warning_output = CNFManager . validate_cnf_conformance_yml(yml)
151
151
152
152
LOGGING .warn " WARNING: #{ warning_output } "
153
153
@@ -156,7 +156,7 @@ describe "SampleUtils" do
156
156
end
157
157
158
158
159
- it " 'validate_cnf_conformance_yml' (command) should warn, but be valid when a cnf config file yml has fields that are not a part of the validation type" , tags: [" unhappy-path" , " validate_config" ] do
159
+ it " 'CNFManager. validate_cnf_conformance_yml' (command) should warn, but be valid when a cnf config file yml has fields that are not a part of the validation type" , tags: [" unhappy-path" , " validate_config" ] do
160
160
response_s = ` ./cnf-conformance validate_config cnf-config=spec/fixtures/cnf-conformance-unmapped-keys-and-subkeys.yml`
161
161
$? .success?.should be_true
162
162
(/WARNING: Unmapped cnf_conformance.yml keys. Please add them to the validator/ =~ response_s).should_not be_nil
@@ -165,28 +165,28 @@ describe "SampleUtils" do
165
165
end
166
166
167
167
168
- it " 'validate_cnf_conformance_yml' (function) should fail when an invalid cnf config file yml is used" , tags: [" unhappy-path" , " validate_config" ] do
168
+ it " 'CNFManager. validate_cnf_conformance_yml' (function) should fail when an invalid cnf config file yml is used" , tags: [" unhappy-path" , " validate_config" ] do
169
169
args = Sam ::Args .new([" cnf-config=spec/fixtures/cnf-conformance-invalid-and-unmapped-keys.yml" ])
170
170
171
- yml = parsed_config_file(ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
171
+ yml = CNFManager . parsed_config_file(CNFManager . ensure_cnf_conformance_yml_path(args.named[" cnf-config" ].as(String )))
172
172
LOGGING .info yml.inspect
173
173
(" #{ yml.get(" release_name" ).as_s? } " ).should eq(" coredns" )
174
174
175
- status, warning_output = validate_cnf_conformance_yml(yml)
175
+ status, warning_output = CNFManager . validate_cnf_conformance_yml(yml)
176
176
177
177
(status).should eq(false )
178
178
(warning_output).should eq(nil )
179
179
end
180
180
181
- it " 'validate_cnf_conformance_yml' (command) should fail when an invalid cnf config file yml is used" , tags: [" unhappy-path" , " validate_config" ] do
181
+ it " 'CNFManager. validate_cnf_conformance_yml' (command) should fail when an invalid cnf config file yml is used" , tags: [" unhappy-path" , " validate_config" ] do
182
182
response_s = ` ./cnf-conformance validate_config cnf-config=spec/fixtures/cnf-conformance-invalid-and-unmapped-keys.yml`
183
183
$? .success?.should be_true
184
184
185
185
(/ERROR: cnf_conformance.yml field validation error/ =~ response_s).should_not be_nil
186
186
(/FAILURE: Critical Error with CNF Configuration. Please review USAGE.md for steps to set up a valid CNF configuration file/ =~ response_s).should_not be_nil
187
187
end
188
188
189
- it " 'validate_cnf_conformance_yml' (command) should pass, for all sample-cnfs" , tags: [" unhappy-path" , " validate_config" ] do
189
+ it " 'CNFManager. validate_cnf_conformance_yml' (command) should pass, for all sample-cnfs" , tags: [" unhappy-path" , " validate_config" ] do
190
190
191
191
get_dirs = Dir .entries(" sample-cnfs" )
192
192
dir_list = get_dirs - [" ." , " .." ]
@@ -200,7 +200,7 @@ describe "SampleUtils" do
200
200
end
201
201
end
202
202
203
- it " 'validate_cnf_conformance_yml' (command) should pass, for all example-cnfs" , tags: [" unhappy-path" , " validate_config" ] do
203
+ it " 'CNFManager. validate_cnf_conformance_yml' (command) should pass, for all example-cnfs" , tags: [" unhappy-path" , " validate_config" ] do
204
204
205
205
get_dirs = Dir .entries(" example-cnfs" )
206
206
dir_list = get_dirs - [" ." , " .." ]
0 commit comments