Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "google-cloud-testing/google-cloud-conformance-tests/conformance-tests"]
path = google-cloud-testing/google-cloud-conformance-tests/conformance-tests
url = git@github.com:googleapis/conformance-tests.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is the definition for the git-submodule which is being used to track which revision the local conformance test resources came from. You can see an example of what it looks like and how it exists in the file tree here.

52 changes: 52 additions & 0 deletions google-cloud-testing/google-cloud-conformance-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Google cloud conformance tests
This maven module is intended to function as a central location for integration with
[googleapis/conformance-tests](https://github.com/googleapis/conformance-tests).

In this directory `conformance-tests` which is a git-submodule, containing the reference for which
the various conformance test resources are updated to.

## Updating conformance-tests

#### Prerequisites

Part of the process of updating the conformance tests involves running maven a maven build for
this module. Ensure that all parent modules have been installed locally so the build can run.
```bash
pushd cd ../../
mvn -Dmaven.test.skip.exec=true install
popd
```

#### Performing the update

To update the conformance tests run the following commands from this module directory:
```bash
pushd conformance-tests
git pull
popd
./generate-conformance-tests.sh
git add .
```

If an error is encountered while generating the new resources please check the `generate.log`
written to the working directory.


## Test Suites

### Firestore

The conformance test suites for Firestore are located in the `com.google.cloud.conformance.firestore`
package.

#### Files

There are a number of files that together define the format of the tests as well as the tests
themselves.

* `src/main/java/com/google/cloud/conformance/firestore/v1/TestDefinition.java`
* The generated protobuf objects used to read the tests definitions
* `src/main/proto/google/cloud/conformance/firestore/v1/tests.proto`
* The proto definition for the tests. `TestDefinition.java` is generated from this definition.
* `src/main/resources/com/google/cloud/conformance/firestore/v1/*.json`
* Each files is a json serialized `TestFile` definition (defined in tests.proto).
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Copyright 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit -o errtrace -o nounset -o pipefail

function errNotify() {
echo "Error while generating conformance tests" >&2;
echo "See generate.log for details" >&2;
return 1
}
trap errNotify ERR

function generateFirestore() {
rm generate.log 2> /dev/null || true

local javaPackage="com/google/cloud/conformance/firestore/v1"

msg "Cleaning existing generated protos"
rm -rf src/main/java/${javaPackage}/*
msg "Cleaning existing test definitions"
rm -rf src/main/resources/${javaPackage}/*
msg "Cleaning existing proto files"
rm -rf src/main/proto/google/cloud/conformance/firestore/v1/*

msg "Copying new proto files"
cp -R -t src/main/proto/ conformance-tests/firestore/v1/proto/*
msg "Copying new test definitions"
cp -R -t "src/main/resources/${javaPackage}/" conformance-tests/firestore/v1/*.json

msg "Generating protos"
mvn -Pgen-conformance-protos clean verify > generate.log 2>&1

msg "Adding copyright header to generated sources"
## java classes generated from protoc do not include the copyright header
## prepend it to the generated files
local moduleDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd target/generated-sources/protobuf/java/${javaPackage}
for f in $(find ./ -type f -name '*.java'); do
echo "Processing $f"
mv ${f} ${f}.tmp
cat ${moduleDir}/copyright-header.txt > ${f}
cat ${f}.tmp >> ${f}
rm ${f}.tmp
done
popd

## move generated proto class(es) into the main src root
cp -R -t src/main/java/${javaPackage} target/generated-sources/protobuf/java/${javaPackage}/*

## cleanup any generated files that may have not been moved over
mvn clean > /dev/null 2>&1

msg "Building module"
## ensure building of the module still works
mvn clean package

}

function main() {
generateFirestore
}

function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}

main
Loading