forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-azure.xml
120 lines (91 loc) · 3.41 KB
/
build-test-azure.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
<?xml version="1.0"?>
<project basedir="." name="portal-test-azure" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="delete-azure-containers">
<sequential>
<local name="container.list" />
<exec executable="az" outputproperty="container.list">
<arg line="storage container list --account-name blobstoragesmoketest --prefix lfr-qa-poshi-test --auth-mode login" />
</exec>
<script language="javascript"><![CDATA[
var containerList = project.getProperty("container.list");
var expiredContainers = [];
var json = JSON.parse(containerList);
for (var i = 0; i < json.length; i++) {
var container = json[i];
var name = JSON.stringify(container.name);
if (name.indexOf('lfr-qa-poshi-test') > -1) {
var lastModified = container.properties.lastModified;
var currentDate = new Date();
var containerDate = new Date(lastModified);
var diffHours = (currentDate - containerDate) / (1000 * 60 * 60);
if (diffHours > 12) {
expiredContainers.push(name);
}
}
}
project.setProperty("expired.containers", expiredContainers.toString());]]>
</script>
<for list="${expired.containers}" param="delete.name">
<sequential>
<echo>Expired Container: @{delete.name}</echo>
<exec executable="az">
<arg line="storage container delete --account-name blobstoragesmoketest --name @{delete.name} --auth-mode login" />
</exec>
</sequential>
</for>
</sequential>
</macrodef>
<target name="assert-document-in-container">
<local name="container.blobs" />
<exec executable="az" outputproperty="container.blobs">
<arg line="storage blob list --container-name lfr-qa-poshi-test-${azure.container.id} --account-name blobstoragesmoketest --prefix ${companyId}/${groupId} --output table" />
</exec>
<echo>${container.blobs}</echo>
<if>
<contains string="${container.blobs}" substring="1.0" />
<then>
<echo>Document is in container.</echo>
</then>
<else>
<fail>Document is not in container.</fail>
</else>
</if>
</target>
<target name="assert-no-document-in-container">
<local name="container.blobs" />
<exec executable="az" outputproperty="container.blobs">
<arg line="storage blob list --container-name lfr-qa-poshi-test-${azure.container.id} --account-name blobstoragesmoketest --prefix ${companyId}/${groupId} --output table" />
</exec>
<echo>${container.blobs}</echo>
<if>
<not>
<isset property="${container.blobs}" />
</not>
<then>
<echo>The container is empty.</echo>
</then>
<else>
<fail>The container is not empty.</fail>
</else>
</if>
</target>
<target name="create-azure-container">
<local name="container.create.output" />
<exec executable="az" outputproperty="container.create.output">
<arg line="storage container create -n lfr-qa-poshi-test-${azure.container.id} --public-access container --account-name blobstoragesmoketest" />
</exec>
<echo>${container.create.output}</echo>
</target>
<target name="delete-azure-container">
<exec executable="az">
<arg line="storage container delete --account-name blobstoragesmoketest --name lfr-qa-poshi-test-${azure.container.id}" />
</exec>
<delete-azure-containers />
</target>
<target name="login-azure-cli">
<exec executable="az">
<arg line="login -u ${azure.account.email.address} -p ${azure.account.password}" />
</exec>
</target>
</project>