Skip to content

Commit

Permalink
support multiple providers: update tests for new changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Salmela <jacob.salmela@hpe.com>
  • Loading branch information
jacobsalmela committed Oct 30, 2023
1 parent 1823a92 commit c6e37f8
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 133 deletions.
3 changes: 2 additions & 1 deletion spec/edge/add_cabinet_ex2000_vlan_limit_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ It 'commit and reconcile'
When call bin/cani alpha session --config "$CANI_CONF" apply --commit
The status should equal 0
The stderr should include 'Hardware added to the system'
The stdout should include '5994 new hardware item(s) are in the inventory:'
The stderr should include 'Adding'
The stderr should include 'Added'
End

End
49 changes: 26 additions & 23 deletions spec/functional/cani_add_blade_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Describe 'cani add blade'
# help output should succeed and match the fixture
# a config file should be created if one does not exist
It '--help'
BeforeCall remove_config # Remove the config to start fresh
BeforeCall use_active_session # session is active
BeforeCall use_valid_datastore_system_only # deploy a valid datastore
When call bin/cani alpha add blade --help --config "$CANI_CONF"
The status should equal 0
The stdout should satisfy fixture 'cani/add/blade/help'
Expand Down Expand Up @@ -69,19 +70,21 @@ Describe 'cani add blade (each blade type)'

# add each blade type as a parameter, determined dynamically from the current build's output of supported hardware
Parameters:dynamic
for blade in $(bin/cani --config "$CANI_CONF" alpha add blade -L); do
mkdir -p "$CANI_DIR"
cp "$SHELLSPEC_HELPERDIR/testdata/fixtures/cani/configs/canitest_valid_active.yml" "$CANI_CONF"
cp "$FIXTURES"/cani/configs/canitestdb_valid_system_only.json "$CANI_DS"
for blade in $(bin/cani --config "$SHELLSPEC_HELPERDIR/testdata/fixtures/cani/configs/canitest_valid_active.yml" alpha add blade -L); do
%data "$blade"
done
End


# Adding a blade should fail if no session is active
It "--config $CANI_CONF $1 --cabinet 3000 --chassis 1 --blade 0 (no session)"
BeforeCall use_inactive_session # session is inactive
BeforeCall use_valid_datastore_system_only # deploy a valid datastore
When call bin/cani alpha add blade --config "$CANI_CONF" "$1" --cabinet 3000 --chassis 1 --blade 0
The status should equal 1
The line 1 of stderr should equal "Error: No active session. Run 'session start' to begin"
The line 1 of stderr should include "No active session."
End

# Adding a blade should fail if:
Expand All @@ -92,7 +95,7 @@ It "--config $CANI_CONF $1 --cabinet 3000 --chassis 1 --blade 0 (active session,
BeforeCall remove_datastore # datastore does not exist
When call bin/cani alpha add blade --config "$CANI_CONF" "$1" --cabinet 3000 --chassis 1 --blade 0
The status should equal 1
The line 1 of stderr should equal "Error: Datastore '$CANI_DS' does not exist. Run 'session start' to begin"
The line 1 of stderr should include "Datastore '$CANI_DS' does not exist. Run 'session init' to begin"
End

# Adding a blade should fail if:
Expand Down Expand Up @@ -147,7 +150,7 @@ It "--config $CANI_CONF $1 --cabinet 3000 --chassis 1 --blade 0 (active session,
When call bin/cani alpha add blade --config "$CANI_CONF" "$1" --cabinet 3000 --chassis 1 --blade 0
The status should equal 1
The line 1 of stderr should equal 'Error: unable to find Cabinet at System:0->Cabinet:3000'
The line 2 of stderr should equal "try 'go run main.go alpha list cabinet'"
The line 2 of stderr should equal "try 'list cabinet'"
End

