Class TCTestMu
In: test/tc_test_mu.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

# File test/tc_test_mu.rb, line 352
  def make_uuid_args(uuid)
    args = Array.new
    args << "-u"
    args << uuid
  #  args << "-v"
    return args
  end

[Source]

# File test/tc_test_mu.rb, line 16
  def setup
      $log.level = Logger::INFO
      @mu_ip = ENV['MU_IP']
      @mu_admin_user = ENV['MU_ADMIN_USER']
      @mu_admin_pass = ENV['MU_ADMIN_PASS']
      Dir.chdir($dir)
      $cookie = nil # reset for htto_helper
      # puts "pwd = #{Dir.pwd}"
  end

[Source]

# File test/tc_test_mu.rb, line 26
  def teardown
   
  end

————— cmd_cli —————-

[Source]

# File test/tc_test_mu.rb, line 74
  def test_cli_history
      api = Mu::Command::Cmd_cli.new
      result = api.cmd_history []
      puts result
      assert result==true, "expected 'true'"
  end

[Source]

# File test/tc_test_mu.rb, line 81
  def test_cli_question
      api = Mu::Command::Cmd_cli.new
      result = api.cmd_question []
      puts result
      assert result==true, "expected 'true'"
  end

use ip range setting and a brief pattern

[Source]

# File test/tc_test_mu.rb, line 52
  def test_cmd_appid_run_dir
      File.delete("app_id_status.json") if File.exists?("app_id_status.json")
      app = Mu::Command::Cmd_appid.new
      args = Array.new
      args << "-d"
      args << "#{Dir.pwd}/test/data"
      args << "-i"
      args << "b1-10000,b2"
      args << "-p"
      args << "1-100:10"
      app.cmd_run_dir args
      sleep 2
      assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
      j = JSON File.read("app_id_status.json")
      status = j["status"]
      assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
      assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
  end

use ip range setting and a brief pattern

[Source]

# File test/tc_test_mu.rb, line 33
  def test_cmd_appid_run_file
      File.delete("app_id_status.json") if File.exists?("app_id_status.json")
      app = Mu::Command::Cmd_appid.new
      args = Array.new
      args << "-s"
      args << "#{Dir.pwd}/test/data/data_cgi.msl"
      args << "-i"
      args << "b1-10000,b2"
      args << "-p"
      args << "1-100:10"
      app.cmd_run_file args
      assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
      j = JSON File.read("app_id_status.json")
      status = j["status"]
      assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
      assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
  end

————— cmd_ddt —————

[Source]

# File test/tc_test_mu.rb, line 90
  def test_cmd_ddt_get_all_sessions
      api = Mu::Command::Cmd_ddt.new
      api.cmd_close_all_sessions []
      api.cmd_new_session []
      api.cmd_new_session []
      sessions = Nokogiri::XML(api.cmd_get_all_sessions [])
      sess = sessions.xpath("//session")
      assert(sess.length == 2, "expected 2 sessions, got #{sess.length}")
  ensure
      api.cmd_close_all_sessions []
  end

[Source]

# File test/tc_test_mu.rb, line 151
  def test_cmd_ddt_get_set_channels
      puts "expects SSH channel defined on a host named dell-eth1"
      scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4"  # ftp_with_channel
      api = Mu::Command::Cmd_ddt.new
      api.cmd_close_all_sessions [ "-v" ]
      api.cmd_new_session []
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
      api.cmd_load_scenario [ "-u", scenario_uuid ]
      api.cmd_setup_test []
      response = api.cmd_get_channels []
      doc = Nokogiri::XML(response)
      channels = doc.xpath("//channel")
      assert channels.length==1, "expected 1 scenario channel, found #{channels.length}"
      response = api.cmd_set_channels [ "-r", "channel", "-n", "dell-eth1" ]
      response.each do | resp |
        doc = Nokogiri::XML(resp)
        message = doc.xpath("//message").text
        assert message.include?("Bind channel successfully") , "expected 'Bind host successfully' but got #{message}"
      end
  ensure
      api.cmd_close_all_sessions []
  end

[Source]

