-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[env]Introduce flink-env test suite (#17)
* [env]Introduce flink-env test suite
- Loading branch information
Showing
23 changed files
with
2,030 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "env/flink/env_flink_test_suite.h" | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
|
||
#define ASSERT_TRUE(expression) \ | ||
if (!(expression)) { \ | ||
std::cerr << "Assertion failed: " << #expression << ", file " << __FILE__ \ | ||
<< ", line " << __LINE__ << "." << std::endl; \ | ||
std::abort(); \ | ||
} | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
EnvFlinkTestSuites::EnvFlinkTestSuites(const std::string& basePath) | ||
: base_path_(basePath) {} | ||
|
||
void EnvFlinkTestSuites::runAllTestSuites() { | ||
setUp(); | ||
testFileExist(); | ||
} | ||
|
||
void EnvFlinkTestSuites::setUp() { | ||
auto status = ROCKSDB_NAMESPACE::NewFlinkEnv(base_path_, &flink_env_); | ||
if (!status.ok()) { | ||
throw std::runtime_error("New FlinkEnv failed"); | ||
} | ||
} | ||
|
||
void EnvFlinkTestSuites::testFileExist() { | ||
std::string fileName("test-file"); | ||
Status result = flink_env_->FileExists(fileName); | ||
ASSERT_TRUE(result.IsNotFound()); | ||
|
||
// Generate a file manually | ||
const std::string prefix = "file:"; | ||
std::string writeFileName = base_path_ + fileName; | ||
if (writeFileName.compare(0, prefix.size(), prefix) == 0) { | ||
writeFileName = writeFileName.substr(prefix.size()); | ||
} | ||
std::ofstream writeFile(writeFileName); | ||
writeFile << "testFileExist"; | ||
writeFile.close(); | ||
|
||
result = flink_env_->FileExists(fileName); | ||
ASSERT_TRUE(result.ok()); | ||
} | ||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "env_flink.h" | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
class EnvFlinkTestSuites { | ||
public: | ||
EnvFlinkTestSuites(const std::string& basePath); | ||
void runAllTestSuites(); | ||
|
||
private: | ||
std::unique_ptr<ROCKSDB_NAMESPACE::Env> flink_env_; | ||
const std::string base_path_; | ||
void setUp(); | ||
void testFileExist(); | ||
}; | ||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
java/flinktestmock/src/main/java/org/apache/flink/core/fs/FileStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* This file is based on source code from the Hadoop Project (http://hadoop.apache.org/), licensed | ||
* by the Apache Software Foundation (ASF) under the Apache License, Version 2.0. See the NOTICE | ||
* file distributed with this work for additional information regarding copyright ownership. | ||
*/ | ||
|
||
package org.apache.flink.core.fs; | ||
|
||
/** | ||
* Interface that represents the client side information for a file independent of the file system. | ||
*/ | ||
public interface FileStatus { | ||
/** | ||
* Return the length of this file. | ||
* | ||
* @return the length of this file | ||
*/ | ||
long getLen(); | ||
|
||
/** | ||
* Get the block size of the file. | ||
* | ||
* @return the number of bytes | ||
*/ | ||
long getBlockSize(); | ||
|
||
/** | ||
* Get the replication factor of a file. | ||
* | ||
* @return the replication factor of a file. | ||
*/ | ||
short getReplication(); | ||
|
||
/** | ||
* Get the modification time of the file. | ||
* | ||
* @return the modification time of file in milliseconds since January 1, 1970 UTC. | ||
*/ | ||
long getModificationTime(); | ||
|
||
/** | ||
* Get the access time of the file. | ||
* | ||
* @return the access time of file in milliseconds since January 1, 1970 UTC. | ||
*/ | ||
long getAccessTime(); | ||
|
||
/** | ||
* Checks if this object represents a directory. | ||
* | ||
* @return <code>true</code> if this is a directory, <code>false</code> otherwise | ||
*/ | ||
boolean isDir(); | ||
|
||
/** | ||
* Returns the corresponding Path to the FileStatus. | ||
* | ||
* @return the corresponding Path to the FileStatus | ||
*/ | ||
Path getPath(); | ||
} |
Oops, something went wrong.