# Adding a blade should fail if:
Expand Down Expand Up @@ -187,23 +190,23 @@ It "--config $CANI_CONF $1 --cabinet 3000 --chassis 0 --blade 0 (happy path)"
The line 6 of stderr should include "Blade: 0"
End

# (re-run the last command) Adding a blade should fail if:
# - a session is active
# - a datastore exists
# - cabinet flag is set
# - chassis flag is set
# - blade flag is set
# - the cabinet exists
# - the chassis exists
# - the blade already exists
It "--config $CANI_CONF $1 --cabinet 3000 --chassis 0 --blade 0 (active session, datastore, all flags, existing hardware)"
BeforeCall use_active_session # session is active
When call bin/cani alpha add blade --config "$CANI_CONF" "$1" --cabinet 3000 --chassis 0 --blade 0
The status should equal 1
The line 1 of stderr should equal "Error: NodeBlade number 0 is already in use"
The line 2 of stderr should equal "please re-run the command with an available NodeBlade number"
The line 3 of stderr should equal "try 'cani alpha list blade'"
End
# # (re-run the last command) Adding a blade should fail if:
# # - a session is active
# # - a datastore exists
# # - cabinet flag is set
# # - chassis flag is set
# # - blade flag is set
# # - the cabinet exists
# # - the chassis exists
# # - the blade already exists
# It "--config $CANI_CONF $1 --cabinet 3000 --chassis 0 --blade 0 (active session, datastore, all flags, existing hardware)"
# BeforeCall use_active_session # session is active
# When call bin/cani alpha add blade --config "$CANI_CONF" "$1" --cabinet 3000 --chassis 0 --blade 0
# The status should equal 1
# The line 1 of stderr should equal "Error: NodeBlade number 0 is already in use"
# The line 2 of stderr should equal "please re-run the command with an available NodeBlade number"
# The line 3 of stderr should equal "try 'cani alpha list blade'"
# End

# blade suggestions should fail if there are no empty slots
It "--config $CANI_CONF $1 --auto --accept (no slots available)"
Expand Down
7 changes: 5 additions & 2 deletions spec/functional/cani_add_cabinet_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,23 @@ End
# Adding a cabinet withot a hardware type should fail
# it should list the available hardware types
It "--config $CANI_CONF"
BeforeCall use_active_session # session is active
When call bin/cani alpha add cabinet --config "$CANI_CONF"
The status should equal 1
The line 1 of stderr should include 'Error: No hardware type provided: Choose from: hpe-eia-cabinet", "hpe-ex2000", "hpe-ex2500-1-liquid-cooled-chassis", "hpe-ex2500-2-liquid-cooled-chassis", "hpe-ex2500-3-liquid-cooled-chassis", "hpe-ex3000", "hpe-ex4000'
End

# Adding a cabinet with an invalid hardware type should fail
It "--config $CANI_CONF fake-hardware-type"
BeforeCall use_active_session # session is active
When call bin/cani alpha add cabinet --config "$CANI_CONF" fake-hardware-type
The status should equal 1
The line 1 of stderr should equal 'Error: Invalid hardware type: fake-hardware-type'
End

# Listing hardware types should show available hardware types
It "--config $CANI_CONF -L"
BeforeCall use_active_session # session is active
When call bin/cani alpha add cabinet --config "$CANI_CONF" -L
The status should equal 0
The line 1 of stdout should equal "hpe-eia-cabinet"
Expand All @@ -69,7 +72,7 @@ It "--config $CANI_CONF hpe-ex2000"
BeforeCall use_valid_datastore_system_only # deploy a valid datastore
When call bin/cani alpha add cabinet --config "$CANI_CONF" hpe-ex2000
The status should equal 1
The line 1 of stderr should equal "Error: No active session. Run 'session start' to begin"
The line 1 of stderr should include "No active session."
End

