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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.
*/
package org.apache.ozone.test;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

import java.lang.reflect.Method;

/**
* Base class for Ozone JUnit tests.
* Provides test method name, which can be used to create unique items.
*/
public abstract class OzoneTestBase {

private TestInfo info;

@BeforeEach
void storeTestInfo(TestInfo testInfo) {
this.info = testInfo;
}

protected String getTestName() {
return info.getTestMethod()
.map(Method::getName)
.orElse("unknown");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package org.apache.hadoop.ozone.om;

import static org.apache.ozone.test.GenericTestUtils.waitFor;
import static org.mockito.Mockito.mock;

import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.HddsWhiteboxTestUtils;
Expand All @@ -28,25 +30,27 @@
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
import org.apache.hadoop.hdds.security.token.OzoneBlockTokenSecretManager;
import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer.RaftServerStatus;
import org.apache.hadoop.security.authentication.client.AuthenticationException;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
* Test utility for creating a dummy OM, the associated
* managers, and writeClient.
*/
public final class OmTestManagers {

private OzoneManagerProtocol writeClient;
private OzoneManager om;
private KeyManager keyManager;
private OMMetadataManager metadataManager;
private final OzoneManagerProtocol writeClient;
private final OzoneManager om;
private final KeyManager keyManager;
private final OMMetadataManager metadataManager;
private KeyProviderCryptoExtension kmsProvider;
private VolumeManager volumeManager;
private BucketManager bucketManager;
private PrefixManager prefixManager;
private ScmBlockLocationProtocol scmBlockClient;
private final VolumeManager volumeManager;
private final BucketManager bucketManager;
private final PrefixManager prefixManager;
private final ScmBlockLocationProtocol scmBlockClient;

public OzoneManager getOzoneManager() {
return om;
Expand Down Expand Up @@ -74,14 +78,14 @@ public ScmBlockLocationProtocol getScmBlockClient() {
}

public OmTestManagers(OzoneConfiguration conf)
throws AuthenticationException, IOException {
throws AuthenticationException, IOException, InterruptedException, TimeoutException {
this(conf, null, null);
}

public OmTestManagers(OzoneConfiguration conf,
ScmBlockLocationProtocol blockClient,
StorageContainerLocationProtocol containerClient)
throws AuthenticationException, IOException {
throws AuthenticationException, IOException, InterruptedException, TimeoutException {
if (containerClient == null) {
containerClient = mock(StorageContainerLocationProtocol.class);
}
Expand Down Expand Up @@ -109,6 +113,9 @@ public OmTestManagers(OzoneConfiguration conf,
"secretManager", mock(OzoneBlockTokenSecretManager.class));

om.start();
waitFor(() -> om.getOmRatisServer().checkLeaderStatus() == RaftServerStatus.LEADER_AND_READY,
10, 10_000);

writeClient = OzoneClientFactory.getRpcClient(conf)
.getObjectStore().getClientProxy().getOzoneManagerClient();
metadataManager = (OmMetadataManagerImpl) HddsWhiteboxTestUtils
Expand Down
Loading