|
| 1 | +# shellcheck shell=bash |
| 2 | + |
| 3 | +Describe "Milvus embedded MinIO credential contract" |
| 4 | + render_contract() { |
| 5 | + helm template milvus .. | ruby -ryaml -e ' |
| 6 | + documents = YAML.load_stream(ARGF.read).compact |
| 7 | + component = documents.find do |document| |
| 8 | + document["kind"] == "ComponentDefinition" && |
| 9 | + document.dig("spec", "serviceKind") == "milvus-minio" |
| 10 | + end |
| 11 | + abort "milvus-minio ComponentDefinition not rendered" unless component |
| 12 | +
|
| 13 | + account = component.dig("spec", "systemAccounts").find do |item| |
| 14 | + item["name"] == "admin" |
| 15 | + end |
| 16 | + abort "admin system account not rendered" unless account |
| 17 | +
|
| 18 | + policy = account["passwordGenerationPolicy"] || {} |
| 19 | + puts "policy=#{policy.values_at("length", "numDigits", "numSymbols", "letterCase").join(",")}" |
| 20 | +
|
| 21 | + vars = component.dig("spec", "vars").to_h { |item| [item["name"], item] } |
| 22 | + user_ref = vars.dig("MINIO_ROOT_USER", "valueFrom", "credentialVarRef") || {} |
| 23 | + password_ref = vars.dig("MINIO_ROOT_PASSWORD", "valueFrom", "credentialVarRef") || {} |
| 24 | + puts "user=#{user_ref.values_at("name", "optional", "username").join(",")}" |
| 25 | + puts "password=#{password_ref.values_at("name", "optional", "password").join(",")}" |
| 26 | + puts "server_legacy=#{vars.key?("MINIO_ACCESS_KEY") || vars.key?("MINIO_SECRET_KEY")}" |
| 27 | +
|
| 28 | + standalone = documents.find do |document| |
| 29 | + document["kind"] == "ComponentDefinition" && |
| 30 | + document.dig("spec", "serviceKind") == "milvus" && |
| 31 | + document["metadata"]["name"].include?("standalone") |
| 32 | + end |
| 33 | + abort "milvus standalone ComponentDefinition not rendered" unless standalone |
| 34 | +
|
| 35 | + client_vars = standalone.dig("spec", "vars").to_h { |item| [item["name"], item] } |
| 36 | + access_ref = client_vars.dig("MINIO_ACCESS_KEY", "valueFrom", "credentialVarRef") || {} |
| 37 | + secret_ref = client_vars.dig("MINIO_SECRET_KEY", "valueFrom", "credentialVarRef") || {} |
| 38 | + puts "client_access=#{access_ref.values_at("name", "optional", "username").join(",")}" |
| 39 | + puts "client_secret=#{secret_ref.values_at("name", "optional", "password").join(",")}" |
| 40 | + puts "client_root=#{client_vars.key?("MINIO_ROOT_USER") || client_vars.key?("MINIO_ROOT_PASSWORD")}" |
| 41 | +
|
| 42 | + clients = documents.select do |document| |
| 43 | + document["kind"] == "ComponentDefinition" && |
| 44 | + document.dig("spec", "serviceKind") == "milvus" |
| 45 | + end |
| 46 | + client_contract = clients.all? do |document| |
| 47 | + names = document.dig("spec", "vars").map { |item| item["name"] } |
| 48 | + names.include?("MINIO_ACCESS_KEY") && |
| 49 | + names.include?("MINIO_SECRET_KEY") && |
| 50 | + !names.include?("MINIO_ROOT_USER") && |
| 51 | + !names.include?("MINIO_ROOT_PASSWORD") |
| 52 | + end |
| 53 | + puts "client_components=#{clients.map { |document| document["metadata"]["name"].sub(/-1[.].*$/, "") }.sort.join(",")}" |
| 54 | + puts "client_contract=#{client_contract}" |
| 55 | + ' |
| 56 | + } |
| 57 | + |
| 58 | + It "renders an explicit non-empty password policy and separates server and client variables" |
| 59 | + When call render_contract |
| 60 | + The output should eq "policy=16,4,0,MixedCases |
| 61 | +user=admin,false,Required |
| 62 | +password=admin,false,Required |
| 63 | +server_legacy=false |
| 64 | +client_access=admin,false,Required |
| 65 | +client_secret=admin,false,Required |
| 66 | +client_root=false |
| 67 | +client_components=milvus-datanode,milvus-indexnode,milvus-mixcoord,milvus-proxy,milvus-querynode,milvus-standalone |
| 68 | +client_contract=true" |
| 69 | + The status should be success |
| 70 | + End |
| 71 | +End |
0 commit comments