2 #include "ace/Get_Opt.h"
3 #include "tao/IORManipulation/IORManip_Loader.h"
4 // Ensure that the PI library is linked in when building statically
6 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
7 #include "orbsvcs/FaultTolerance/FT_IOGR_Property.h"
8 #include "ace/Auto_Ptr.h"
11 //const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
12 TAO_IOP::TAO_IOR_Manipulation_var iorm
= 0;
13 CORBA::ULong number_of_servers
= 0;
16 parse_args (int argc
, ACE_TCHAR
*argv
[])
18 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:"));
21 while ((c
= get_opts ()) != -1)
27 number_of_servers
= ACE_OS::atoi (get_opts
.opt_arg ());
31 ACE_ERROR_RETURN ((LM_ERROR
,
38 // Indicates successful parsing of the command line
43 make_iogr (const char* domain_id
, CORBA::ULongLong group_id
, CORBA::ULong group_version
, Test::Hello_var
*refs
)
45 FT::TagFTGroupTaggedComponent ft_tag_component
;
47 TAO_IOP::TAO_IOR_Manipulation::IORList
iors (number_of_servers
);
48 iors
.length(number_of_servers
);
49 for (CORBA::ULong i
= 0; i
< number_of_servers
; ++i
)
51 iors
[i
] = CORBA::Object::_duplicate (refs
[i
].in ());
54 CORBA::Object_var new_ref
=
55 iorm
->merge_iors (iors
);
59 // Major and Minor revision numbers
60 ft_tag_component
.component_version
.major
= (CORBA::Octet
) 1;
61 ft_tag_component
.component_version
.minor
= (CORBA::Octet
) 0;
64 //const char *id = "iogr_testing";
65 ft_tag_component
.group_domain_id
= domain_id
;
68 ft_tag_component
.object_group_id
= group_id
;
71 ft_tag_component
.object_group_ref_version
= group_version
;
73 // Construct the IOGR Property class
74 TAO_FT_IOGR_Property
iogr_prop (ft_tag_component
);
77 CORBA::Boolean retval
= iorm
->set_property (&iogr_prop
,
81 // See we are setting the second ior as the primary
84 retval
= iorm
->set_primary (&iogr_prop
,
89 return new_ref
._retn ();
93 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
95 CORBA::Boolean result
= 0;
99 CORBA::ORB_init (argc
, argv
);
101 if (parse_args (argc
, argv
) != 0)
104 // Get a ref to the IORManipulation object
105 CORBA::Object_var IORM
=
106 orb
->resolve_initial_references (TAO_OBJID_IORMANIPULATION
,
111 TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM
.in());
113 Test::Hello_var
*servers
= 0;
114 ACE_NEW_RETURN (servers
,
115 Test::Hello_var
[number_of_servers
],
117 std::unique_ptr
<Test::Hello_var
[]> owner (servers
);
119 for (CORBA::ULong i
= 0; i
< number_of_servers
; ++ i
)
121 char buf
[4]; // if you run more than 10000 servers then you need your head looking at
122 const char *number
= ACE_OS::itoa ((int) i
, buf
, 10);
123 ACE_CString
ior_file ("file://n");
124 const char *ior
= ((ior_file
+= number
) += ".ior").c_str ();
126 CORBA::Object_var tmp
=
127 orb
->string_to_object(ior
);
130 Test::Hello::_narrow(tmp
.in ());
132 if (CORBA::is_nil (servers
[i
].in ()))
134 ACE_ERROR_RETURN ((LM_DEBUG
,
135 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
141 CORBA::Object_var iogr
= make_iogr ("Domain_1", 1, 1, servers
);
143 Test::Hello_var hello_iogr
= Test::Hello::_narrow(iogr
.in ());
145 CORBA::ULong last_server
= 0;
149 last_server
= hello_iogr
->drop_down_dead ();
150 // If the call 'succeeds' the server has identified a regression.
152 ACE_DEBUG ((LM_ERROR
, "Error: REGRESSION identified by server %u. Test Failed !!\n", last_server
));
154 catch (const CORBA::COMM_FAILURE
&)
156 // We can't use the word exception for fear of upsetting the build log parser
157 ACE_DEBUG ((LM_DEBUG
, "Client caught one of those things that is normally used to indicate a problem ("
158 "although it doesn't in this case) and which we cannot name because the autobuild "
159 "script will think we have a problem if we do mention the word. No problem !\n"));
162 for (CORBA::ULong j
= last_server
; j
< number_of_servers
; ++j
)
166 servers
[j
]->shutdown ();
176 catch (const CORBA::Exception
& ex
)
178 ex
._tao_print_exception (
179 "Test failed (Not regression) because unexpected exception caught:");
185 ACE_DEBUG ((LM_ERROR
, "Error: REGRESSION identified!!!\n"));
189 ACE_DEBUG ((LM_DEBUG
, "Test passed !!!\n"));