Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ORC encryption tests [databricks] #5737

Merged
merged 4 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
27 changes: 0 additions & 27 deletions integration_tests/src/main/python/orc_write_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,30 +167,3 @@ def create_empty_df(spark, path):
lambda spark, path: spark.read.orc(path),
data_path,
conf={'spark.rapids.sql.format.orc.write.enabled': True})

@allow_non_gpu('DataWritingCommandExec')
@pytest.mark.parametrize("path", ["", "kms://http@localhost:9600/kms"])
@pytest.mark.parametrize("provider", ["", "hadoop"])
@pytest.mark.parametrize("encrypt", ["", "pii:a"])
@pytest.mark.parametrize("mask", ["", "sha256:a"])
@pytest.mark.skipif(is_databricks104_or_later(), reason="The test will fail on Databricks10.4 because `HadoopShimsPre2_3$NullKeyProvider` is loaded")
def test_orc_write_encryption_fallback(spark_tmp_path, spark_tmp_table_factory, path, provider, encrypt, mask):
def write_func(spark, write_path):
writer = unary_op_df(spark, gen).coalesce(1).write
if path != "":
writer.option("hadoop.security.key.provider.path", path)
if provider != "":
writer.option("orc.key.provider", provider)
if encrypt != "":
writer.option("orc.encrypt", encrypt)
if mask != "":
writer.option("orc.mask", mask)
writer.format("orc").mode('overwrite').option("path", write_path).saveAsTable(spark_tmp_table_factory.get())
if path == "" and provider == "" and encrypt == "" and mask == "":
pytest.skip("Skip this test when none of the encryption confs are set")
gen = IntegerGen()
data_path = spark_tmp_path + '/ORC_DATA'
assert_gpu_fallback_write(write_func,
lambda spark, path: spark.read.orc(path),
data_path,
'DataWritingCommandExec')
76 changes: 76 additions & 0 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-321cdh-test-src</id>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>${project.basedir}/src/test/320+/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!--
Expand Down Expand Up @@ -273,6 +292,62 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>release321</id>
<activation>
<property>
<name>buildver</name>
<value>321</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-321-test-src</id>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>${project.basedir}/src/test/320+/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release322</id>
<activation>
<property>
<name>buildver</name>
<value>322</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-322-test-src</id>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>${project.basedir}/src/test/320+/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release330</id>
<activation>
Expand All @@ -293,6 +368,7 @@
<configuration>
<sources>
<source>${project.basedir}/src/test/330/scala</source>
<source>${project.basedir}/src/test/320+/scala</source>
</sources>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* 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.
*/

package com.nvidia.spark.rapids

import java.io.File
import java.util.Random

import com.nvidia.spark.rapids.shims.SparkShimImpl
import org.apache.orc.impl.HadoopShimsFactory

import org.apache.spark.SparkConf

class OrcEncryptionSuite extends SparkQueryCompareTestSuite {
testGpuFallback(
"Write encrypted ORC fallback",
"DataWritingCommandExec",
intsDf,
conf = new SparkConf().set("hadoop.security.key.provider.path", "test:///")
.set("orc.key.provider", "hadoop")
.set("orc.encrypt", "pii:ints,more_ints")
.set("orc.mask", "sha256:ints,more_ints")) {
frame =>
// ORC encryption is only allowed in 3.2+
val isValidTestForSparkVersion = SparkShimImpl.getSparkShimVersion match {
case SparkShimVersion(major, minor, _) => major == 3 && minor != 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't need these checks if this is in a 320+ directory right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we don't. I am being defensive here in case someone moves things around. If this is an issue, I can remove them

case DatabricksShimVersion(major, minor, _, _) => major == 3 && minor != 1
case ClouderaShimVersion(major, minor, _, _) => major == 3 && minor != 1
case _ => true
}
assume(isValidTestForSparkVersion)

withCpuSparkSession(session => {
val conf = session.sessionState.newHadoopConf()
val provider = HadoopShimsFactory.get.getHadoopKeyProvider(conf, new Random)
assume(!provider.getKeyNames.isEmpty,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't testing anything the way its written, we need a different way to test

s"$provider doesn't has the test keys. ORC shim is created with old Hadoop libraries")
}
)

val tempFile = File.createTempFile("orc-encryption-test", "")
frame.write.mode("overwrite").orc(tempFile.getAbsolutePath)
frame.selectExpr("*")
}
}