Search in sources :

Example 1 with OMStorage

use of org.apache.hadoop.ozone.om.OMStorage in project ozone by apache.

the class TestSecureOzoneCluster method testSecureOmInitSuccess.

/**
 * Test functionality to get SCM signed certificate for OM.
 */
@Test
public void testSecureOmInitSuccess() throws Exception {
    LogCapturer omLogs = LogCapturer.captureLogs(OzoneManager.getLogger());
    omLogs.clearOutput();
    initSCM();
    try {
        scm = HddsTestUtils.getScmSimple(conf);
        scm.start();
        OMStorage omStore = new OMStorage(conf);
        initializeOmStorage(omStore);
        OzoneManager.setTestSecureOmFlag(true);
        om = OzoneManager.createOm(conf);
        assertNotNull(om.getCertificateClient());
        assertNotNull(om.getCertificateClient().getPublicKey());
        assertNotNull(om.getCertificateClient().getPrivateKey());
        assertNotNull(om.getCertificateClient().getCertificate());
        assertTrue(omLogs.getOutput().contains("Init response: GETCERT"));
        assertTrue(omLogs.getOutput().contains("Successfully stored " + "SCM signed certificate"));
        X509Certificate certificate = om.getCertificateClient().getCertificate();
        validateCertificate(certificate);
        String pemEncodedCACert = scm.getSecurityProtocolServer().getCACertificate();
        X509Certificate caCert = CertificateCodec.getX509Cert(pemEncodedCACert);
        X509Certificate caCertStored = om.getCertificateClient().getCertificate(caCert.getSerialNumber().toString());
        assertEquals(caCert, caCertStored);
    } finally {
        if (scm != null) {
            scm.stop();
        }
        if (om != null) {
            om.stop();
        }
        IOUtils.closeQuietly(om);
    }
}
Also used : LogCapturer(org.apache.ozone.test.GenericTestUtils.LogCapturer) OMStorage(org.apache.hadoop.ozone.om.OMStorage) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 2 with OMStorage

use of org.apache.hadoop.ozone.om.OMStorage in project ozone by apache.

the class TestSecureOzoneCluster method setupOm.

private void setupOm(OzoneConfiguration config) throws Exception {
    OMStorage omStore = new OMStorage(config);
    omStore.setClusterId("testClusterId");
    omStore.setOmCertSerialId(OM_CERT_SERIAL_ID);
    // writes the version file properties
    omStore.initialize();
    OzoneManager.setTestSecureOmFlag(true);
    om = OzoneManager.createOm(config);
}
Also used : OMStorage(org.apache.hadoop.ozone.om.OMStorage)

Example 3 with OMStorage

use of org.apache.hadoop.ozone.om.OMStorage in project ozone by apache.

the class TestSecureOzoneCluster method testSecureOmReInit.

/**
 * Tests functionality to init secure OM when it is already initialized.
 */
@Test
public void testSecureOmReInit() throws Exception {
    LogCapturer omLogs = LogCapturer.captureLogs(OzoneManager.getLogger());
    omLogs.clearOutput();
    /*
     * As all these processes run inside the same JVM, there are issues around
     * the Hadoop UGI if different processes run with different principals.
     * In this test, the OM has to contact the SCM to download certs. SCM runs
     * as scm/host@REALM, but the OM logs in as om/host@REALM, and then the test
     * fails, and the OM is unable to contact the SCM due to kerberos login
     * issues. To work around that, have the OM run as the same principal as the
     * SCM, and then the test passes.
     *
     * TODO: Need to look into this further to see if there is a better way to
     *       address this problem.
     */
    String realm = miniKdc.getRealm();
    conf.set(OZONE_OM_KERBEROS_PRINCIPAL_KEY, "scm/" + host + "@" + realm);
    omKeyTab = new File(workDir, "scm.keytab");
    conf.set(OZONE_OM_KERBEROS_KEYTAB_FILE_KEY, omKeyTab.getAbsolutePath());
    initSCM();
    try {
        scm = HddsTestUtils.getScmSimple(conf);
        scm.start();
        conf.setBoolean(OZONE_SECURITY_ENABLED_KEY, false);
        OMStorage omStore = new OMStorage(conf);
        initializeOmStorage(omStore);
        OzoneManager.setTestSecureOmFlag(true);
        om = OzoneManager.createOm(conf);
        assertNull(om.getCertificateClient());
        assertFalse(omLogs.getOutput().contains("Init response: GETCERT"));
        assertFalse(omLogs.getOutput().contains("Successfully stored " + "SCM signed certificate"));
        conf.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
        OzoneManager.omInit(conf);
        om.stop();
        om = OzoneManager.createOm(conf);
        assertNotNull(om.getCertificateClient());
        assertNotNull(om.getCertificateClient().getPublicKey());
        assertNotNull(om.getCertificateClient().getPrivateKey());
        assertNotNull(om.getCertificateClient().getCertificate());
        assertTrue(omLogs.getOutput().contains("Init response: GETCERT"));
        assertTrue(omLogs.getOutput().contains("Successfully stored " + "SCM signed certificate"));
        X509Certificate certificate = om.getCertificateClient().getCertificate();
        validateCertificate(certificate);
    } finally {
        if (scm != null) {
            scm.stop();
        }
    }
}
Also used : LogCapturer(org.apache.ozone.test.GenericTestUtils.LogCapturer) OMStorage(org.apache.hadoop.ozone.om.OMStorage) File(java.io.File) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 4 with OMStorage

use of org.apache.hadoop.ozone.om.OMStorage in project ozone by apache.

the class TestDelegationToken method setupOm.

private void setupOm(OzoneConfiguration config) throws Exception {
    OMStorage omStore = new OMStorage(config);
    omStore.setClusterId("testClusterId");
    omStore.setOmCertSerialId(OM_CERT_SERIAL_ID);
    // writes the version file properties
    omStore.initialize();
    OzoneManager.setTestSecureOmFlag(true);
    om = OzoneManager.createOm(config);
}
Also used : OMStorage(org.apache.hadoop.ozone.om.OMStorage)

Example 5 with OMStorage

use of org.apache.hadoop.ozone.om.OMStorage in project ozone by apache.

the class TestOzoneFsHAURLs method initClass.

@BeforeClass
public static void initClass() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    omId = UUID.randomUUID().toString();
    omServiceId = "om-service-test1";
    numOfOMs = 3;
    clusterId = UUID.randomUUID().toString();
    scmId = UUID.randomUUID().toString();
    final String path = GenericTestUtils.getTempPath(omId);
    java.nio.file.Path metaDirPath = java.nio.file.Paths.get(path, "om-meta");
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, metaDirPath.toString());
    conf.set(ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY, "127.0.0.1:0");
    conf.setInt(ScmConfigKeys.OZONE_DATANODE_PIPELINE_LIMIT, 3);
    conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT, BucketLayout.LEGACY.name());
    conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, true);
    OMStorage omStore = new OMStorage(conf);
    omStore.setClusterId(clusterId);
    // writes the version file properties
    omStore.initialize();
    // Start the cluster
    cluster = MiniOzoneCluster.newOMHABuilder(conf).setNumDatanodes(7).setTotalPipelineNumLimit(10).setClusterId(clusterId).setScmId(scmId).setOMServiceId(omServiceId).setNumOfOzoneManagers(numOfOMs).build();
    cluster.waitForClusterToBeReady();
    om = cluster.getOzoneManager();
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OMStorage(org.apache.hadoop.ozone.om.OMStorage) BeforeClass(org.junit.BeforeClass)

Aggregations

OMStorage (org.apache.hadoop.ozone.om.OMStorage)6 Test (org.junit.Test)3 X509Certificate (java.security.cert.X509Certificate)2 LogCapturer (org.apache.ozone.test.GenericTestUtils.LogCapturer)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Optional (java.util.Optional)1 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)1 ON_FINALIZE (org.apache.hadoop.ozone.upgrade.LayoutFeature.UpgradeActionType.ON_FINALIZE)1 UpgradeException (org.apache.hadoop.ozone.upgrade.UpgradeException)1 LAYOUT_FEATURE_FINALIZATION_FAILED (org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.LAYOUT_FEATURE_FINALIZATION_FAILED)1 UpgradeFinalizer (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer)1 ALREADY_FINALIZED (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.ALREADY_FINALIZED)1 FINALIZATION_DONE (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_DONE)1 FINALIZATION_REQUIRED (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_REQUIRED)1 STARTING_FINALIZATION (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.STARTING_FINALIZATION)1