# Adding a cabinet should fail if:
Expand All @@ -80,7 +83,7 @@ It "--config $CANI_CONF hpe-ex2000"
BeforeCall remove_datastore # datastore does not exist
When call bin/cani alpha add cabinet --config "$CANI_CONF" hpe-ex2000
The status should equal 1
The line 1 of stderr should equal "Error: Datastore '$CANI_DS' does not exist. Run 'session start' to begin"
The line 1 of stderr should include "Datastore '$CANI_DS' does not exist. Run 'session init' to begin"
End

# Adding a cabinet should fail if:
Expand Down
13 changes: 7 additions & 6 deletions spec/functional/cani_session_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ It "--config $CANI_CONF status"
BeforeCall use_inactive_session # session is inactive
When call bin/cani alpha session --config "$CANI_CONF" status
The status should equal 0
The line 1 of stderr should include "See $CANI_CONF for session details"
The line 2 of stderr should include 'Session is INACTIVE'
The line 1 of stderr should include "No active session"
The line 2 of stderr should include "Session is INACTIVE for"
End

# Status should be ACTIVE if active: true
It "--config $CANI_CONF status"
BeforeCall use_active_session # session is active
When call bin/cani alpha session --config "$CANI_CONF" status
The status should equal 0
The line 1 of stderr should include "See $CANI_CONF for session details"
The line 2 of stderr should include 'Session is ACTIVE'
The stderr should include 'Session is ACTIVE for'
The stderr should include "See $CANI_CONF for session details"
End

# Starting a session without passing a provider should fail
It "--config $CANI_CONF init"
BeforeCall remove_config
When call bin/cani alpha session --config "$CANI_CONF" init
The status should equal 1
The line 1 of stderr should equal 'Error: Need a provider. Choose from: [csm]'
The line 1 of stderr should equal 'Error: need a provider. Choose from: [csm]'
End

# Starting a session without passing a provider should fail
Expand Down Expand Up @@ -91,7 +91,8 @@ It 'initialize a session without a config file or datastore'
BeforeCall "load_sls.sh testdata/fixtures/sls/valid_hardware_networks.json" # simulator is running, load a specific SLS config
When call bin/cani alpha session --config "$CANI_CONF" init csm -S
The status should equal 0
The line 1 of stderr should include 'Using simulation mode'
The line 1 of stderr should include 'does not exist, creating default datastore'
The line 2 of stderr should include 'Using simulation mode'
The stderr should include 'Validated CANI inventory'
The stderr should include 'Validated external inventory provider'
# Verify the import logic reached out to SLS
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/add_blade_ex235a_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ It 'commit and reconcile'
When call bin/cani alpha session --config "$CANI_CONF" apply --commit
# committing without node metadata should fail
The status should equal 0
The line 1 of stderr should include 'Session is STOPPED'
The line 2 of stderr should include 'Committing changes to session'
The stderr should include 'Session is STOPPED'
The stderr should include 'Committing changes to session'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b1n0 - Type: Node, Class: Hill, Aliases: [nid001002], Role: Compute, NID: 1002'
The stdout should include 'Node (staged)'
The stderr should include 'Added hardware to SLS'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_blade_ex235n_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ It 'commit and reconcile'
The line 2 of stderr should include 'Committing changes to session'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b1n0 - Type: Node, Class: Hill, Aliases: [nid001002], Role: Compute, NID: 1002'
The stdout should include 'Node (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_blade_ex254n_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ It 'commit and reconcile'
The line 2 of stderr should include 'Committing changes to session'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b1n0 - Type: Node, Class: Hill, Aliases: [nid001002], Role: Compute, NID: 1002'
The stdout should include 'Node (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_blade_ex420_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ It 'commit and reconcile'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b1n0 - Type: Node, Class: Hill, Aliases: [nid001002], Role: Compute, NID: 1002'
The stderr should include 'x9000c1s0b1n1 - Type: Node, Class: Hill, Aliases: [nid001003], Role: Compute, NID: 1003'
The stdout should include 'Node (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_blade_ex4252_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ It 'commit and reconcile'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b0n2 - Type: Node, Class: Hill, Aliases: [nid002000], Role: Compute, NID: 2000'
The stderr should include 'x9000c1s0b0n3 - Type: Node, Class: Hill, Aliases: [nid002001], Role: Compute, NID: 2001'
The stdout should include 'Node (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_blade_ex425_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ It 'commit and reconcile'
The stderr should include 'x9000c1s0b0n1 - Type: Node, Class: Hill, Aliases: [nid001001], Role: Compute, NID: 1001'
The stderr should include 'x9000c1s0b1n0 - Type: Node, Class: Hill, Aliases: [nid001002], Role: Compute, NID: 1002'
The stderr should include 'x9000c1s0b1n1 - Type: Node, Class: Hill, Aliases: [nid001003], Role: Compute, NID: 1003'
The stdout should include 'Node (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_cabinet_ex2000_dryrun_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ It 'commit and reconcile'
The stderr should include 'Performing dryrun no changes will be applied to the system!'
The stderr should include 'Hardware added to the system'
The stderr should include 'x9001 - Type: Cabinet, Class: Hill, Networks: {"cn":{"HMN":{"CIDR":"10.104.4.0/22","Gateway":"10.104.4.1","VLan":3001},"NMN":{"CIDR":"10.100.4.0/22","Gateway":"10.100.4.1","VLan":2001}}}'
The stdout should include 'Cabinet (staged)'
The stderr should include 'Dryrun enabled, no changes performed!'
End