# File test/tc_test_mu.rb, line 127
  def test_cmd_ddt_get_set_hosts
      scenario_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
      api = Mu::Command::Cmd_ddt.new
      api.cmd_close_all_sessions [ "-v" ]
      api.cmd_new_session []
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
      api.cmd_load_scenario [ "-u", scenario_uuid ]
      api.cmd_setup_test []
      response = api.cmd_get_hosts []
      doc = Nokogiri::XML(response)
      hosts = doc.xpath("//host")
      role = doc.xpath("//host/role")[0].text
      assert hosts.length==2, "expected 2 scenario hosts, found #{hosts.length}"
      response = api.cmd_set_hosts [ "-r", role, "-n", "a3" ]
      response.each do | resp |
        doc = Nokogiri::XML(resp)
        message = doc.xpath("//message").text
        assert message.include?("Bind host successfully") , "expected 'Bind host successfully' but got #{message}"
      end
  ensure
      api.cmd_close_all_sessions []
  end

[Source]

# File test/tc_test_mu.rb, line 102
  def test_cmd_ddt_get_set_options
      scenario_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
      #test_set_uuid = "49cd406e-a8ca-4360-a115-e7ac33e8034f"
      api = Mu::Command::Cmd_ddt.new
      api.cmd_close_all_sessions []
      api.cmd_new_session []
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
     # http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/test_data_cgi_error.xml"))
      api.cmd_load_scenario [ "-u", scenario_uuid ]
      api.cmd_setup_test []
      response = api.cmd_get_options []
      doc = Nokogiri::XML(response)
      options = doc.xpath("//option/name")
      assert options.length==8, "expected 8 scenario options, found #{options.length}"
      response = api.cmd_set_options [ "-n", "scenario_user_options.url", "-p", "hullo" ]
      response.each do | resp |
        doc = Nokogiri::XML(resp)
        message = doc.xpath("//message").text
        assert message.include?("Option set") , "expected 'Option set' but got #{message}"
      end
  ensure
      api.cmd_close_all_sessions []
  end

assumes hosts a1.v4 -> dell-eth1.v4

[Source]

# File test/tc_test_mu.rb, line 315
  def test_cmd_muapi_analysis
      # $log.level = Logger::DEBUG
      puts "assumes hosts a1.v4 -> dell-eth1.v4"
      uuid = "f07f3cb9-b1a0-4840-a7fd-e733c89f303c"
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/proto_arp.xml"))
      api = Mu::Command::Cmd_muapi.new
      
      run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
      api.cmd_pause make_uuid_args(run_uuid)
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "SUSPENDED", "after PAUSE, expected status=SUSPENDED, got #{status}")
      api.cmd_resume make_uuid_args(run_uuid)
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "RUNNING", "after RESUME, expected status=RUNNING, got #{status}")
      sleep 2
      list = api.cmd_list_by_status ["-s", "running"]
      assert(list.to_s.include?(run_uuid), "expected run_uuid #{run_uuid}in the list_by_status for running, but got #{list}")
      api.cmd_stop make_uuid_args(run_uuid)
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "ABORTED", "after STOP, expected status=ABORTED, got #{status}")
      name = api.cmd_get_name make_uuid_args(run_uuid) # returns a Nokogiri::XML::Attr
      assert(name.value.include?("proto/arp"), "expected name = proto/arp but got #{name.value}")
  ensure
    begin
      api.cmd_stop make_uuid_args(run_uuid)
    rescue
      # do nothing. probably already stopped
    end
  end

assumes hosts a1.v4 -> dell-eth1.v4

[Source]

# File test/tc_test_mu.rb, line 361
  def test_cmd_muapi_archive
      # $log.level = Logger::DEBUG
      puts "assumes hosts a1.v4 -> dell-eth1.v4"
      uuid = "f07f3cb9-b1a0-4840-a7fd-e733c89f303c"

      # load it
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/proto_arp.xml"))
      api = Mu::Command::Cmd_muapi.new

      # run it
      run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
      while status == "RUNNING" 
        sleep 5
        status = api.cmd_status make_uuid_args(run_uuid)
      end

      # archive it
      response = api.cmd_archive ["-c", "run", "-u", run_uuid ]
      sleep 5
      status = api.cmd_archive ["-s", "status", "-u", run_uuid ]

      while true
        status = api.cmd_archive ["-s", "status", "-u", run_uuid ]
        break if status == false
        sleep 5
      end

      # now get it
      api.cmd_archive ["-c", "get", "-u", run_uuid ]
      file_name = run_uuid.to_s + ".zip"
      assert(File.exists?(file_name), "did not find the expected file #{file_name}")
  end

