~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to test/deft/ts-instantiate.pl

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/inktest/dist/bin/perl
 
2
 
 
3
# Licensed to the Apache Software Foundation (ASF) under one
 
4
# or more contributor license agreements.  See the NOTICE file
 
5
# distributed with this work for additional information
 
6
# regarding copyright ownership.  The ASF licenses this file
 
7
# to you under the Apache License, Version 2.0 (the
 
8
# "License"); you may not use this file except in compliance
 
9
# with the License.  You may obtain a copy of the License at
 
10
#
 
11
#      http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
13
# Unless required by applicable law or agreed to in writing, software
 
14
# distributed under the License is distributed on an "AS IS" BASIS,
 
15
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
# See the License for the specific language governing permissions and
 
17
# limitations under the License.
 
18
 
 
19
#
 
20
#  ts-instantiate.pl
 
21
#
 
22
#
 
23
#  Description:
 
24
#    script to manage traffic_server under the DEFT testing
 
25
#    framework
 
26
#
 
27
#  
 
28
#
 
29
#
 
30
 
 
31
use strict vars;
 
32
use English;
 
33
use File::Copy;
 
34
 
 
35
our $bin_dir;
 
36
our $run_dir;
 
37
 
 
38
our $base_port = 0;
 
39
our @additional_config_entries = ();
 
40
our %override;
 
41
our @remap_lines;
 
42
our @filter_lines;
 
43
our @ipnat_lines;
 
44
 
 
45
my @user_info = getpwuid $UID;
 
46
my $default_user = $user_info[0];
 
47
 
 
48
#####################################
 
49
#                                   #
 
50
# Finding the ethernet interface    #
 
51
#                                   #
 
52
#####################################
 
53
 
 
54
# Defaults in case we can't access ifconfig
 
55
our %default_interface = 
 
56
(
 
57
 "solaris" => "hme0",
 
58
 "dec_osf" => "tu0",
 
59
 "irix" => "ef0",
 
60
 "freebsd" => "de0",
 
61
 "linux" => "eth0",
 
62
 "hpux" => "lan0"
 
63
);
 
64
 
 
65
 
 
66
sub get_default_if {
 
67
    my $dif = $default_interface{$OSNAME};
 
68
 
 
69
    if (! $dif) {
 
70
        die "Unknown OS type, could determine default internface\n";
 
71
    }
 
72
 
 
73
    return $dif;
 
74
}
 
75
 
 
76
sub process_if_record {
 
77
    my ($if_name, $if_info) = @_;
 
78
 
 
79
    if ($if_name eq "") {
 
80
        return 0;
 
81
    }
 
82
 
 
83
    # Do not return loop back addrs
 
84
    if ($if_name =~ /^lo/) {
 
85
        return 0;
 
86
    }
 
87
 
 
88
    # Check to see if the address has an address
 
89
    if ($if_info =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/) {
 
90
        # If it's not localhost, it's good enough
 
91
        if ($1 != 127 || $2 == 0 || $3 == 0 || $4 == 1) {
 
92
            return 1;
 
93
        }
 
94
    }
 
95
 
 
96
    return 0;
 
97
}
 