Expand Down
1 change: 0 additions & 1 deletion spec/integration/add_cabinet_ex2000_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ It 'commit and reconcile'
The status should equal 0
The stderr should include 'Hardware added to the system'
The stderr should include 'x9001 - Type: Cabinet, Class: Hill, Networks: {"cn":{"HMN":{"CIDR":"10.104.4.0/22","Gateway":"10.104.4.1","VLan":3001},"NMN":{"CIDR":"10.100.4.0/22","Gateway":"10.100.4.1","VLan":2001}}}'
The stdout should include 'Cabinet (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_cabinet_ex2500_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ It 'commit and reconcile'
The stderr should include 'x8000 - Type: Cabinet, Class: Hill, Networks: {"cn":{"HMN":{"CIDR":"10.104.4.0/22","Gateway":"10.104.4.1","VLan":3001},"NMN":{"CIDR":"10.100.4.0/22","Gateway":"10.100.4.1","VLan":2001}}}'
The stderr should include 'x8001 - Type: Cabinet, Class: Hill, Networks: {"cn":{"HMN":{"CIDR":"10.104.8.0/22","Gateway":"10.104.8.1","VLan":3002},"NMN":{"CIDR":"10.100.8.0/22","Gateway":"10.100.8.1","VLan":2002}}}'
The stderr should include 'x8002 - Type: Cabinet, Class: Hill, Networks: {"cn":{"HMN":{"CIDR":"10.104.12.0/22","Gateway":"10.104.12.1","VLan":3003},"NMN":{"CIDR":"10.100.12.0/22","Gateway":"10.100.12.1","VLan":2003}}}'
The stdout should include 'Cabinet (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_cabinet_ex3000_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ It 'commit and reconcile'
The status should equal 0
The stderr should include 'Hardware added to the system'
The stderr should include 'x1000 - Type: Cabinet, Class: Mountain, Networks: {"cn":{"HMN":{"CIDR":"10.104.4.0/22","Gateway":"10.104.4.1","VLan":3001},"NMN":{"CIDR":"10.100.4.0/22","Gateway":"10.100.4.1","VLan":2001}}}'
The stdout should include 'Cabinet (staged)'
End

End
1 change: 0 additions & 1 deletion spec/integration/add_cabinet_ex4000_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ It 'commit and reconcile'
The status should equal 0
The stderr should include 'Hardware added to the system'
The stderr should include 'x1000 - Type: Cabinet, Class: Mountain, Networks: {"cn":{"HMN":{"CIDR":"10.104.4.0/22","Gateway":"10.104.4.1","VLan":3001},"NMN":{"CIDR":"10.100.4.0/22","Gateway":"10.100.4.1","VLan":2001}}}'
The stdout should include 'Cabinet (staged)'
End

End
5 changes: 2 additions & 3 deletions spec/integration/export_import_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ It 'apply and reconcile session'
The status should equal 0
The line 1 of stderr should include 'Session is STOPPED'
The line 2 of stderr should include 'Committing changes to session'
The line 1 of stdout should include 'Summary:'
The line 2 of stdout should include '--------'
The line 3 of stdout should include 'ID'
The stderr should include 'Adding'
The stderr should include 'Added'
End

End
8 changes: 4 additions & 4 deletions spec/integration/session_start_import_1_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ It 'commit and reconcile'
The status should equal 0
The line 1 of stderr should include 'Session is STOPPED'
The line 2 of stderr should include 'Committing changes to session'
The line 1 of stdout should include 'Summary:'
The line 2 of stdout should include '--------'
The line 3 of stdout should include 'ID TYPE STATUS'
The line 5 of stdout should include '0 new hardware item(s) are in the inventory'
The line 82 of stderr should include 'Hardware added to the system'
The line 83 of stderr should include 'None'
The line 85 of stderr should include 'Hardware removed from system'
The line 86 of stderr should include 'None'
End

End
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ It 'commit and reconcile ignoring validation failures'
The status should equal 0
The line 1 of stderr should include 'Session is STOPPED'
The line 2 of stderr should include 'Committing changes to session'
The line 1 of stdout should include 'Summary:'
The line 2 of stdout should include '--------'
The line 3 of stdout should include 'ID TYPE STATUS'
The line 5 of stdout should include '0 new hardware item(s) are in the inventory'
The stderr should include 'Ignoring these failures'
End

End
72 changes: 35 additions & 37 deletions testdata/fixtures/cani/configs/canitest_valid_active.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,38 @@
# OTHER DEALINGS IN THE SOFTWARE.
#
session:
domain_options:
datastore_path: /tmp/.cani/canidb.json
log_file_path: /tmp/.cani/canidb.log
provider: csm
csm_options:
usesimulation: true
insecureskipverify: true
apigatewaytoken: ""
baseurlsls: https://localhost:8443/apis/sls/v1
baseurlhsm: https://localhost:8443/apis/smd/hsm/v2
secretname: admin-client-auth
k8spodscidr: 10.32.0.0/12
k8sservicescidr: 10.16.0.0/12
kubeconfig: ""
providerhost: localhost:8443
cacertpath: ""
validroles:
- Storage
- Management
- Storage
- Management
- Compute
- Service
- System
- Application
validsubroles:
- UAN
- Gateway
- LNETRouter
- Visualization
- UserDefined
- Master
- Worker
- Storage
custom_hardware_types_dir: /tmp/.cani/hardware-types
domain: {}
active: true
domains:
csm:
active: true
datastore_path: /tmp/.cani/canidb.json
log_file_path: /tmp/.cani/canidb.log
custom_hardware_types_dir: /tmp/.cani/hardware-types
provider: csm
options:
use_simulation: true
insecure_skip_verify: true
api_gateway_token: ""
base_url_sls: https://localhost:8443/apis/sls/v1
base_url_hsm: https://localhost:8443/apis/smd/hsm/v2
secret_name: admin-client-auth
k8s_pods_cidr: 10.32.0.0/12
k8s_services_cidr: 10.16.0.0/12
kubeconfig: ""
provider_host: localhost:8443
ca_cert_path: ""
valid_roles:
- Management
- Compute
- Service
- System
- Application
- Storage
valid_sub_roles:
- Storage
- UAN
- Gateway
- LNETRouter
- Visualization
- UserDefined
- Master
- Worker
Loading

0 comments on commit c6e37f8

Please sign in to comment.