-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_interfaces_test.rb.old
More file actions
125 lines (96 loc) · 3.49 KB
/
create_interfaces_test.rb.old
File metadata and controls
125 lines (96 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/lib/gnuplot-2.2/lib/"))
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/lib/snmp-1.0.2/lib/"))
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/lib/ruby-xr"))
puts $LOAD_PATH
require 'yaml'
require 'Cooker.rb'
require 'GraphPerf.rb'
require 'ConfigCreate.rb'
require 'XrTelnet.rb'
x = 1
describe "Performance Analysis" do
before(:all) do
puts "+#{Time.now}: Preconfig started"
#Load Environment Data
@env = YAML::load(File.open('Environment.yaml'))
@points = EventPointEater.eat_header(@env['build_dir'])
@tftp = [@env["tftpserver"]["ip"],
@env["tftpserver"]["dir"]]
@timestamp = Time.now.strftime("%b%d-%H%M%S")
end
before(:each) do
puts "+#{Time.now}: Common build-up started"
@name = [@timestamp, "sample_#{x}"]
#Establish XR connections
@conn = XrTelnet.new(@env['console'],
@env['auxilary'],
@env["workspace"]+ '/' + @name.join('/'))
@conn.config do |console|
#Prevent MORE from running
console.cmd("line con 0")
console.cmd("length 0")
#Configure SNMP
console.cmd("logging console debugging")
console.cmd("snmp-server community public RW SystemOwner")
console.cmd("snmp-server community sdr_owner SDROwner")
console.cmd("snmp-server community sys_owner SystemOwner")
end
end
after(:each) do
puts "+#{Time.now}: Common tear-down started"
#Copy logs of UUT
@conn.copy_log(@tftp.join('/'), "#{@name.join('_')}.kev")
#Close XR connections
@conn.close
#Cook kev file into csv
csvs = Cooker.cook("/tftpboot/#{@tftp[1]}",
@env["workspace"],
@name,
@points)
#Graph csv data using gnuplot
csvs.each {|csv| GraphPerf.graph_test(csv)}
#Increment Sample Number
x += 1
puts @x
end
###Test Cases###
it "Attempt 1 should not timeout" do
puts "+#{Time.now}: First testcase started"
create_int(10000, @tftp, @name).should_not
end
it "Attempt 2 should not timeout" do
puts "+#{Time.now}: Second testcase started"
create_int(10000, @tftp, @name)
end
it "Attempt 3 should not timeout" do
puts "+#{Time.now}: Third testcase started"
create_int(10000, @tftp, @name)
end
###HELPER METHODS###
def create_int(num, tftp_str, log_name)
#Create config file with interfaces
ConfigCreate.create_loopback_conf(:size => num,
:loc => "/tftpboot/#{tftp_str[1]}")
#Copy config file
@conn.exec("copy tftp://#{tftp_str.join('/')}/running.config nvram:changeset\n\n")
#Load changes
@conn.config(:log => true,
:command => "load nvram:changeset")
end
def delete_int(num, tftp_str, log_name)
#Create config file with interfaces
ConfigCreate.delete_loopback_conf(num, "/tftpboot/#{tftp_str[1]}")
#Copy config file
@conn.exec("copy tftp://#{tftp_str.join('/')}/running.config nvram:changeset\n\n")
#Load changes
@conn.config("load nvram:changeset")
#Delete interfaces
@conn.unconfig(:log => true)
end
def create_int_tty(num, tftp_str, log_name)
#Read File into Telnet Socket
@conn.config(:log => true) do |con|
num.times { |i| con.puts("int l#{i}"); puts "Hello #{i}" }
end
end
end