-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_many_kev.rb
111 lines (86 loc) · 3.13 KB
/
create_many_kev.rb
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
$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"))
require 'yaml'
require 'Cooker.rb'
require 'GraphPerf.rb'
require 'ConfigCreate.rb'
require 'XrTelnet.rb'
require 'pp'
interval = 100
total = 200
describe "Performance Analysis" do
### Build-Up ###
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")
@name = [@timestamp]
@csvs = Array.new
#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
### Test Cases ###
(total/interval).times do |num|
it "Create Many Kev files" do
@name = [@timestamp, "sample_#{num}"]
#Create config file with interfaces
ConfigCreate.create_loopback_conf(:start => (num * interval),
:size => (interval - 1),
:no => true,
:loc => "/tftpboot/#{@tftp[1]}")
#Copy config file
@conn.exec("copy tftp://#{@tftp.join('/')}/running.config nvram:changeset\n\n")
#Load changes
@conn.config("load nvram:changeset")
@conn.config(:log => true,
:command => "int l#{((num + 1) * interval)}",
:time => 1)
end
end
### Tear-Down ###
after(:each) do
#Copy logs of UUT
@conn.copy_log(@tftp.join('/'), "#{@name.join('_')}.kev")
#Cook kev file into csv
@csvs.push Cooker.cook("/tftpboot/#{@tftp[1]}",
@env["workspace"],
@name,
@points)
end
after(:all) do
@csvs.each do |files|
for file in files
@points.each do |key, value|
tag = /(\w+)_(START|STOP)/.match value
puts "file: #{file} Value: #{tag[1]}"
if tag[1].match file
puts "cat #{file} >> #{@env['workspace']}/#{@timestamp}/#{tag}.csv"
end
end
end
end
# Graph csv data using gnuplot
# csvs.each {|csv| GraphPerf.graph_test(csv,
# :start => 100,
# :iterval => 100)}
#Close XR connections
@conn.close
end
end