Search in sources :

Example 1 with Rotation

use of com.yahoo.config.provision.Rotation in project vespa by vespa-engine.

the class DeployStateTest method testRotations.

@Test
public void testRotations() {
    Set<Rotation> rotations = new HashSet<>();
    assertThat(new DeployState.Builder().rotations(rotations).build(true).getRotations().size(), is(0));
    for (String name : new String[] { "rotation-001.vespa.a02.yahoodns.net", "rotation-002.vespa.a02.yahoodns.net" }) {
        rotations.add(new Rotation(name));
    }
    assertThat(new DeployState.Builder().rotations(rotations).build(true).getRotations(), equalTo(rotations));
}
Also used : Rotation(com.yahoo.config.provision.Rotation) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Rotation

use of com.yahoo.config.provision.Rotation in project vespa by vespa-engine.

the class SessionPreparerTest method require_that_rotations_are_written_in_prepare.

@Test
public void require_that_rotations_are_written_in_prepare() throws IOException {
    final String rotations = "mediasearch.msbe.global.vespa.yahooapis.com";
    final ApplicationId applicationId = applicationId("test");
    PrepareParams params = new PrepareParams.Builder().applicationId(applicationId).rotations(rotations).build();
    File app = new File("src/test/resources/deploy/app");
    preparer.prepare(getContext(getApplicationPackage(app)), getLogger(), params, Optional.empty(), tenantPath, Instant.now());
    assertThat(readRotationsFromZK(applicationId), contains(new Rotation(rotations)));
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) File(java.io.File) Rotation(com.yahoo.config.provision.Rotation) Test(org.junit.Test)

Example 3 with Rotation

use of com.yahoo.config.provision.Rotation in project vespa by vespa-engine.

the class SessionPreparerTest method require_that_rotations_are_read_from_zookeeper_and_used.

@Test
public void require_that_rotations_are_read_from_zookeeper_and_used() throws IOException {
    final Version vespaVersion = Version.fromIntValues(1, 2, 3);
    final TestModelFactory modelFactory = new TestModelFactory(vespaVersion);
    preparer = createPreparer(new ModelFactoryRegistry(Arrays.asList(modelFactory)), HostProvisionerProvider.empty());
    final String rotations = "foo.msbe.global.vespa.yahooapis.com";
    final ApplicationId applicationId = applicationId("test");
    new Rotations(curator, tenantPath).writeRotationsToZooKeeper(applicationId, Collections.singleton(new Rotation(rotations)));
    final PrepareParams params = new PrepareParams.Builder().applicationId(applicationId).build();
    final File app = new File("src/test/resources/deploy/app");
    preparer.prepare(getContext(getApplicationPackage(app)), getLogger(), params, Optional.empty(), tenantPath, Instant.now());
    // check that the rotation from zookeeper were used
    final ModelContext modelContext = modelFactory.getModelContext();
    final Set<Rotation> rotationSet = modelContext.properties().rotations();
    assertThat(rotationSet, contains(new Rotation(rotations)));
    // Check that the persisted value is still the same
    assertThat(readRotationsFromZK(applicationId), contains(new Rotation(rotations)));
}
Also used : ModelContext(com.yahoo.config.model.api.ModelContext) Version(com.yahoo.config.provision.Version) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) Rotation(com.yahoo.config.provision.Rotation) File(java.io.File) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) Test(org.junit.Test)

Example 4 with Rotation

use of com.yahoo.config.provision.Rotation in project vespa by vespa-engine.

the class PrepareParamsTest method testCorrectParsingWithRotation.

@Test
public void testCorrectParsingWithRotation() {
    PrepareParams prepareParams = createParams(request + "&" + PrepareParams.ROTATIONS_PARAM_NAME + "=" + rotation, TenantName.from("foo"));
    assertThat(prepareParams.getApplicationId().serializedForm(), is("foo:baz:default"));
    assertTrue(prepareParams.isDryRun());
    assertTrue(prepareParams.isVerbose());
    assertFalse(prepareParams.ignoreValidationErrors());
    Version expectedVersion = Version.fromString(vespaVersion);
    assertThat(prepareParams.vespaVersion().get(), is(expectedVersion));
    assertTrue(prepareParams.getTimeoutBudget().hasTimeLeft());
    Set<Rotation> rotations = prepareParams.rotations();
    assertThat(rotations.size(), is(1));
    assertThat(rotations, contains(equalTo(new Rotation(rotation))));
}
Also used : Version(com.yahoo.component.Version) Rotation(com.yahoo.config.provision.Rotation) Test(org.junit.Test)

Example 5 with Rotation

use of com.yahoo.config.provision.Rotation in project vespa by vespa-engine.

the class ModelContextImplTest method testModelContextTest.

@Test
public void testModelContextTest() {
    final Rotation rotation = new Rotation("this.is.a.mock.rotation");
    final Set<Rotation> rotations = Collections.singleton(rotation);
    ModelContext context = new ModelContextImpl(MockApplicationPackage.createEmpty(), Optional.empty(), Optional.empty(), new BaseDeployLogger(), new StaticConfigDefinitionRepo(), new MockFileRegistry(), Optional.empty(), new ModelContextImpl.Properties(ApplicationId.defaultId(), true, Collections.emptyList(), null, false, Zone.defaultZone(), rotations), Optional.empty(), new Version(6), new Version(6));
    assertTrue(context.applicationPackage() instanceof MockApplicationPackage);
    assertFalse(context.hostProvisioner().isPresent());
    assertFalse(context.permanentApplicationPackage().isPresent());
    assertFalse(context.previousModel().isPresent());
    assertTrue(context.getFileRegistry() instanceof MockFileRegistry);
    assertTrue(context.configDefinitionRepo() instanceof StaticConfigDefinitionRepo);
    assertThat(context.properties().applicationId(), is(ApplicationId.defaultId()));
    assertTrue(context.properties().configServerSpecs().isEmpty());
    assertTrue(context.properties().multitenant());
    assertTrue(context.properties().zone() instanceof Zone);
    assertFalse(context.properties().hostedVespa());
    assertThat(context.properties().rotations(), equalTo(rotations));
}
Also used : ModelContext(com.yahoo.config.model.api.ModelContext) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Version(com.yahoo.component.Version) Zone(com.yahoo.config.provision.Zone) ModelContextImpl(com.yahoo.vespa.config.server.deploy.ModelContextImpl) Rotation(com.yahoo.config.provision.Rotation) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) Test(org.junit.Test)

Aggregations

Rotation (com.yahoo.config.provision.Rotation)5 Test (org.junit.Test)5 Version (com.yahoo.component.Version)2 ModelContext (com.yahoo.config.model.api.ModelContext)2 ApplicationId (com.yahoo.config.provision.ApplicationId)2 File (java.io.File)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)1 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)1 Version (com.yahoo.config.provision.Version)1 Zone (com.yahoo.config.provision.Zone)1 ModelContextImpl (com.yahoo.vespa.config.server.deploy.ModelContextImpl)1 TestModelFactory (com.yahoo.vespa.config.server.model.TestModelFactory)1 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)1 Rotations (com.yahoo.vespa.config.server.tenant.Rotations)1 HashSet (java.util.HashSet)1