Skip to content

Commit

Permalink
IT tests were fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Mar 26, 2021
1 parent 72a8eae commit 6db3725
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1761,11 +1761,15 @@ private void initNameIdMapping() throws IOException, InterruptedException {

final Path nameIdMapHolderV1 = storagePath.resolve(NAME_ID_MAP_V1);
final Path nameIdMapHolderV2 = storagePath.resolve(NAME_ID_MAP_V2);
final Path nameIdMapHolderV3 = storagePath.resolve(NAME_ID_MAP_V3);

if (Files.exists(nameIdMapHolderV1)) {
if (Files.exists(nameIdMapHolderV2)) {
Files.delete(nameIdMapHolderV2);
}
if (Files.exists(nameIdMapHolderV3)) {
Files.delete(nameIdMapHolderV3);
}

try (final FileChannel nameIdMapHolder =
FileChannel.open(nameIdMapHolderV1, StandardOpenOption.WRITE, StandardOpenOption.READ)) {
Expand All @@ -1774,7 +1778,9 @@ private void initNameIdMapping() throws IOException, InterruptedException {

Files.delete(nameIdMapHolderV1);
} else if (Files.exists(nameIdMapHolderV2)) {
nameIdMapHolderPath = storagePath.resolve(NAME_ID_MAP_V2);
if (Files.exists(nameIdMapHolderV3)) {
Files.delete(nameIdMapHolderV3);
}

try (final FileChannel nameIdMapHolder =
FileChannel.open(nameIdMapHolderV2, StandardOpenOption.WRITE, StandardOpenOption.READ)) {
Expand All @@ -1784,7 +1790,7 @@ private void initNameIdMapping() throws IOException, InterruptedException {
Files.delete(nameIdMapHolderV2);
}

nameIdMapHolderPath = storagePath.resolve(NAME_ID_MAP_V3);
nameIdMapHolderPath = nameIdMapHolderV3;
if (Files.exists(nameIdMapHolderPath)) {
try (final FileChannel nameIdMapHolder =
FileChannel.open(
Expand Down Expand Up @@ -1903,10 +1909,16 @@ private void readNameIdMapV3(FileChannel nameIdMapHolder)
localFileCounter = absFileId;
}

nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId);
idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name);
if (absFileId != 0) {
nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId);
idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name);

idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName);
idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName);
} else {
nameIdMap.remove(nameFileIdEntry.name);
idNameMap.remove(nameFileIdEntry.fileId);
idFileNameMap.remove(nameFileIdEntry.fileId);
}
}

for (final Map.Entry<String, Integer> nameIdEntry : nameIdMap.entrySet()) {
Expand Down Expand Up @@ -1966,12 +1978,14 @@ private void readNameIdMapV2(FileChannel nameIdMapHolder)
if (absFileId != 0) {
nameIdMap.put(nameFileIdEntry.name, nameFileIdEntry.fileId);
idNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.name);

idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName);
} else {
nameIdMap.remove(nameFileIdEntry.name);
idNameMap.remove(nameFileIdEntry.fileId);

idFileNameMap.remove(nameFileIdEntry.fileId);
}

idFileNameMap.put(nameFileIdEntry.fileId, nameFileIdEntry.fileSystemName);
}

for (final Map.Entry<String, Integer> nameIdEntry : nameIdMap.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ private boolean checkPageIsBrokenAndDecrypt(
}

final int pageSize = buffer.getShort(CASWALPage.PAGE_SIZE_OFFSET);
if (pageSize == 0 || pageSize > walPageSize) {
if (pageSize <= 0 || pageSize > walPageSize) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.id.ORID;
Expand Down Expand Up @@ -170,7 +169,8 @@ public void testEncryptionSingleDatabase() {
.addConfig(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, "T1JJRU5UREJfSVNfQ09PTA==")
.build();

orientDB.create("encryption", ODatabaseType.PLOCAL, orientDBConfig);
orientDB.execute(
"create database encryption plocal users ( admin identified by 'admin' role admin)");
}
try (final OrientDB orientDB =
new OrientDB(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.orientechnologies.orient.core.db.ODatabase;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OSharedContext;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
Expand Down Expand Up @@ -53,7 +52,10 @@ public void testCheckSumFailureReadOnly() throws Exception {
.build();

orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config);
orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config);
orientDB.execute(
"create database "
+ OStorageTestIT.class.getSimpleName()
+ " plocal users ( admin identified by 'admin' role admin)");

ODatabaseSession session =
orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config);
Expand Down Expand Up @@ -114,7 +116,10 @@ public void testCheckMagicNumberReadOnly() throws Exception {
.build();

orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config);
orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config);
orientDB.execute(
"create database "
+ OStorageTestIT.class.getSimpleName()
+ " plocal users ( admin identified by 'admin' role admin)");

ODatabaseSession session =
orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config);
Expand Down Expand Up @@ -171,7 +176,10 @@ public void testCheckMagicNumberVerify() throws Exception {
.build();

orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config);
orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config);
orientDB.execute(
"create database "
+ OStorageTestIT.class.getSimpleName()
+ " plocal users ( admin identified by 'admin' role admin)");

