forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-test-apacheds.xml
193 lines (169 loc) · 5.09 KB
/
build-test-apacheds.xml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?xml version="1.0"?>
<project basedir="." name="portal-test-apacheds" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="install-apacheds-utils">
<sequential>
<exec executable="/bin/bash">
<arg value="-c" />
<arg value="yum install openldap-clients -y" />
</exec>
</sequential>
</macrodef>
<macrodef name="search-apacheds-data">
<sequential>
<property name="liferay.ldap.dependency.dir" value="${project.dir}/portal-web/test/functional/com/liferay/portalweb/dependencies/ldap" />
<exec dir="${liferay.ldap.dependency.dir}" executable="/bin/bash">
<arg value="-c" />
<arg value="ldapsearch -x -b dc=example,dc=com -H ldap://0.0.0.0:10389 >> ${project.dir}/LDAPSearchResult.txt" />
</exec>
</sequential>
</macrodef>
<macrodef name="unzip-apacheds">
<sequential>
<delete dir="${apacheds.dir}" />
<if>
<not>
<available file="${app.server.parent.dir}/${apacheds.zip.name}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${apacheds.zip.name}"
src="${apacheds.zip.url}"
verbose="true"
/>
</then>
</if>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${apacheds.zip.name}"
/>
</sequential>
</macrodef>
<macrodef name="unzip-apacheds-instance-custom">
<attribute default="" name="apacheds.instance.custom.zip.name" />
<sequential>
<if>
<not>
<available file="${apacheds.dir}/instances/@{apacheds.instance.custom.zip.name}" />
</not>
<then>
<mirrors-get
dest="${apacheds.dir}/instances/@{apacheds.instance.custom.zip.name}"
src="${apacheds.instance.custom.base.url}/@{apacheds.instance.custom.zip.name}"
verbose="true"
/>
</then>
</if>
<unzip
dest="${apacheds.dir}/instances"
src="${apacheds.dir}/instances/@{apacheds.instance.custom.zip.name}"
/>
</sequential>
</macrodef>
<macrodef name="update-apacheds-data">
<sequential>
<property name="liferay.ldap.dependency.dir" value="${project.dir}/portal-web/test/functional/com/liferay/portalweb/dependencies/ldap" />
<exec dir="${liferay.ldap.dependency.dir}" executable="/bin/bash">
<arg value="-c" />
<arg value="ldapadd -c -D uid=admin,ou=system -f ${ldifName}.ldif -H ldap://0.0.0.0:10389 -v -w secret -x" />
</exec>
</sequential>
</macrodef>
<macrodef name="update-apacheds-log4j-level">
<sequential>
<replace
file="${apacheds.dir}/instances/liferay/conf/log4j.properties"
>
<replacetoken><![CDATA[log4j.rootCategory=WARN, F, stdout]]></replacetoken>
<replacevalue><![CDATA[log4j.rootCategory=INFO, F, stdout]]></replacevalue>
</replace>
</sequential>
</macrodef>
<target name="get-apacheds-commands">
<install-apacheds-utils />
</target>
<target name="search-apacheds">
<search-apacheds-data />
</target>
<target name="start-apacheds">
<unzip-apacheds />
<get-testcase-property property.name="apacheds.blank.user.password.enabled" />
<if>
<equals arg1="${apacheds.blank.user.password.enabled}" arg2="true" />
<then>
<unzip-apacheds-instance-custom
apacheds.instance.custom.zip.name="${apacheds.instance.blank.user.password.custom.zip.name}"
/>
</then>
<elseif>
<equals arg1="${apacheds.multiple.users.enabled}" arg2="true" />
<then>
<unzip-apacheds-instance-custom
apacheds.instance.custom.zip.name="${apacheds.instance.multiple.users.custom.zip.name}"
/>
</then>
</elseif>
<else>
<unzip-apacheds-instance-custom
apacheds.instance.custom.zip.name="${apacheds.instance.custom.zip.name}"
/>
</else>
</if>
<update-apacheds-log4j-level />
<if>
<os family="unix" />
<then>
<chmod
file="${apacheds.dir}/bin/**"
perm="a+x"
/>
<exec dir="${apacheds.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./apacheds.sh liferay start" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${apacheds.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="apacheds.bat liferay" />
</exec>
</then>
</elseif>
</if>
<waitfor checkevery="5" maxwait="60" maxwaitunit="second">
<available file="${apacheds.dir}/instances/liferay/log/apacheds.log" />
</waitfor>
<waitfor maxwait="60" maxwaitunit="second">
<socket port="10389" server="localhost" />
</waitfor>
<loadfile
property="apacheds.log.content"
srcfile="${apacheds.dir}/instances/liferay/log/apacheds.log"
/>
<print-file file.name="${apacheds.dir}/instances/liferay/log/apacheds.log" />
<if>
<not>
<contains string="${apacheds.log.content}" substring="DirectoryService initialized" />
</not>
<then>
<fail message="ApacheDS server failed to initialize." />
</then>
</if>
</target>
<target name="stop-apacheds">
<if>
<os family="unix" />
<then>
<exec dir="${apacheds.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./apacheds.sh liferay stop" />
</exec>
</then>
</if>
</target>
<target name="update-apacheds">
<update-apacheds-data />
</target>
</project>