~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/snmp/test/snmp_agent_test.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%<copyright>
2
 
%% <year>2003-2007</year>
 
2
%% <year>2003-2008</year>
3
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
4
%%</copyright>
5
5
%%<legalnotice>
148
148
             test_v2, 
149
149
             test_v1_v2, 
150
150
             test_v3, 
151
 
             test_multi_threaded, 
152
 
             mib_storage, 
153
 
             tickets
 
151
             test_multi_threaded, 
 
152
             mib_storage, 
 
153
             tickets
154
154
            ]
155
155
    end.
156
156
 
2618
2618
db_notify_client(Config) when list(Config) ->
2619
2619
    ?P(db_notify_client), 
2620
2620
    {SaNode, MgrNode, MibDir} = init_case(Config),
2621
 
    ?DBG("~n\tSaNode: ~p~n\tMgrNode: ~p~n\tMibDir: ~p",
2622
 
           [SaNode,MgrNode,MibDir]),
 
2621
    ?DBG("db_notify_client -> case initiated: "
 
2622
         "~n   SaNode:  ~p"
 
2623
         "~n   MgrNode: ~p"
 
2624
         "~n   MibDir:  ~p", [SaNode, MgrNode, MibDir]),
 
2625
    ?DBG("db_notify_client -> maximize verbosity", []),
 
2626
    snmpa_local_db:verbosity(trace),
 
2627
    Self = self(), 
 
2628
    ?DBG("db_notify_client -> register self (~p) notify client", [Self]),
2623
2629
    snmpa_local_db:register_notify_client(self(),?MODULE),
2624
2630
 
2625
 
    %% This call (the manager) will issue to set operations, so
 
2631
    %% This call (to the manager) will issue to set operations, so
2626
2632
    %% we expect to receive to notify(insert) calls.
2627
2633
    try_test(db_notify_client_test),
2628
2634
 
2629
 
    ?DBG("await first notify",[]),
 
2635
    ?DBG("db_notify_client -> await first notify",[]),
2630
2636
    receive 
2631
 
        {db_notify_test_reply,insert} -> ?DBG("first notify received",[]),ok
 
2637
        {db_notify_test_reply, insert} -> 
 
2638
            ?DBG("db_notify_client -> first notify received",[]),
 
2639
            ok
 
2640
    after 10000 ->
 
2641
            ?FAIL({timeout, waiting_for_first_event})
2632
2642
    end,
2633
2643
    
2634
 
    ?DBG("await second notify",[]),
 
2644
    ?DBG("db_notify_client -> await second notify",[]),
2635
2645
    receive 
2636
 
        {db_notify_test_reply,insert} -> ?DBG("second notify received",[]),ok
 
2646
        {db_notify_test_reply, insert} -> 
 
2647
            ?DBG("db_notify_client -> second notify received",[]),
 
2648
            ok
 
2649
    after 10000 ->
 
2650
            ?FAIL({timeout, waiting_for_second_event})
2637
2651
    end,
2638
2652
 
2639
 
    snmpa_local_db:unregister_notify_client(self()).
 
2653
    ?DBG("db_notify_client -> unregister self (~p) notify client", [Self]),
 
2654
    snmpa_local_db:unregister_notify_client(self()),
 
2655
    ?DBG("db_notify_client -> minimize verbosity", []),
 
2656
    snmpa_local_db:verbosity(silence),
 
2657
 
 
2658
    ?DBG("db_notify_client -> done", []),
 
2659
    ok.
2640
2660
 
2641
2661
 
2642
2662
%% This is run in the manager node
2649
2669
    s([{[sysLocation, 0], "new_value"}]),
2650
2670
    ?line expect(5, [{[sysLocation, 0], "new_value"}]).
2651
2671
 
2652
 
notify(Pid,What) -> 
 
2672
notify(Pid, What) -> 
2653
2673
    ?DBG("notify(~p,~p) -> called",[Pid,What]),
2654
 
    Pid ! {db_notify_test_reply,What}.
 
2674
    Pid ! {db_notify_test_reply, What}.
2655
2675
 
2656
2676
 
2657
2677
%% Req: system group, OLD-SNMPEA-MIB, Klas1
3411
3431
                after
3412
3432
                    20000 ->
3413
3433
                        ?ERR("ma_v2_inform1 -> "
3414
 
                             "timeout awaiting snmp_notification [tag1]",
3415
 
                             []),
 
3434
                             "timeout awaiting snmp_notification [~p]",
 
3435
                             [Tag03]),
3416
3436
                        {error, snmp_notification_timeout}
3417
3437
                end
3418
3438
        end,
3450
3470
                after
3451
3471
                    240000 ->
3452
3472
                        ?ERR("ma_v2_inform1 -> "
3453
 
                             "timeout awaiting snmp_notification [tag2]",
3454
 
                             []),
 
3473
                             "timeout awaiting snmp_notification [~p]",
 
3474
                             [Tag07]),
3455
3475
                        {error, snmp_notification_timeout}
3456
3476
                end
3457
3477
        end,
4133
4153
    ?line [EngineTime] = get_req(2, [[snmpEngineTime,0]]),
4134
4154
    ?SLEEP(5000),
4135
4155
    ?line [EngineTime2] = get_req(3, [[snmpEngineTime,0]]),
 
4156
    ?DBG("snmp_framework_mib -> time(s): "
 
4157
         "~n   EngineTime 1 = ~p"
 
4158
         "~n   EngineTime 2 = ~p", [EngineTime, EngineTime2]),
4136
4159
    if 
4137
 
        EngineTime+7 < EngineTime2 ->
4138
 
            ?line ?FAIL({too_large_diff, EngineTime, EngineTime2});
4139
 
        EngineTime+4 > EngineTime2 ->
4140
 
            ?line ?FAIL({too_large_diff, EngineTime, EngineTime2});
4141
 
        true -> ok
 
4160
        (EngineTime+7) < EngineTime2 ->
 
4161
            ?line ?FAIL({too_large_diff, EngineTime, EngineTime2});
 
4162
        (EngineTime+4) > EngineTime2 ->
 
4163
            ?line ?FAIL({too_large_diff, EngineTime, EngineTime2});
 
4164
        true -> 
 
4165
            ok
4142
4166
    end,
4143
4167
    ?line case get_req(4, [[snmpEngineBoots,0]]) of
4144
 
              [Boots] when integer(Boots) -> ok;
4145
 
              Else -> ?FAIL(Else)
 
4168
              [Boots] when is_integer(Boots) -> 
 
4169
                  ok;
 
4170
              Else -> 
 
4171
                  ?FAIL(Else)
4146
4172
          end,
4147
4173
    ok.
4148
4174
 
4890
4916
%%%-----------------------------------------------------------------
4891
4917
 
4892
4918
reported_bugs(suite) ->
4893
 
    [otp_1128, otp_1129, otp_1131, otp_1162,
4894
 
     otp_1222, otp_1298, otp_1331, otp_1338,
4895
 
     otp_1342, otp_2776, otp_2979, otp_3187, otp_3725].
 
4919
    [
 
4920
     otp_1128, 
 
4921
     otp_1129, 
 
4922
     otp_1131, 
 
4923
     otp_1162,
 
4924
     otp_1222, 
 
4925
     otp_1298, 
 
4926
     otp_1331, 
 
4927
     otp_1338,
 
4928
     otp_1342, 
 
4929
     otp_2776, 
 
4930
     otp_2979, 
 
4931
     otp_3187, 
 
4932
     otp_3725
 
4933
    ].
4896
4934
 
4897
4935
reported_bugs_2(suite) ->
4898
 
    [otp_1128_2, otp_1129_2, otp_1131_2, otp_1162_2,
4899
 
     otp_1222_2, otp_1298_2, otp_1331_2, otp_1338_2,
4900
 
     otp_1342_2, otp_2776_2, otp_2979_2, otp_3187_2].
 
4936
    [
 
4937
     otp_1128_2, 
 
4938
     otp_1129_2, 
 
4939
     otp_1131_2, 
 
4940
     otp_1162_2,
 
4941
     otp_1222_2, 
 
4942
     otp_1298_2, 
 
4943
     otp_1331_2, 
 
4944
     otp_1338_2,
 
4945
     otp_1342_2, 
 
4946
     otp_2776_2, 
 
4947
     otp_2979_2, 
 
4948
     otp_3187_2
 
4949
    ].
4901
4950
 
4902
4951
reported_bugs_3(suite) ->
4903
 
    [otp_1128_3, otp_1129_3, otp_1131_3, otp_1162_3,
4904
 
     otp_1222_3, otp_1298_3, otp_1331_3, otp_1338_3,
4905
 
     otp_1342_3, otp_2776_3, otp_2979_3, otp_3187_3,
4906
 
     otp_3542].
 
4952
    [
 
4953
     otp_1128_3, 
 
4954
     otp_1129_3, 
 
4955
     otp_1131_3, 
 
4956
     otp_1162_3,
 
4957
     otp_1222_3, 
 
4958
     otp_1298_3, 
 
4959
     otp_1331_3, 
 
4960
     otp_1338_3,
 
4961
     otp_1342_3, 
 
4962
     otp_2776_3, 
 
4963
     otp_2979_3, 
 
4964
     otp_3187_3,
 
4965
     otp_3542
 
4966
    ].
4907
4967
 
4908
4968
 
4909
4969
%% These are (ticket) test cases where the initiation has to be done