98
 
 
99
sub find_ethernet_if {
 
100
 
 
101
    if (!open(IFCONFIG, "ifconfig -a |") && 
 
102
        !open(IFCONFIG, "/usr/sbin/ifconfig -a |")) {
 
103
            warn "Warning: Could not open ifconfig : $! : guessing interface\n";
 
104
            return get_default_if();
 
105
    }
 
106
 
 
107
    # Basic strategy is loop over the interfaces and use the first
 
108
    #  one that is up that is not localhost
 
109
    #
 
110
    # Between the various OS's there are several different formats
 
111
    #  for ifconfig output.  They have in common that interfaces
 
112
    #  start the line with "<if_name>:"   Some put new line between
 
113
    #  interfaces and others do not
 
114
    my $if_name = "";
 
115
    my $if_info = "";
 
116
    my $tmp;
 
117
    my $done;
 
118
    while ($tmp = <IFCONFIG>) {
 
119
        chomp($tmp);
 
120
        if ($tmp =~ /^(\w+):(.*)/) {
 
121
 
 
122
            # We've got a new record, process old info
 
123
            my $new_name = $1;
 
124
            my $new_info = $2;
 
125
            
 
126
            if (process_if_record($if_name, $if_info)) {
 
127
                return $if_name;
 
128
            }
 
129
 
 
130
            $if_name = $new_name;
 
131
            $if_info = $new_info;
 
132
            
 
133
        } elsif ($tmp =~ /^\s*$/) {
 
134
 
 
135
            # Blank lines tell us the old record is done 
 
136
            if (process_if_record($if_name, $if_info)) {
 
137
                return $if_name;
 
138
            }
 
139
 
 
140
            $if_name = "";
 
141
            $if_info = "";
 
142
                
 
143
        } else {
 
144
            $if_info = $if_info . " " . $tmp;
 
145
        }
 
146
    }
 
147
 
 
148
    if (process_if_record($if_name, $if_info)) {
 
149
        return $if_name;
 
150
    }
 
151
    
 
152
    return get_default_if;
 
153
}
 
154
 
 
155
my $eth_if = find_ethernet_if();
 
156
 
 
157
###############*######################
 
158
#                                    #
 
159
# End: finding ethernet interface    #
 
160
#                                    #
 
161
######################################
 
162
 
 
163
our %defaults =
 
164
(
 
165
 "proxy.config.socks.socks_server_port" => 1080,
 
166
 "proxy.config.proxy_name" => "ink-proxy.inktomi.com",
 
167
 "proxy.config.bin_path" => "bin",
 
168
 "proxy.config.alarm_email" => $default_user,
 
169
 "proxy.config.cluster.mc_group_addr" => "225.0.1.89",
 
170
 "proxy.config.admin.html_doc_root" => "ui",
 
171
 "proxy.config.admin.admin_user" => "admin",
 
172
 "proxy.config.admin.admin_password" => "21232F297A57A5A743894A0",
 
173
 "proxy.config.admin.user_id" => $default_user,
 
174
 "proxy.config.net.connections_throttle" => 8000,
 
175
 "proxy.config.cluster.ethernet_interface" => $eth_if,
 
176
 "proxy.config.icp.icp_interface" => $eth_if,
 
177
 "proxy.config.hostdb.size" => 200000,
 
178
 "proxy.config.reverse_proxy.enabled" => 0,
 
179
 "proxy.config.loadshedding.max_connections" => 0,
 
180
 );
 
181
 
 
182
our %export_ports =
 
183
(
 
184
 "proxy.config.http.server_port" => "tsHttpPort",
 
185
);
 
186
 
 
187
our %base_port_hash  =
 
188
(
 
189
 "proxy.config.http.server_port" => 0,
 
190
 "proxy.config.admin.web_interface_port" => 2,
 
191
 "proxy.config.admin.overseer_port" => 3,
 
192
 "proxy.config.admin.autoconf_port" => 4,
 
193
 "proxy.config.process_manager.mgmt_port" => 5,
 
194
 "proxy.config.log.collation_port" => 7,
 
195
 "proxy.config.cluster.cluster_port" => 8,
 
196
 "proxy.config.cluster.rsport" => 10,
 
197
 "proxy.config.cluster.mcport" => 11,
 
198
 );
 
199
 
 
200
our %config_meta = ();
 