[Source]

# File test/tc_test_mu.rb, line 284
  def test_cmd_muapi_capture
      api = Mu::Command::Cmd_muapi.new
      run_args = Array.new
      run_args << "-c"
      run_args << "run"
      run_args << "-p"
      run_args << "a1"
      job_id = api.cmd_capture run_args
      sleep 2
      status_args = Array.new
      status_args << "-c"
      status_args << "status"
      status_args << "-p"
      status_args << "a1"
      status_args << "-u"
      status_args << job_id
      status = api.cmd_capture status_args
      sleep 2
      get_args = Array.new
      get_args << "-c"
      get_args << "get"
      get_args << "-p"
      get_args << "a1"
      get_args << "-u"
      get_args << job_id
      api.cmd_capture get_args
      sleep 2
      assert( File.exists?("#{job_id}.pcap"), "expected to find #{job_id}.pcap but didn't")
  end

assumes hosts a1.v4 -> dell-eth1.v4

[Source]

# File test/tc_test_mu.rb, line 399
  def test_cmd_muapi_delete
      # $log.level = Logger::DEBUG
      puts "assumes hosts a1.v4 -> dell-eth1.v4"
      uuid = "f07f3cb9-b1a0-4840-a7fd-e733c89f303c"

      # load it
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/proto_arp.xml"))
      api = Mu::Command::Cmd_muapi.new

      # run it
      run_uuid = api.cmd_run make_uuid_args(uuid) # use the run_uuid for subsequent calls
      sleep 2
      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status == "RUNNING", "after RUN, expected status=RUNNING, got #{status}")
      while status == "RUNNING"
        sleep 5
        status = api.cmd_status make_uuid_args(run_uuid)
      end

      # now delete it
      status = api.cmd_delete [ "-u", run_uuid ]
      puts status

      status = api.cmd_status make_uuid_args(run_uuid)
      assert(status.nil?, "expected status=nil, got #{status}")
  end

[Source]

# File test/tc_test_mu.rb, line 275
  def test_cmd_muapi_export_by_type_and_name
     api = Mu::Command::Cmd_muapi.new
     scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4"  # ftp_with_channel
     http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
     http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
     response = api.cmd_export_by_type_and_name(["-n", "ftp_with_channel", "-t", "scenario"]).to_s
     assert response.include?(scenario_uuid), "expected #{scenario_uuid} but did not find it"
  end

[Source]

# File test/tc_test_mu.rb, line 266
  def test_cmd_muapi_export_by_uuid
     api = Mu::Command::Cmd_muapi.new
     scenario_uuid = "379a4cf8-8fe7-4d2d-8f6b-b8c6b71557b4"  # ftp_with_channel
     http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
     http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/ftp_with_channel.xml"))
     response = api.cmd_export_by_uuid(["-u", scenario_uuid]).to_s
     assert response.include?(scenario_uuid), "expected #{scenario_uuid} but did not find it"
  end

————— cmd_muapi ————

[Source]

# File test/tc_test_mu.rb, line 260
  def test_cmd_muapi_types
      api = Mu::Command::Cmd_muapi.new
      response = api.cmd_types []
      assert(response.include?("scenario"), "expected scenario got #{response}")
  end

[Source]

# File test/tc_test_mu.rb, line 495
  def test_cmd_netconfig_add_modify_delete_route
      puts "assumes a1 on 192.168.30.x subnet and a router at 192.168.30.247"
      # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      system = api.cmd_get ["-e", "system"]
      # delete route if if already existsname"] ==
      begin
        response = api.cmd_delete ["-e", "routes/192.168.100.0-192.168.30.247-a1"]
      rescue
        # do nothing. route may not exists
      end
      # turn dhcp on
      dhcp = {"name"=>"a1","v4_dhcp"=>"Enabled"}
      response = api.cmd_modify ["-j", dhcp, "-e", "interfaces/a1"]
      sleep 3
      g = api.cmd_get ["-e", "interfaces/a1"]
      assert(g["v4_addrs"]["begin"].include?("192.168.30"),"A1 DHCP failed")
      new_route = {"interface"=>"a1", "dst"=>"192.168.100.0", "gateway"=>"192.168.30.247", "dst_pfx_len"=>24}
      response = api.cmd_create ["-j", new_route, "-e", "routes"]
      assert(response.include?("192.168.100.0-192.168.30.247-a1 created."), response) # not sure what this will be
      update_mask = {"dst_pfx_len"=>24}
      response = api.cmd_modify ["-j", update_mask, "-e", "routes/192.168.100.0-192.168.30.247-a1"]
  ensure
      response = api.cmd_delete ["-e", "routes/192.168.100.0-192.168.30.247-a1"]
      assert(response.include?("deleted"),response)
  end

