summaryrefslogtreecommitdiffstats
path: root/verigraph/gRPC-build.xml
blob: 50483c803fd3384aaef66eba35c0e2d9e1b619c6 (plain)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2017 Politecnico di Torino and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Apache License, Version 2.0
 which accompanies this distribution, and is available at
 http://www.apache.org/licenses/LICENSE-2.0
-->
<project name="gRPC-Verigraph" default="gRPC-run" basedir="."  xmlns:artifact="antlib:org.apache.maven.artifact.ant">
  <description>
      Script for gRPC-Verigraph
  </description>

  <!-- The location of this assignment -->
  <property name="grpc.location" location="." />
  <!-- The location to be used for class files -->
  <property name="build.dir" location="${grpc.location}/build" />
  <!-- The location for source files -->
  <property name="src.dir" location="${grpc.location}/src" />
  <!-- The location for solutions -->
  <property name="grpc.dir" value="src/it/polito/verigraph/grpc" />
  <!-- The location for jar files -->
  <property name="lib.dir" location="${grpc.location}/lib" />
  <!-- The location for jar files -->
  <property name="other_lib.dir" location="${grpc.location}/service/build" />
  <!-- The location for generated files -->
  <property name="generated.dir" location="${basedir}/gen-protobuf" />
  <!-- The default test class -->
  <property name="test1.class" value="it.polito.verigraph.grpc.test.GrpcServerTest" />
  <property name="test2.class" value="it.polito.verigraph.grpc.test.GrpcTest" />
  <property name="test3.class" value="it.polito.verigraph.grpc.test.MultiThreadTest" />
  <property name="test4.class" value="it.polito.verigraph.grpc.test.ReachabilityTest" />
  <!-- Tosca grpc test class -->
  <property name="testToscaGrpc.class" value="it.polito.verigraph.grpc.tosca.test.GrpcToscaTest" />
  <!-- The name to be given to the final zip -->
  <property name="sol.zip" value="grpc.zip" />
  <!-- Java compiler settings -->
  <property name="debug" value="true" />
  <property name="debuglevel" value="source,lines,vars" />
  <property name="target" value="1.8" />
  <property name="source" value="1.8" />

  <!-- The classpath to be used for running the tests -->
  <path id="test.classpath">
    <pathelement path="${build.dir}" />
    <fileset dir="${grpc.location}/lib">
      <include name="com.microsoft.z3.jar" />
    </fileset>
    <fileset refid="mvn-dependencies" />
  </path>

  <!-- Here starts part for Maven -->
  <path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
  <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
             uri="antlib:org.apache.maven.artifact.ant"
             classpathref="maven-ant-tasks.classpath" />
  <property file="build.properties"/>

  <!-- Load pom.xml for dependencies -->
  <artifact:pom id="pomfile" file="pom.xml" />
  <artifact:dependencies filesetId="mvn-dependencies" pomRefId="pomfile" />

  <!-- Grab the HSQLDB jar and add it to the classpath
  <artifact:dependencies filesetId="warDeps">
    <dependency groupId="org.glassfish.jersey" artifactId="jersey-bom" version="2.22.1" />
  </artifact:dependencies>-->

  <path id="build.classpath">
    <fileset refid="mvn-dependencies" />
  </path>

  <!-- target name="init">
    <mkdir dir="${build.dir}" />
  </target-->


  <!-- The target for compiling the gRPC application -->
  <!--target name="gRPC-build" depends="init" description="Build the sources"-->
  <target name="gRPC-build" description="Build the sources">
    <echo>Building gRPC (if needed)...</echo>
    <javac
        debug="${debug}"
        debuglevel="${debuglevel}"
        source="${source}"
        target="${target}"
        destdir="${build.dir}"
        classpathref="build.classpath"
        includeantruntime="false">
      <src path="${generated.dir}" />
      <src path="${src.dir}" />
      <src path="${grpc.location}/gen-src"/>
      <compilerarg value="-Xlint:unchecked"/>
      <classpath>
        <pathelement path="${grpc.location}/lib/com.microsoft.z3.jar"/>
      </classpath>
      <include name="$it/polito/**/**/*.java"/>
      <!-- classpath>
          <pathelement path="${other_lib.dir}/qjutils.jar"/>
        </classpath-->
    </javac>
    <echo>Done.</echo>
  </target>


  <!-- The target for running the gRPC application -->
  <target name="gRPC-run" depends="gRPC-build" description="Run gRPC">
    <parallel>
      <sequential>
        <java classname="it.polito.verigraph.grpc.Service" failonerror="true" classpathref="build.classpath" fork="yes">
          <classpath>
            <pathelement path="${build.dir}"/>
            <path refid="test.classpath" />
          </classpath>
        </java>
      </sequential>
      <sequential>
        <sleep milliseconds="500"/>
        <java classname="it.polito.verigraph.grpc.Client" failonerror="true" classpathref="build.classpath" fork="yes">
          <classpath>
            <pathelement path="${build.dir}"/>
          </classpath>
        </java>
      </sequential>
    </parallel>
  </target>


  <target name="gRPC-run-client" depends="gRPC-build" description="Run gRPC client">
    <java classname="it.polito.verigraph.grpc.client.Client" failonerror="true" classpathref="build.classpath" fork="yes">
      <classpath>
        <pathelement path="${build.dir}"/>
      </classpath>
    </java>
  </target>


  <target name="gRPC-run-server" depends="gRPC-build" description="Run gRPC server">
    <java classname="it.polito.verigraph.grpc.server.Service" failonerror="true" classpathref="build.classpath" fork="yes">
      <classpath>
        <pathelement path="${build.dir}"/>
        <path refid="test.classpath" />
      </classpath>
    </java>
  </target>


  <target name="gRPC-run-tests" description="Run tests for gRPC">
    <echo>Running functional tests</echo>
    <antcall target="runFuncTest.real">
      <param name="exit.code1" value="126" />
      <param name="exit.code2" value="125" />
      <param name="exit.code3" value="124" />
      <param name="exit.code4" value="123" />
    </antcall>
  </target>

  <!-- Run Tosca Grpc Tests -->
  <target name="gRPC-tosca-run-tests" description="Run tests for Tosca implementation of gRPC">
    <echo>Running grpc tests...</echo>
    <junit printsummary="yes" dir="." fork="yes" haltonfailure="no" showoutput="yes" filtertrace="true" timeout="120000">
      <jvmarg value="-Djava.awt.headless=true" />
      <formatter type="brief" usefile="false" />
      <test haltonfailure="no" failureproperty="test_failed" name="${testToscaGrpc.class}" />
      <classpath>
        <path refid="test.classpath" />
      </classpath>
    </junit>
    <fail if="test_failed" message="*** JUnit tests for gRPC Tosca completed: some Tests FAILED ***" />
  </target>

  <!-- Target runFuncTest.real  -->
  <target name="runFuncTest.real" depends="gRPC-build">
    <echo>Running First set of Junit tests...</echo>
    <junit printsummary="yes" dir="." fork="yes" haltonfailure="no" showoutput="no" filtertrace="true" timeout="120000">
      <jvmarg value="-Djava.awt.headless=true" />
      <formatter type="brief" usefile="false"/>
      <test haltonfailure="no" failureproperty="test_failed" name="${test1.class}"/>
      <classpath>
        <path refid="test.classpath" />
      </classpath>
    </junit>
    <fail if="test_failed" status="${exit.code1}" message="*** First set of Junit tests: Some Tests FAILED ***"/>
    <echo>*** First set of Junit tests: All Tests PASSED  ***</echo>

    <echo>Running Second set of Junit tests...</echo>
    <junit printsummary="yes" dir="." fork="yes" haltonfailure="no" showoutput="no" filtertrace="true" timeout="120000">
      <jvmarg value="-Djava.awt.headless=true" />
      <formatter type="brief" usefile="false"/>
      <test haltonfailure="no" failureproperty="test_failed" name="${test2.class}"/>
      <classpath>
        <path refid="test.classpath" />
      </classpath>
    </junit>
    <fail if="test_failed" status="${exit.code2}" message="*** Second set of Junit tests: Some Tests FAILED ***"/>
    <echo>*** Second set of Junit tests: All Tests PASSED  ***</echo>

    <!--echo>Running Third set of Junit tests...</echo>
    <junit printsummary="yes" dir="." fork="yes" haltonfailure="no" showoutput="no" filtertrace="true" timeout="120000">
      <jvmarg value="-Djava.awt.headless=true" />
      <formatter type="brief" usefile="false"/>
      <test haltonfailure="no" failureproperty="test_failed" name="${test3.class}"/>
      <classpath>
        <path refid="test.classpath" />
      </classpath>
    </junit>
    <fail if="test_failed" status="${exit.code3}" message="*** Third set of Junit tests: Some Tests FAILED ***"/>
    <echo>*** Third set of Junit tests: All Tests PASSED  ***</echo-->

    <echo>Running Fourth set of Junit tests...</echo>
    <junit printsummary="yes" dir="." fork="yes" haltonfailure="no" showoutput="no" filtertrace="true" timeout="120000">
      <jvmarg value="-Djava.awt.headless=true" />
      <formatter type="brief" usefile="false"/>
      <test haltonfailure="no" failureproperty="test_failed" name="${test4.class}"/>
      <classpath>
        <path refid="test.classpath" />
        <fileset dir="${lib.dir}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </junit>
    <fail if="test_failed" status="${exit.code4}" message="*** Fourth set of Junit tests: Some Tests FAILED ***"/>
    <echo>*** Fourth set of Junit tests: All Tests PASSED  ***</echo>
    <echo>***************************************************</echo>
    <echo>*************** All Tests PASSED  *****************</echo>
  </target>


  <!-- target for cleaning -->
  <!-- target name="clean">
    <delete dir="${build.dir}" />
  </target-->
</project>