201
 
 
202
sub process_records_blob {
 
203
    my $line;
 
204
    while ($line = <CONFIG_BLOB>) {
 
205
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
206
            return $1;
 
207
        }
 
208
 
 
209
        my ($cmd, $arg1, $arg2, $arg3, $arg4) = split(/\s+/, $line, 5);
 
210
 
 
211
        if ($cmd eq "base_port") {
 
212
            $base_port = $arg1;
 
213
        } elsif ($cmd eq "add") {
 
214
            my $config_entry = $arg1 . " " . $arg2 . " " . $arg3 . " " . $arg4;
 
215
            push @additional_config_entries, $config_entry;
 
216
        } else {
 
217
            $override{$cmd} = $arg1;
 
218
        }
 
219
    }
 
220
 
 
221
    return "";
 
222
}
 
223
 
 
224
sub process_remap_config {
 
225
    my $line;
 
226
    while ($line = <CONFIG_BLOB>) {
 
227
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
228
            return $1;
 
229
        } else {
 
230
            push(@remap_lines, $line);
 
231
        }
 
232
    }
 
233
    return "";
 
234
}
 
235
 
 
236
sub process_filter_config {
 
237
    my $line;
 
238
    while ($line = <CONFIG_BLOB>) {
 
239
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
240
            return $1;
 
241
        } else {
 
242
            push(@filter_lines, $line);
 
243
        }
 
244
    }
 
245
    return "";
 
246
}
 
247
 
 
248
sub process_ipnat_conf {
 
249
    my $line;
 
250
    while ($line = <CONFIG_BLOB>) {
 
251
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
252
            return $1;
 
253
        } else {
 
254
            push(@ipnat_lines, $line);
 
255
        }
 
256
    }
 
257
    return "";
 
258
}
 
259
 
 
260
sub process_meta_config {
 
261
    my $line;
 
262
    while ($line = <CONFIG_BLOB>) {
 
263
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
264
            return $1;
 
265
        } else {
 
266
            if ($line =~ /(\S+):\s+(\S+)/) {
 
267
                print "meta config '$1' = '$2'\n";
 
268
                $config_meta{$1} = $2;
 
269
            } elsif ($line !~ /^\s*$/) {
 
270
                warn("Malformed meta config: $line\n");
 
271
            }
 
272
        }
 
273
    }
 
274
    return "";
 
275
}
 
276
 
 
277
sub process_other_file_blob {
 
278
    my ($file_name) = @_;
 
279
    my $file_path = $run_dir . "/etc/trafficserver/" . $file_name;
 
280
    
 
281
    open(OTHER_FILE, "> $file_path") || die "Failed to write file $file_name: $!\n";
 
282
 
 
283
    my $line;
 
284
    while ($line = <CONFIG_BLOB>) {
 
285
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
286
            close(OTHER_FILE);
 
287
            return $1;
 
288
        }
 
289
        print OTHER_FILE $line;
 
290
    }
 
291
 
 
292
    close (OTHER_FILE);
 
293
    return "";
 
294
};
 
295
 
 
296
sub read_test_config_blob {
 
297
    my ($test_config_blob) = @_;
 
298
 
 
299
    open (CONFIG_BLOB, "< $test_config_blob") || die "Failed to open config_blob: $!\n";
 
300
 
 
301
    my $line;
 
302
    my $file_name = "";
 
303
    while ($line = <CONFIG_BLOB>) {
 
304
 
 
305
        if ($line =~ /^\[([^\]]*)\]\s*$/) {
 
306
             $file_name= $1;
 
307
             last;
 
308
         }
 
309
    }
 
310
 
 
311
    while ($file_name ne "") {
 
312
        if ($file_name eq "records.config") {
 
313
            $file_name = process_records_blob();
 
314
        } elsif ($file_name eq "remap.config") {
 
315
            $file_name = process_remap_config();
 
316
        } elsif ($file_name eq "filter.config") {
 
317
            $file_name = process_filter_config();
 
318
        } elsif ($file_name eq "ipnat.conf") {
 
319
            $file_name = process_ipnat_conf();
 
320
        } elsif ($file_name eq "meta") {
 
321
            $file_name = process_meta_config();
 
322
        } else {
 
323
            # any other file is writting to config 
 
324
            $file_name = process_other_file_blob($file_name);
 
325
        }
 
326
    }
 