[Source]

# File test/tc_test_mu.rb, line 486
  def test_cmd_netconfig_create_delete_host
      # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      response = api.cmd_create ["-j", '{"name"=>"deleteme","v4_addr"=>"192.168.30.9"}', "-e", "hosts"]
      assert(response.include?("created"), "Failed to create host:" + response.to_s)
      response = api.cmd_delete ["-e", "hosts/deleteme"]
      assert(response.include?("deleted"), "Failed to delete host:" + response.to_s)
  end

————— cmd_netfconfig ——-

[Source]

# File test/tc_test_mu.rb, line 449
  def test_cmd_netconfig_get_interfaces_a1
      api = Mu::Command::Cmd_netconfig.new
      response = api.cmd_get ["-e", "interfaces/a1"]
      assert(response["display_name"] == "A1", "expected A1 got #{response["display_name"]}")
  end

[Source]

# File test/tc_test_mu.rb, line 455
  def test_cmd_netconfig_modify_interfaces_a1
      # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      saved = api.cmd_get ["-e", "interfaces/a1"]
      assert(saved["display_name"] == "A1", "expected A1 got #{saved["display_name"]}")
      api.cmd_modify ["-e", "interfaces/a1", "-j", '{"v4_dhcp"=>false}']
      sleep 2
      modified = api.cmd_get ["-e", "interfaces/a1"]
      assert(modified["v4_dhcp"] == false, "expected dhcp false but it wasn't")
  ensure
      api.cmd_modify ["-e", "interfaces/a1", "-j", '{"v4_dhcp"=>true}']
  end

[Source]

# File test/tc_test_mu.rb, line 522
  def test_cmd_netconfig_resolve_hosts
      puts "assumes the Mu can resolve a host named mrtwig"
    # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      response = api.cmd_delete ["-e", "hosts/mrtwig"] # delete it if it exists
      # assert response.include?("deleted"), "expected to find 'deleted' but got #{response}"
      response = api.cmd_resolve_hosts ["-n", "mrtwig"]
      response = api.cmd_get ["-e", "hosts/mrtwig"]
      assert response["name"] == "mrtwig", "expected to find mrtwig but found #{response["name"]}"
  end

[Source]

# File test/tc_test_mu.rb, line 533
  def test_cmd_netconfig_save
    # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      File.delete("save.json") if File.exists?("save.json")
      response = api.cmd_save ["-f", "save.json"]
      assert(File.exists?("save.json"), "wxpected for find file 'save.json but did not")
  ensure
      File.delete("save.json") if File.exists?("save.json")
  end

[Source]

# File test/tc_test_mu.rb, line 468
  def test_cmd_netconfig_vlans
     # $log.level = Logger::DEBUG
      api = Mu::Command::Cmd_netconfig.new
      begin
         api.cmd_delete ["-e", "interfaces/b1.222"]
      rescue
        # ignore. the vlan probably did not exist
      end
      vlan_222 = {"v4_addrs"=>["2.2.2.2"],"v4_mask"=>"26","v6_addrs"=>["2222:0:0:0:0:0:0:2"],"v6_mask"=>"64"}
      api.cmd_create ["-j", '{"name"=>"b1","vlan"=>"222"}', "-e", "interfaces" ]
      sleep 3
      api.cmd_modify [ "-j", vlan_222, "-e", "interfaces/b1.222"]
      b1 = api.cmd_get ["-e", "interfaces/b1.222"]
      assert(b1["v4_addrs"]["begin"] == "2.2.2.2","vlan v4_addrs incorrect: #{b1["v4_addrs"]["begin"]}")
      response = api.cmd_delete ["-e", "interfaces/b1.222"]
      assert(response.include?("deleted"), "Failed to delete host:" + response)
  end

use ip range setting and a brief pattern

[Source]

