<commit_before>/*
 * Copyright 2016 Red Hat Inc.
 *
 * 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 enmasse.smoketest;

import com.openshift.restclient.ClientBuilder;
import com.openshift.restclient.IClient;
import com.openshift.restclient.ResourceKind;
import com.openshift.restclient.model.IResource;
import com.openshift.restclient.model.IService;
import com.openshift.restclient.model.IServicePort;
import com.openshift.restclient.model.route.IRoute;

import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.List;

public class Environment {
    public static final String user = System.getenv("OPENSHIFT_USER");
    public static final String token = System.getenv("OPENSHIFT_TOKEN");
    public static final String url = System.getenv("OPENSHIFT_URL");
    public static final String namespace = System.getenv("OPENSHIFT_NAMESPACE");
    public static final IClient client = new ClientBuilder(url).usingToken(token).withUserName(user).build();
    public static final IService service = client.get(ResourceKind.SERVICE, "messaging", namespace);
    public static final Endpoint endpoint = getInsecureEndpoint();

    public static Endpoint getSecureEndpoint() throws UnknownHostException {
        return new Endpoint("127.0.0.1", 443); //getPort("amqps"));
    }

    private static Endpoint getInsecureEndpoint() {
        return new Endpoint(service.getPortalIP(), getPort("amqp"));
    }

    private static int getPort(String portName) {
        List<IServicePort> ports = service.getPorts();
        for (IServicePort port : ports) {
            if (port.getName().equals(portName)) {
                return port.getPort();
            }
        }
        throw new IllegalArgumentException("Unable to find port " + portName + " for service " + service.getName());
    }

    public static String getRouteHost() {
        IRoute route = client.get(ResourceKind.ROUTE, "messaging", namespace);
        return route.getHost();
    }
}<commit_msg>Use internal ip for now<commit_after>/*
 * Copyright 2016 Red Hat Inc.
 *
 * 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 enmasse.smoketest;

import com.openshift.restclient.ClientBuilder;
import com.openshift.restclient.IClient;
import com.openshift.restclient.ResourceKind;
import com.openshift.restclient.model.IResource;
import com.openshift.restclient.model.IService;
import com.openshift.restclient.model.IServicePort;
import com.openshift.restclient.model.route.IRoute;

import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.List;

public class Environment {
    public static final String user = System.getenv("OPENSHIFT_USER");
    public static final String token = System.getenv("OPENSHIFT_TOKEN");
    public static final String url = System.getenv("OPENSHIFT_URL");
    public static final String namespace = System.getenv("OPENSHIFT_NAMESPACE");
    public static final IClient client = new ClientBuilder(url).usingToken(token).withUserName(user).build();
    public static final IService service = client.get(ResourceKind.SERVICE, "messaging", namespace);
    public static final Endpoint endpoint = getInsecureEndpoint();

    public static Endpoint getSecureEndpoint() throws UnknownHostException {
        return new Endpoint(service.getPortalIP(), getPort("amqps")); //"127.0.0.1", 443); //getPort("amqps"));
    }

    private static Endpoint getInsecureEndpoint() {
        return new Endpoint(service.getPortalIP(), getPort("amqp"));
    }

    private static int getPort(String portName) {
        List<IServicePort> ports = service.getPorts();
        for (IServicePort port : ports) {
            if (port.getName().equals(portName)) {
                return port.getPort();
            }
        }
        throw new IllegalArgumentException("Unable to find port " + portName + " for service " + service.getName());
    }

    public static String getRouteHost() {
        IRoute route = client.get(ResourceKind.ROUTE, "messaging", namespace);
        return route.getHost();
    }
}
{'fraction_non_alphanumeric': 0.09834123222748815, 'fraction_numerical': 0.0071090047393364926, 'mean_word_length': 3.8795761078998074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7551152', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1351, 'n_words': 426}