327
 
 
328
    close (CONFIG_BLOB);
 
329
}
 
330
 
 
331
my %records_seen = {};
 
332
 
 
333
sub output_records_config {
 
334
    my ($records_config_in, $records_config_out, $port_start) = @_;
 
335
 
 
336
    open (RECORDS_IN, "< $records_config_in") ||
 
337
        die "Couldn't open $records_config_in: $!\n";
 
338
 
 
339
    open (RECORDS_OUT, "> $records_config_out") ||
 
340
        die "Couldn't open $records_config_out: $!\n";
 
341
 
 
342
    my $rec_line;
 
343
    my $num_ports_alloc = 0;
 
344
 
 
345
    while($rec_line = <RECORDS_IN>) {
 
346
        my $new_line;
 
347
        if ($rec_line =~ /^\s*#/) {
 
348
            $new_line = $rec_line;
 
349
        } else {
 
350
            my $changed = 0;
 
351
            my $tmp;
 
352
            my ($r_class, $r_name, $r_type, $r_val) = split (/\s+/, $rec_line, 4);
 
353
 
 
354
            # Look at defaults
 
355
            if (defined($tmp = $defaults{$r_name})) {
 
356
                $r_val = $tmp;
 
357
                $changed = 1;
 
358
            }
 
359
            
 
360
            # Look at the port stuff
 
361
            if (defined($tmp = $base_port_hash{$r_name})) {
 
362
                $r_val = $port_start + $num_ports_alloc;
 
363
                $changed = 1;
 
364
                $num_ports_alloc++;
 
365
            }
 
366
 
 
367
            # Look at rc overrides
 
368
            if (defined($tmp = $override{$r_name})) {
 
369
                $r_val = $tmp;
 
370
                $changed = 1;
 
371
            }
 
372
 
 
373
            $records_seen{$r_name} = $r_val;
 
374
 
 
375
            if ($changed) {
 
376
                $new_line = $r_class . " " . $r_name . " " . "$r_type" . " " . "$r_val" . "\n";
 
377
            } else {
 
378
                $new_line = $rec_line;
 
379
            }
 
380
        }
 
381
 
 
382
        print RECORDS_OUT $new_line;
 
383
    }
 
384
 
 
385
    close(RECORDS_IN);
 
386
 
 
387
    my $config_entry;
 
388
    foreach $config_entry (@additional_config_entries) {
 
389
        my ($r_class, $r_name, $r_type, $r_val) = split (/\s+/, $config_entry, 4);
 
390
 
 
391
        if ($records_seen{$r_name}) {
 
392
            # We already has an entry for this record so ignore the addition
 
393
            next;
 
394
        }
 
395
 
 
396
        if ($r_val eq "<alloc_port>") {
 
397
            my $tmp;
 
398
            if (defined($tmp = $base_port_hash{$r_name})) {
 
399
                $r_val = $num_ports_alloc + $port_start;
 
400
                $config_entry = $r_class . " " . $r_name . " " . "$r_type" . " " . "$r_val" . "\n";
 
401
                $num_ports_alloc++;
 
402
            }
 
403
        }
 
404
 
 
405
        $records_seen{$r_name} = $r_val;        
 
406
        print RECORDS_OUT $config_entry . "\n";
 
407
    }
 
408
 
 
409
    close(RECORDS_OUT);
 
410
 
 
411
    return $num_ports_alloc;
 
412
}
 
413
 
 
414
sub output_remap_config {
 
415
    my $remap_file = $run_dir . "/etc/trafficserver/remap.config";
 
416
    
 
417
    open(REMAP_FILE, "> $remap_file") || die "Failed to write file $remap_file: $!\n";
 
418
 
 
419
    my $line;
 
420
    while ($line = shift(@remap_lines)) {
 
421
        chomp($line);
 
422
        my $output_line = "";
 
423
        while ($line) {
 
424
            if ($line =~ /([^\(]*)&&\(([^\)]+)\)(.*)/) {
 
425
                $output_line = $output_line . $1;
 
426
                my $rec_var = $2;
 
427
 
 
428
                if ($records_seen{$rec_var}) {
 
429
                    $output_line = $output_line . $records_seen{$rec_var};
 
430
                } else {
 
431
                    $output_line = $output_line . "&&(" . $2 . ")";
 
432
                }
 
433
                $line = $3;
 
434
            } else {
 
435
                $output_line = $output_line . $line;
 
436
                $line = "";
 
437
            }
 
438
        }
 
439
 
 
440
        print REMAP_FILE "$output_line\n";
 
441
    }
 
442
 
 
443
    close(REMAP_FILE);
 
444
}
 
445
 
 
446
sub output_ipnat_conf {
 
447
    my $ipnat_file = $run_dir . "/etc/trafficserver/ipnat.conf";
 
448
    
 
449
    open(IPNAT_FILE, "> $ipnat_file") || die "Failed to write file $ipnat_file: $!\n";
 
450
 
 
451
    my $line;
 
452
    while ($line = shift(@ipnat_lines)) {
 
453
        chomp($line);
 
454
        my $output_line = "";
 
455
        while ($line) {
 
456
            if ($line =~ /([^\(]*)&&\(([^\)]+)\)(.*)/) {
 
457
                $output_line = $output_line . $1;
 
458
                my $rec_var = $2;
 
459
 
 
460
                if ($records_seen{$rec_var}) {
 
461
                    $output_line = $output_line . $records_seen{$rec_var};
 
462
                } else {
 
463
                    $output_line = $output_line . "&&(" . $2 . ")";
 
464
                }
 
465
                $line = $3;
 
466
            } else {
 
467
                $output_line = $output_line . $line;
 
468
                $line = "";
 
469
            }
 
470
        }
 
471
 
 
472
        print IPNAT_FILE "$output_line\n";
 
473
    }
 
474
 
 
475
    close(IPNAT_FILE);
 
476
}
 
477
 
 
478
 
 
479
sub output_filter_config {
 
480
    my $filter_file = $run_dir . "/etc/trafficserver/filter.config";
 
481
    
 
482
    open(FILTER_FILE, "> $filter_file") || die "Failed to write file $filter_file: $!\n";
 
483
 
 
484
    my $line;
 
485
    while ($line = shift(@filter_lines)) {
 
486
        chomp($line);
 
487
        my $output_line = "";
 
488
        while ($line) {
 
489
            if ($line =~ /([^\(]*)&&\(eval(.)(.*)\2\)(.*)/) {
 
490
                $output_line = $output_line . $1;
 
491
                # print "eval|" . $3 . "|\n";
 
492
                my $tmp = eval $3;
 
493
                $output_line = $output_line . $tmp;
 
494
                $line = $4;
 
495
            } elsif ($line =~ /([^\(]*)&&\(([^\)]+)\)(.*)/) {
 
496
                $output_line = $output_line . $1;
 
497
                my $rec_var = $2;
 
498
 
 
499
                if ($records_seen{$rec_var}) {
 
500
                    $output_line = $output_line . $records_seen{$rec_var};
 
501
                } else {
 
502
                    $output_line = $output_line . "&&(" . $2 . ")";
 
503
                }
 
504
                $line = $3;
 
505
            } else {
 
506
                $output_line = $output_line . $line;
 
507
                $line = "";
 
508
            }
 
509
        }
 
510
 
 
511
        print FILTER_FILE "$output_line\n";
 
512
    }
 
513
 
 
514
    close(FILTER_FILE);
 
515
}
 
516
 
 
517
sub build_port_bindings {
 
518
    my ($records_config) = @_;
 
519
    my $output_line = "port_binding:";
 
520
 
 
521
    open (RECORDS, "< $records_config") ||
 
522
        die "Couldn't open $records_config: $!\n";
 
523
 
 
524
    my $rec_line;
 
525
 
 
526
    while($rec_line = <RECORDS>) {
 
527
        if ($rec_line !~ /^\s*#/) {
 
528
            my ($r_class, $r_name, $r_type, $r_val) = split (/\s+/, $rec_line);
 
529
 
 
530
            if ($export_ports{$r_name}) {
 
531
                $output_line = $output_line . " " . $export_ports{$r_name} . " " . $r_val;
 
532
            }
 
533
        }
 
534
    }
 
535
 
 
536
    return $output_line;
 
537
}
 
538
 
 
539
our @populate_dirs = ( "bin", "etc/trafficserver", "etc/trafficserver/internal", "logs");
 
540
 
 
541
our %populate_symlinks =
 
542
( "bin/traffic_server" => "bin/traffic_server",
 
543
  "bin/traffic_manager" => "bin/traffic_manager",
 
544
  "bin/traffic_cop" => "bin/traffic_cop",
 
545
  "bin/traffic_line" => "bin/traffic_line",
 
546
  "bin/start_traffic_server" => "bin/start_traffic_server",
 
547
  "bin/stop_traffic_server" => "bin/stop_traffic_server",
 
548
  "bin/filter_to_policy" => "bin/filter_to_policy",
 
549
  "etc/trafficserver/body_factory" => "etc/trafficserver/body_factory",
 
550
  "etc/trafficserver/plugins" => "etc/trafficserver/plugins",
 
551
  "lib" => "lib",
 
552
  "ui" => "ui"
 
553
);
 
554
 
 
555
our %populate_exclude_config =
 
556
(
 
557
 "records.config" => 1,
 
558
 "records.config.shadow" => 1,
 
559
 "storage.config.shadow" => 1
 
560
);
 
561
 
 
562
sub populate_run_dir() {
 
563
    my ($dir, $from_file_key);
 
564
 
 
565
    foreach $dir (@populate_dirs) {
 
566
        my $rdir = $run_dir . "/" . $dir;
 
567
        if (! -d $rdir) {
 
568
            mkdir($rdir);
 
569
        }
 
570
    }
 
571
 
 
572
    foreach $from_file_key (keys (%populate_symlinks)) {
 
573
        my $from_file = $bin_dir . "/" . $from_file_key;
 
574
        my $to_file = $run_dir . "/" . $populate_symlinks{$from_file_key};
 
575
 
 
576
        if (! -e $to_file && ! -l $to_file) {
 
577
            symlink($from_file, $to_file);
 
578
        }
 
579
    }
 
580
 
 
581
    my $config_dir_source = $bin_dir . "/etc/trafficserver";
 
582
    my $config_dir_target = $run_dir . "/etc/trafficserver";
 
583
 
 
584
    opendir(CONFIG_SOURCE_DIR, $config_dir_source) ||
 
585
        die "Couldn't open config src dir: $!\n";
 
586
 
 
587
    my $dir_ent;
 
588
    while ($dir_ent = readdir(CONFIG_SOURCE_DIR)) {
 
589
        if (! $populate_exclude_config{$dir_ent}) {
 
590
            my $source_file = $config_dir_source . "/" . $dir_ent;
 
591
            if (-f $source_file) {
 
592
                my $target_file = $config_dir_target . "/" . $dir_ent;
 
593
                copy($source_file, $target_file) || die "Copy of $dir_ent failed: $!\n";
 
594
            }
 
595
        }
 
596
    }
 
597
}
 
598
 
 
599
open(OUTPUT,">&=$ARGV[1]") || die "Couldn't open output: $!";
 
600
 
 
601
my $tmp;
 
602
my %input_args;
 
603
 
 
604
while ($tmp = <STDIN>) {
 
605
    print $tmp;
 
606
    if ($tmp =~ /^([^:]+):\s(.*)\n/) {
 
607
        $input_args{$1} = $2;
 
608
    }
 
609
}
 
610
 
 
611
my $records_config_in = "";
 
612
$bin_dir = $input_args{"bin_dir"};
 
613
 
 
614
if ($bin_dir) {
 
615
    $records_config_in = $bin_dir . "/etc/trafficserver/records.config";
 
616
} else {
 
617
    warn("bin_dir not sent\n");
 
618
    exit(1);
 
619
}
 
620
 
 
621
$run_dir = $input_args{"run_dir"};
 
622
my $no_run_dir = $input_args{"no_run_dir"};
 
623
 
 
624
my $records_config_out;
 
625
if ($no_run_dir) {
 
626
    $records_config_out = $bin_dir . "/etc/trafficserver/records.config.shadow";
 
627
    $run_dir = $bin_dir;
 
628
} else {
 
629
    $records_config_out = $run_dir . "/etc/trafficserver/records.config";
 
630
}
 
631
 
 
632
if (!$run_dir) {
 
633
    warn("run_dir not sent\n");
 
634
    exit(1);
 
635
}
 
636
 
 
637
if (! $no_run_dir) {
 
638
    populate_run_dir();
 
639
}
 
640
 
 
641
my $ports = $input_args{"ports_avail"};
 
642
 
 
643
my $config_blob = $input_args{"config_file"};
 
644
if (!$config_blob) {
 
645
    die("config_blob not sent\n");
 
646
}
 
647
 
 
648
read_test_config_blob($config_blob);
 
649
 
 
650
my ($start_port, $end_port);
 
651
if ($ports =~ /^(\d+)-(\d+)/) {
 
652
    $start_port = $1;
 
653
     $end_port = $2;
 
654
} else {
 
655
    warn("ports_avail invalid\n");
 
656
}
 
657
 
 
658
my $use_start_port = $base_port;
 
659
if ($use_start_port == 0) {
 
660
    $use_start_port = $start_port;
 
661
}
 
662
 
 
663
my $ports_used;
 
664
 
 
665
$ports_used = output_records_config($records_config_in,
 
666
                                    $records_config_out, $use_start_port);
 
667
 
 
668
if (scalar(@remap_lines) > 0) {
 
669
    output_remap_config();
 
670
}
 
671
 
 
672
if (scalar(@filter_lines) > 0) {
 
673
    output_filter_config();
 
674
}
 
675
 
 
676
if (scalar(@ipnat_lines) > 0) {
 
677
    output_ipnat_conf();
 
678
}
 
679
 
 
680
my $cmd_line = "cmd_line: $bin_dir/bin/";
 
681
if ($config_meta{"run_manager"}) {
 
682
   $cmd_line = $cmd_line . "traffic_manager";
 
683
} else {
 
684
   $cmd_line = $cmd_line . "traffic_server";
 
685
}
 
686
 
 
687
if ($use_start_port == $start_port) {
 
688
    print OUTPUT "ports_used: $ports_used\n";
 
689
}
 
690
 
 
691
my $bindings = build_port_bindings($records_config_out);
 
692
print OUTPUT $bindings . "\n";
 
693
 
 
694
print OUTPUT $cmd_line . "\n";
 
695
 
 
696
#
 
697
my $ld_lib_path = $ENV{"LD_LIBRARY_PATH"};
 
698
 
 
699
if ($ld_lib_path eq "") {
 
700
    $ld_lib_path = $run_dir . "/bin";
 
701
    $ld_lib_path .= $run_dir . "/lib";
 
702
} else {
 
703
    $ld_lib_path  = $ld_lib_path . ":" . $run_dir . "/bin";
 
704
    $ld_lib_path .= $ld_lib_path . ":" . $run_dir . "/lib";
 
705
}
 
706
 
 
707
print OUTPUT "env_vars: LD_LIBRARY_PATH=" . $ld_lib_path . "\n";
 
708
 
 
709
exit(0);