# File test/tc_test_mu.rb, line 573
  def test_cmd_runscale_run_dir
      File.delete("app_id_status.json") if File.exists?("app_id_status.json")
      app = Mu::Command::Cmd_runscale.new
      args = Array.new
      args << "-d"
      args << "#{Dir.pwd}/test/data"
      args << "-i"
      args << "b1-10000,b2"
      args << "-p"
      args << "1-100:10"
      app.cmd_run_dir args
      assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
      j = JSON File.read("app_id_status.json")
      status = j["status"]
      assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
      assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
  end

use ip range setting and a brief pattern

[Source]

# File test/tc_test_mu.rb, line 554
  def test_cmd_runscale_run_file
      File.delete("app_id_status.json") if File.exists?("app_id_status.json")
      app = Mu::Command::Cmd_runscale.new
      args = Array.new
      args << "-s"
      args << "#{Dir.pwd}/test/data/data_cgi.msl"
      args << "-i"
      args << "b1-10000,b2"
      args << "-p"
      args << "1-100:10"
      app.cmd_run_file args
      assert(File.exists?("app_id_status.json"), "app_id_status.json file was not created")
      j = JSON File.read("app_id_status.json")
      status = j["status"]
      assert(status["statistics"]["summary"]["duration"].to_f >= 10.0, "expected summary duration > 10, but got #{status["statistics"]["summary"]["duration"]}")
      assert(status["statistics"]["summary"]["instances"]["executed"].to_i > 10, "expected instances executed > 0, but got #{status["statistics"]["summary"]["instances"]["executed"]}")
  end

————— cmd_runscenario ———-

[Source]

# File test/tc_test_mu.rb, line 594
  def test_cmd_runscenario
      app = Mu::Command::Cmd_runscenario.new
      args = Array.new
      args << "-s"
      args << "#{Dir.pwd}/test/data/data_cgi.xml"
      args << "-i"
      args << "b1,b2"
      app.cmd_run args
      assert(app.errors.size == 0, "expected 0 errors but got #{app.errors}")
  end

————— cmd_runverify ————

[Source]

# File test/tc_test_mu.rb, line 608
  def test_cmd_runverify
      app = Mu::Command::Cmd_runverify.new
      args = Array.new
      args << "-s"
      args << "#{Dir.pwd}/test/data/data_cgi.xml"
      args << "-t"
      args << "#{Dir.pwd}/test/data/test_data_cgi_error.xml"
      args << "-i"
      args << "b1,b2"
      args << "-v"
      app.cmd_run args
      assert(app.errors.size > 0, "expected errors but got none")
  end

do NOT write a test for cmd_system:restart please!

[Source]

# File test/tc_test_mu.rb, line 668
  def test_cmd_system_status
      api = Mu::Command::Cmd_system.new
      result = api.cmd_status []
      doc = Nokogiri::XML(result)
      ports = doc.xpath("//ports")
      assert(ports.length >= 5, "expected to find at least 5 ports, but got #{ports.length}")
  end

[Source]

# File test/tc_test_mu.rb, line 676
  def test_cmd_system_status2
      api = Mu::Command::Cmd_system.new
      result = api.cmd_status2 []
      assert(result.to_s.include?("raid"), "expected to find 'raid' in results, but got #{result}")
  end

[Source]

# File test/tc_test_mu.rb, line 194
  def test_ddt_close_all_sessions
      api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      api.new_session
      api.new_session
      api.new_session
      api.close_all_sessions
      sessions = Nokogiri::XML(api.get_all_sessions)
      sess = sessions.xpath("//session")
      assert(sess.length == 0, "expected 0 sessions, got #{sess.length}")
  end

[Source]

# File test/tc_test_mu.rb, line 183
  def test_ddt_get_all_sessions
      api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      api.new_session
      api.new_session
      sessions = Nokogiri::XML(api.get_all_sessions)
      sess = sessions.xpath("//session")
      assert(sess.length == 2, "expected 2 sessions, got #{sess.length}")
  ensure
      api.close_all_sessions
  end

————— ddt ——————

[Source]

# File test/tc_test_mu.rb, line 177
  def test_ddt_new
      api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/api/v5/ddt/", "failed to set docroot")
  end

[Source]