ODatabaseSession session =
orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config);
Expand Down Expand Up @@ -230,7 +238,10 @@ public void testCheckSumFailureVerifyAndLog() throws Exception {
.build();

orientDB = new OrientDB("embedded:" + buildPath.toFile().getAbsolutePath(), config);
orientDB.create(OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, config);
orientDB.execute(
"create database "
+ OStorageTestIT.class.getSimpleName()
+ " plocal users ( admin identified by 'admin' role admin)");

ODatabaseSession session =
orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin", config);
Expand Down Expand Up @@ -287,8 +298,10 @@ public void testCreatedVersionIsStored() {
orientDB =
new OrientDB(
"embedded:" + buildPath.toFile().getAbsolutePath(), OrientDBConfig.defaultConfig());
orientDB.create(
OStorageTestIT.class.getSimpleName(), ODatabaseType.PLOCAL, OrientDBConfig.defaultConfig());
orientDB.execute(
"create database "
+ OStorageTestIT.class.getSimpleName()
+ " plocal users ( admin identified by 'admin' role admin)");

final ODatabaseSession session =
orientDB.open(OStorageTestIT.class.getSimpleName(), "admin", "admin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.metadata.schema.OType;
Expand Down Expand Up @@ -37,7 +36,8 @@ public void before() throws Exception {
.build();
orientDB = new OrientDB("plocal:" + buildDirectory, config);

orientDB.create(DB_NAME, ODatabaseType.PLOCAL, config);
orientDB.execute(
"create database " + DB_NAME + " plocal users ( admin identified by 'admin' role admin)");
final ODatabaseSession databaseDocumentTx = orientDB.open(DB_NAME, "admin", "admin", config);
storage = (OAbstractPaginatedStorage) ((ODatabaseInternal) databaseDocumentTx).getStorage();
OMurmurHash3HashFunction<Integer> murmurHash3HashFunction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
Expand Down Expand Up @@ -78,7 +77,8 @@ public void before() throws Exception {
.addConfig(OGlobalConfiguration.STORAGE_TRACK_PAGE_OPERATIONS_IN_TX, true)
.build();
orientDB = new OrientDB("plocal:" + buildDirectory, orientDBConfig);
orientDB.create(dbName, ODatabaseType.PLOCAL, orientDBConfig);
orientDB.execute(
"create database " + dbName + " plocal users ( admin identified by 'admin' role admin)");

databaseDocumentTx = orientDB.open(dbName, "admin", "admin");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
Expand Down Expand Up @@ -79,7 +78,8 @@ public void before() throws Exception {
.addConfig(OGlobalConfiguration.STORAGE_TRACK_PAGE_OPERATIONS_IN_TX, true)
.build();
orientDB = new OrientDB("plocal:" + buildDirectory, orientDBConfig);
orientDB.create(dbName, ODatabaseType.PLOCAL, orientDBConfig);
orientDB.execute(
"create database " + dbName + " plocal users ( admin identified by 'admin' role admin)");

databaseDocumentTx = orientDB.open(dbName, "admin", "admin");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.orientechnologies.common.util.ORawPair;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
Expand Down Expand Up @@ -69,7 +68,8 @@ public static void beforeClass() {
orientDB.drop(DB_NAME);
}

orientDB.create(DB_NAME, ODatabaseType.PLOCAL);
orientDB.execute(
"create database " + DB_NAME + " plocal users ( admin identified by 'admin' role admin)");

ODatabaseSession databaseSession = orientDB.open(DB_NAME, "admin", "admin");
storage = (OAbstractPaginatedStorage) ((ODatabaseInternal<?>) databaseSession).getStorage();
Expand Down

0 comments on commit 6db3725

Please sign in to comment.