[ https://issues.apache.org/jira/browse/FLINK-1984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15973292#comment-15973292 ]
ASF GitHub Bot commented on FLINK-1984: --------------------------------------- Github user EronWright commented on a diff in the pull request: https://github.com/apache/flink/pull/3586#discussion_r112036914 --- Diff: flink-mesos/src/test/java/org/apache/flink/mesos/runtime/clusterframework/MesosTaskManagerParametersTest.java --- @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.flink.mesos.runtime.clusterframework; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.apache.flink.configuration.Configuration; +import org.junit.Test; + +import com.netflix.fenzo.ConstraintEvaluator; +import com.netflix.fenzo.functions.Func1; +import com.netflix.fenzo.plugins.HostAttrValueConstraint; + +public class MesosTaskManagerParametersTest { + + + @Test + public void givenTwoConstraintsInConfigShouldBeParsed() throws Exception { + + MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(withConfiguration("cluster:foo,az:eu-west-1")); + assertThat(mesosTaskManagerParameters.constraints().size(), is(2)); + ConstraintEvaluator firstConstraintEvaluator = new HostAttrValueConstraint("cluster", new Func1<String, String>() { + @Override + public String call(String s) { + return "foo"; + } + }); + ConstraintEvaluator secondConstraintEvaluator = new HostAttrValueConstraint("az", new Func1<String, String>() { + @Override + public String call(String s) { + return "foo"; + } + }); + assertThat(mesosTaskManagerParameters.constraints().get(0).getName(), is(firstConstraintEvaluator.getName())); + assertThat(mesosTaskManagerParameters.constraints().get(1).getName(), is(secondConstraintEvaluator.getName())); + + } + + @Test + public void givenOneConstraintInConfigShouldBeParsed() throws Exception { + + MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(withConfiguration("cluster:foo")); + assertThat(mesosTaskManagerParameters.constraints().size(), is(1)); + ConstraintEvaluator firstConstraintEvaluator = new HostAttrValueConstraint("cluster", new Func1<String, String>() { + @Override + public String call(String s) { + return "foo"; + } + }); + assertThat(mesosTaskManagerParameters.constraints().get(0).getName(), is(firstConstraintEvaluator.getName())); + } + + @Test + public void givenEmptyConstraintInConfigShouldBeParsed() throws Exception { + + MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(withConfiguration("")); + assertThat(mesosTaskManagerParameters.constraints().size(), is(0)); + } + + @Test + public void givenInvalidConstraintInConfigShouldBeParsed() throws Exception { + + MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(withConfiguration(",:,")); + assertThat(mesosTaskManagerParameters.constraints().size(), is(0)); + } + + + private static Configuration withConfiguration(final String configuration) { --- End diff -- This method is too specific for its name, given that the class is called `MesosTaskManagerParametersTest`. Maybe it would be better to take a varargs of `Tuple2<String,String>` to make it more generic. > Integrate Flink with Apache Mesos > --------------------------------- > > Key: FLINK-1984 > URL: https://issues.apache.org/jira/browse/FLINK-1984 > Project: Flink > Issue Type: New Feature > Components: Cluster Management, Mesos > Reporter: Robert Metzger > Assignee: Eron Wright > Priority: Minor > Fix For: 1.2.0 > > Attachments: 251.patch > > > There are some users asking for an integration of Flink into Mesos. > -There also is a pending pull request for adding Mesos support for Flink-: > https://github.com/apache/flink/pull/251 > Update (May '16): a new effort is now underway, building on the recent > ResourceManager work. > Update (Oct '16): the core functionality is in the master branch. New > sub-tasks track remaining work for a first release. > Design document: ([google > doc|https://docs.google.com/document/d/1WItafBmGbjlaBbP8Of5PAFOH9GUJQxf5S4hjEuPchuU/edit?usp=sharing]) -- This message was sent by Atlassian JIRA (v6.3.15#6346)