# File test/tc_test_mu.rb, line 205
  def test_ddt_set_hosts
      $log.level = Logger::DEBUG
      data_cgi_uuid = "ef6fe3eb-4e9f-44b5-a99e-c431d82e4eeb"
      api = Mu::Ddt.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      api.new_session
      http_helper = Mu::HttpHelper.new(@mu_ip, @mu_admin_user, @mu_admin_pass, "/api/v3/")
      http_helper.post_xml("templates/import", File.read("#{Dir.pwd}/test/data/data_cgi.xml"))
      api.load_scenario(data_cgi_uuid)
      api.setup_test
      response = api.set_hosts( ["192.168.40.217","192.168.40.9"], ["a1", "dell-eth1"] )
      response.each do | resp |
        doc = Nokogiri::XML(resp)
        message = doc.xpath("//message").text
        assert message.include?("Bind host successfully") , "expected 'Bind host successfully' but got #{message}"
      end
  ensure
      api.close_all_sessions
  end

[Source]

# File test/tc_test_mu.rb, line 238
  def test_homepage_all
      api = Mu::Command::Cmd_homepage.new
      result = JSON api.cmd_all []
      assert !result["status"].nil?, "expected to find a status field but didn't"
  end

[Source]

# File test/tc_test_mu.rb, line 244
  def test_homepage_latest_test
      api = Mu::Command::Cmd_homepage.new
      result = JSON api.cmd_latest_test []
      assert  !result.nil?, "expected to get something back but didn't"
  end

————— homepage ————-

[Source]

# File test/tc_test_mu.rb, line 252
  def test_homepage_new
      api = Mu::Homepage.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/api/v5/homepage/", "failed to set docroot")
  end

[Source]

# File test/tc_test_mu.rb, line 232
  def test_homepage_recent
      api = Mu::Command::Cmd_homepage.new
      result = JSON api.cmd_recent []
      assert !result[0]["summary"].nil?, "expected to find a summary field but didn't"
  end

————— cmd_homepage ————-

[Source]

# File test/tc_test_mu.rb, line 226
  def test_homepage_status
      api = Mu::Command::Cmd_homepage.new
      result = JSON api.cmd_status []
      assert result[0]["title"] == "Licenses", "expected 'Licenses'"
  end

[Source]

# File test/tc_test_mu.rb, line 435
  def test_muapi_list_by_status
      api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      response = api.list_by_status("finished")
      assert(!response.empty?, "got empty response")
  end

————— muapi —————-

[Source]

# File test/tc_test_mu.rb, line 429
  def test_muapi_new
      api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/api/v3/", "failed to set docroot")
  end

[Source]

# File test/tc_test_mu.rb, line 441
  def test_muapi_types
      api = Mu::Muapi.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      response = api.types
      assert(response.include?("scenario"), "expected scenario, got\n#{response}")
  end

————— netconfig ————

[Source]

# File test/tc_test_mu.rb, line 545
  def test_netconfig_new
      api = Mu::Netconfig.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/restlet/netconfig/", "failed to set docroot")
  end

[Source]

# File test/tc_test_mu.rb, line 632
  def test_scale_about
      api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      about = api.about
      # puts JSON.pretty_generate about
      assert(about[0]["group"] == "active", "expected 'active' group, got #{about[0]["group"]}")
      assert(about[0]["type"] == "bot", "expected 'bot' type, got #{about[0]["type"]}")
      assert(!api.uuid.nil?, "uuid is nil")
  end

[Source]

# File test/tc_test_mu.rb, line 641
  def test_scale_list
      api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      list = api.list
      assert(list.length == 1 , "expected list of length 1, got #{list.length}")
      assert(!api.uuid.nil?, "uuid is nil")
  end

————— scale —————-

[Source]

# File test/tc_test_mu.rb, line 625
  def test_scale_new
      api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/api/v5/scale/", "failed to set docroot")
      assert(!api.uuid.nil?, "uuid is nil")
  end

[Source]

# File test/tc_test_mu.rb, line 648
  def test_scale_session
      api = Mu::Scale.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      api.session
      assert(!api.uuid.nil?, "uuid is nil")
  end

do NOT write a test for system:restart please!

[Source]

# File test/tc_test_mu.rb, line 658
  def test_system_new
      api = Mu::System.new(@mu_ip, @mu_admin_user, @mu_admin_pass)
      assert(api.host == @mu_ip, "failed to set mu_ip")
      assert(api.docroot == "/api/v5/system/", "failed to set docroot")
  end

[Validate]