language: Erlang (erl-5.7.3)
date: 969 days 1 hour ago
link:
visibility: public
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
-module(migration_SUITE).
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
 
% Require the following tags before executing the suite.
% The tags are provided by a config file
suite() ->
    [{require, hidenets},
     {require, demo},
     {require, node1},
     {require, node2},
     {require, testserver}].
 
init_per_suite(Config) ->
        % Start ssh connections
        {ok, Hidenets} = ct_ssh:connect(hidenets),
        {ok, Demo} = ct_ssh:connect(demo),
        {ok, Node1} = ct_ssh:connect(node1),
        {ok, Node2} = ct_ssh:connect(node2),
        {ok, Testserver} = ct_ssh:connect(testserver),
 
        % Append handles to config
        % OBS: This is not actually used, because of the disconnect issue
        [{ssh_handles,{Hidenets,Demo,Node1,Node2,Testserver}} | Config].
        
end_per_suite(Config) ->
        % Disconnect from all handles
        Handles = erlang:tuple_to_list(?config(ssh_handles, Config)),
        lists:foreach(fun(Handle) -> ct_ssh:disconnect(Handle) end,
                                Handles).
 
init_per_group(_GroupName, Config) ->
        % Get ssh handles from config
        % {Hidenets, Demo, Node1, Node2, Testserver} = ?config(ssh_handles, Config),
 
        % Start context agent on hidenets (simple console application)
        runcmd(hidenets, "./ContextAgentLinux/ContextAgent"),
 
        % Start GUI macro playback
        runcmd(hidenets, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee.xns"),
        runcmd(demo, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee.xns"),
        runcmd(node1, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee.xns"),
        runcmd(node2, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee.xns"),
        Config.
 
 
end_per_group(_GroupName, Config) ->
        % Get ssh handles from config
        % {Hidenets, Demo, Node1, Node2, Testserver} = ?config(ssh_handles, Config),
 
        % Stop GUY macro playback
        runcmd(hidenets, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-end.xns"),
        runcmd(demo, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-end.xns"),
        runcmd(node1, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-end.xns"),
        runcmd(node2, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-end.xns"),
 
        % Stop context agent on hidenets
        runcmd(hidenets, "pkill Context"),
        ok.
 
% Initialize the testcase
init_per_testcase(_TestCase, Config) ->
        Config.
 
% Execute the following after a test case is finished
end_per_testcase(_TestCase, Config) ->
        ok.
 
groups() ->
        [{migrateTest, [sequence], [migCase1, migCase2]}].
 
all() ->
        % Return a list of all test cases in the suite.
        [migrateTest].
 
migCase1() ->
        [].
 
migCase2() ->
        [].
 
migCase1(Config) ->
                %Hidenets = element(1, ?config(ssh_handles,Config)),
 
                % Arbitrary delay to ensure eclipse + CA is started up and running
                ok = timer:sleep(5000),
 
                % Trigger
                runcmd(hidenets, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-triggerzero.xns"),
                ok = timer:sleep(5000),
                ok.
 
migCase2(Config) ->
                % Hidenets = element(1, ?config(ssh_handles,Config)),
                % Arbitrary delay to ensure eclipse + CA is started up and running
                ok = timer:sleep(5000),
 
                % Trigger
                runcmd(hidenets, "export DISPLAY=:0.0 && cnee --replay -f ~/ct/xnee/xnee-triggerone.xns"),
                ok = timer:sleep(5000),
                ok.
 
 
%%%%% HELPER FUNCTIONS %%%%%%%%%
runcmd(HandleCfg, Cmd) ->
        case ct_ssh:connect(HandleCfg) of
                {ok, Handle} ->
                        case ct_ssh:exec(Handle, Cmd, 3000) of
                        {ok, Data} -> ok;
                        {error, _} -> runcmd(HandleCfg, Cmd);
                        {_, _} -> ok
                        end;
                {error, _} ->
                        runcmd(HandleCfg, Cmd);
                _ ->
                        runcmd(HandleCfg, Cmd)
        end.