Skip to content
Snippets Groups Projects
Commit c7841f96 authored by Rucha Deshpande's avatar Rucha Deshpande Committed by ethiraj krishnamanaidu
Browse files

Bug fix for the index-cleanup API and corresponding integration test

commit eb82a28c
Author: Rucha Deshpande <deshruch@amazon.com>
Date: Thu Dec 03 2020 13:57:14 GMT-0600 (Central Standard Time)

    Create legal tag for clean up integration test

commit 04c9bee4
Author: Rucha Deshpande <deshruch@amazon.com>
Date: Wed Dec 02 2020 16:15:35 GMT-0600 (Central Standard Time)

    Merge branch 'dev' into deshruch

commit 4b8d0bde
Author: Rucha Deshpande <deshruch@amazon.com>
Date: Wed Dec 02 2020 14:21:05 GMT-0600 (Central Standard Time)

    Bug Fix: index-cleanup api throws:No qualifying bean of type
IEntitlements Factory available

commit 76f47e02
Author: Rucha Deshpande <deshruch@amazon.com>
Date: Wed Dec 02 2020 16:14:52 GMT-0600 (Central Standard Time)

    Add index-cleanup integration test
parent ec76c2a0
No related branches found
No related tags found
No related merge requests found
// Copyright © Amazon Web Services
//
// 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 org.opengroup.osdu.indexer.aws.di;
import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig;
import org.opengroup.osdu.core.common.entitlements.EntitlementsFactory;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Component
@RequestScope
@Lazy
public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlementsFactory> {
@Value("${AUTHORIZE_API}")
private String AUTHORIZE_API;
@Value("${AUTHORIZE_API_KEY:}")
private String AUTHORIZE_API_KEY;
@Autowired
private HttpResponseBodyMapper mapper;
@Override
protected IEntitlementsFactory createInstance() throws Exception {
return new EntitlementsFactory(EntitlementsAPIConfig
.builder()
.rootUrl(AUTHORIZE_API)
.apiKey(AUTHORIZE_API_KEY)
.build(),
mapper);
}
@Override
public Class<?> getObjectType() {
return IEntitlementsFactory.class;
}
}
\ No newline at end of file
// Copyright © Amazon Web Services
//
// 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 org.opengroup.osdu.step_definitions.index.cleanup;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features/indexcleanup/IndexCleanup.feature",
glue = {"classpath:org.opengroup.osdu.step_definitions/index/cleanup"},
plugin = {"pretty", "junit:target/cucumber-reports/TEST-indexcleanup.xml"})
public class RunTest {
}
\ No newline at end of file
// Copyright © Amazon Web Services
//
// 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 org.opengroup.osdu.step_definitions.index.cleanup;
import cucumber.api.DataTable;
import cucumber.api.Scenario;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import lombok.extern.java.Log;
import org.opengroup.osdu.common.CleanupIndiciesSteps;
import org.opengroup.osdu.core.common.model.legal.Legal;
import org.opengroup.osdu.util.AWSHTTPClient;
import org.opengroup.osdu.util.LegalTagUtilsAws;
import org.opengroup.osdu.util.ElasticUtilsAws;
import static org.opengroup.osdu.util.Config.getOtherRelevantDataCountries;
@Log
public class Steps extends CleanupIndiciesSteps {
protected LegalTagUtilsAws legalTagUtils;
private String legalTagName;
public Steps() {
super(new AWSHTTPClient(), new ElasticUtilsAws());
}
@Before
public void before(Scenario scenario) throws Exception {
this.scenario = scenario;
this.httpClient = new AWSHTTPClient();
legalTagUtils = new LegalTagUtilsAws(this.httpClient);
this.legalTagName = this.legalTagUtils.createRandomName();
this.legalTagUtils.create(this.legalTagName);
}
@Override
public void tearDown() {
super.tearDown();
this.legalTagUtils.delete(this.legalTagName);
}
@Override
protected Legal generateLegalTag() {
Legal legal = new Legal();
Set<String> legalTags = new HashSet<>();
legalTags.add(this.legalTagName);
legal.setLegaltags(legalTags);
Set<String> otherRelevantCountries = new HashSet<>();
otherRelevantCountries.add(getOtherRelevantDataCountries());
legal.setOtherRelevantDataCountries(otherRelevantCountries);
return legal;
}
@Given("^the schema is created with the following kind$")
public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) {
super.theSchemaIsCreatedWithTheFollowingKind(dataTable);
}
@When("^I ingest records with the \"(.*?)\" with \"(.*?)\" for a given \"(.*?)\"$")
public void iIngestRecordsWithTheforAGiven(String record, String dataGroup, String kind) {
super.iIngestRecordsWithTheforAGiven(record, dataGroup, kind);
}
@Then("^I check that the index for \"(.*?)\" has been created$")
public void iCheckThatTheIndexForHasBeenCreated(String kind) throws IOException, InterruptedException {
super.iCheckThatTheIndexForHasBeenCreated(kind);
}
@Then("^I should delete the records I created earlier$")
public void iShouldDeleteTheRecordsForICreatedEarlier() {
super.iShouldDeleteTheRecordsForICreatedEarlier();
}
@Then("^I should delete the schema for \"(.*?)\" I created earlier$")
public void iShouldDeleteTheSchemaForICreatedEarlier(String kind) {
super.iShouldDeleteTheSchemaForICreatedEarlier(kind);
}
@Then("^I should check that the index for \"(.*?)\" has not been deleted$")
public void iShouldCheckThetTheIndexforHasNotBeenDeleted(String kind) throws IOException, InterruptedException {
super.iShouldCheckThetTheIndexforHasNotBeenDeleted(kind);
}
@Then("^I should to run cleanup of indexes for \"(.*?)\" and \"(.*?)\"$")
public void iShouldToRunCleanupOfIndexesForAnd(String kind, String message) {
super.iShouldToRunCleanupOfIndexesForAnd(kind, message);
}
@Then("^I should check that the index for \"(.*?)\" has been deleted$")
public void iShouldCheckThatTheIndexForHasBeenDeleted(String kind) throws IOException, InterruptedException {
super.iShouldCheckThatTheIndexForHasBeenDeleted(kind);
}
}
\ No newline at end of file
......@@ -42,6 +42,7 @@ import org.opengroup.osdu.models.Setup;
import org.opengroup.osdu.models.TestIndex;
import org.opengroup.osdu.util.FileHandler;
import org.opengroup.osdu.util.HTTPClient;
import org.opengroup.osdu.util.ElasticUtils;
@Log
public class CleanupIndiciesSteps extends TestsBase {
......@@ -55,6 +56,11 @@ public class CleanupIndiciesSteps extends TestsBase {
super(httpClient);
}
public CleanupIndiciesSteps(HTTPClient httpClient, ElasticUtils elasticUtils) {
super(httpClient, elasticUtils);
}
public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) {
List<Setup> inputList = dataTable.asList(Setup.class);
for (Setup input : inputList) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment