manuzhang commented on code in PR #2761: URL: https://github.com/apache/datafusion-comet/pull/2761#discussion_r2527891739
########## docs/source/contributor-guide/fuzz-testing.md: ########## @@ -0,0 +1,268 @@ +<!--- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +--> + +# Fuzz Testing + +## Overview + +Comet Fuzz is a standalone property-based testing framework located in the `fuzz-testing/` directory. It helps ensure compatibility between Comet and Apache Spark by automatically generating random data and queries, then executing them against both Spark (with Comet disabled) and Comet (with Comet enabled) to detect discrepancies. + +The framework has proven valuable in discovering numerous bugs and edge cases that might not be caught by traditional unit or integration tests. + +## Inspiration + +Comet Fuzz is inspired by the [SparkFuzz](https://ir.cwi.nl/pub/30222) paper from Databricks and CWI, which demonstrates the effectiveness of property-based testing for finding bugs in query engines. + +## Architecture + +The fuzz testing framework consists of several key components: + +### Core Components + +- **`Meta.scala`**: Defines metadata about supported data types, expressions, and operators +- **`QueryGen.scala`**: Generates random SQL queries based on available test data +- **`QueryRunner.scala`**: Executes queries against Spark with Comet disabled and enabled, comparing results +- **`Utils.scala`**: Utility functions for data generation and comparison +- **`Main.scala`**: Entry point with CLI for different fuzz testing modes +- **`ComparisonTool.scala`**: Standalone tool for comparing existing datasets + +### Testing Workflow + +1. **Data Generation**: Create random Parquet files with various data types +2. **Query Generation**: Generate random SQL queries that operate on the test data +3. **Execution**: Run queries twice - once with Comet disabled (Spark baseline) and once with Comet enabled +4. **Comparison**: Compare results and report any discrepancies + +## Getting Started + +### Prerequisites + +Before running fuzz tests, ensure you have: + +- Comet built and installed: `mvn install -DskipTests` from the project root Review Comment: I have to run make command to build native modules as well. Otherwise, I'm running to native lib not found issue at runtime. ########## docs/source/contributor-guide/fuzz-testing.md: ########## @@ -0,0 +1,268 @@ +<!--- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +--> + +# Fuzz Testing + +## Overview + +Comet Fuzz is a standalone property-based testing framework located in the `fuzz-testing/` directory. It helps ensure compatibility between Comet and Apache Spark by automatically generating random data and queries, then executing them against both Spark (with Comet disabled) and Comet (with Comet enabled) to detect discrepancies. + +The framework has proven valuable in discovering numerous bugs and edge cases that might not be caught by traditional unit or integration tests. + +## Inspiration + +Comet Fuzz is inspired by the [SparkFuzz](https://ir.cwi.nl/pub/30222) paper from Databricks and CWI, which demonstrates the effectiveness of property-based testing for finding bugs in query engines. + +## Architecture + +The fuzz testing framework consists of several key components: + +### Core Components + +- **`Meta.scala`**: Defines metadata about supported data types, expressions, and operators +- **`QueryGen.scala`**: Generates random SQL queries based on available test data +- **`QueryRunner.scala`**: Executes queries against Spark with Comet disabled and enabled, comparing results +- **`Utils.scala`**: Utility functions for data generation and comparison +- **`Main.scala`**: Entry point with CLI for different fuzz testing modes +- **`ComparisonTool.scala`**: Standalone tool for comparing existing datasets + +### Testing Workflow + +1. **Data Generation**: Create random Parquet files with various data types +2. **Query Generation**: Generate random SQL queries that operate on the test data +3. **Execution**: Run queries twice - once with Comet disabled (Spark baseline) and once with Comet enabled +4. **Comparison**: Compare results and report any discrepancies + +## Getting Started + +### Prerequisites + +Before running fuzz tests, ensure you have: + +- Comet built and installed: `mvn install -DskipTests` from the project root Review Comment: I have to run make command to build native modules as well. Otherwise, I'm running into native lib not found issue at runtime. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
