Skip to content

Commit

Permalink
fix(mongo): add missing indexes
Browse files Browse the repository at this point in the history
With the upgrade of the gravitee-bom, some Mongo Repositories tests were
failing. After a bit of investigation, all failing tests were missing
indexes.
I don't really understand what dependencies make this required...
  • Loading branch information
jgiovaresco committed Mar 1, 2024
1 parent 85a6470 commit 9576f51
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 0 deletions.
@@ -0,0 +1,37 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.accesspoints;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("AccessPointsHostIndexUpgrader")
public class HostIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("access_points")
.name("h1")
.key("host", ascending())
.build();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.accesspoints;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("AccessPointsReferenceIdReferenceTypeIndexUpgrader")
public class ReferenceIdReferenceTypeIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("access_points")
.name("rt_ri1")
.key("referenceType", ascending())
.key("referenceId", ascending())
.build();
}
}
@@ -0,0 +1,39 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.accesspoints;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("AccessPointsReferenceIdReferenceTypeTargetIndexUpgrader")
public class ReferenceIdReferenceTypeTargetIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("access_points")
.name("ri_rt_t1")
.key("referenceId", ascending())
.key("referenceType", ascending())
.key("target", ascending())
.build();
}
}
@@ -0,0 +1,37 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.accesspoints;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("AccessPointsTargetIndexUpgrader")
public class TargetIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("access_points")
.name("t1")
.key("target", ascending())
.build();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.licenses;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("LicensesIdReferenceIdReferenceTypeIndexUpgrader")
public class IdReferenceIdReferenceTypeIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("licenses")
.name("id_rt_ri1")
.key("_id.referenceType", ascending())
.key("_id.referenceId", ascending())
.build();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.licenses;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("LicensesReferenceIdReferenceTypeIndexUpgrader")
public class ReferenceIdReferenceTypeIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("licenses")
.name("rt_ri1")
.key("referenceType", ascending())
.key("referenceId", ascending())
.build();
}
}
@@ -0,0 +1,37 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.licenses;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("LicensesUpdatedAtIndexUpgrader")
public class UpdatedAtIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("licenses")
.name("f_t1")
.key("updatedAt", ascending())
.build();
}
}
@@ -0,0 +1,37 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.organizations;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("OrganizationsCockpitIdIndexUpgrader")
public class CockpitIdIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("organizations")
.name("cid1")
.key("cockpitId", ascending())
.build();
}
}
@@ -0,0 +1,37 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.pages;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("PagesParentIdIndexUpgrader")
public class ParentIdIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("pages")
.name("pid1")
.key("parentId", ascending())
.build();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.repository.mongodb.management.upgrade.upgrader.index.qualityrules;

import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.Index;
import io.gravitee.repository.mongodb.management.upgrade.upgrader.index.IndexUpgrader;
import org.springframework.stereotype.Component;

/**
* @author GraviteeSource Team
*/
@Component("QualityRulesReferenceIdReferenceTypeIndexUpgrader")
public class ReferenceIdReferenceTypeIndexUpgrader extends IndexUpgrader {

@Override
protected Index buildIndex() {
return Index
.builder()
.collection("qualityrules")
.name("ri1rt1")
.key("referenceId", ascending())
.key("referenceType", ascending())
.build();
}
}

0 comments on commit 9576f51

Please sign in to comment.