Skip to content

Commit

Permalink
Merge pull request #2276 from rohanKanojia/pr/github-actions-minikube
Browse files Browse the repository at this point in the history
  • Loading branch information
fusesource-ci authored Jul 8, 2020
2 parents 15554e5 + 83afcbf commit 7868b41
Show file tree
Hide file tree
Showing 67 changed files with 2,958 additions and 4,626 deletions.
137 changes: 16 additions & 121 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,125 +16,6 @@

version: 2
jobs:

OPENSHIFT_3.10.0:
machine: true
steps:
- checkout
- run:
command: |
kube_version=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -LO https://storage.googleapis.com/kubernetes-release/release/${kube_version}/bin/linux/amd64/kubectl && \
chmod +x kubectl && sudo mv kubectl /usr/local/bin/
echo "Installed kubectl CLI tool"
echo "Installing nsenter"
if ! which nsenter > /dev/null; then
echo "Did not find nsenter. Installing it."
NSENTER_BUILD_DIR=$(mktemp -d /tmp/nsenter-build-XXXXXX)
pushd ${NSENTER_BUILD_DIR}
curl https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.gz | tar -zxf-
cd util-linux-2.31
./configure --without-ncurses
make nsenter
sudo cp nsenter /usr/local/bin
rm -rf "${NSENTER_BUILD_DIR}"
popd
fi
if ! which systemd-run > /dev/null; then
echo "Did not find systemd-run. Hacking it to work around Kubernetes calling it."
echo '#!/bin/bash
echo "all arguments: "$@
while [[ $# -gt 0 ]]
do
key="$1"
if [[ "${key}" != "--" ]]; then
shift
continue
fi
shift
break
done
echo "remaining args: "$@
exec $@' | sudo tee /usr/bin/systemd-run >/dev/null
sudo chmod +x /usr/bin/systemd-run
fi
oc_tool_version="openshift-origin-client-tools-v3.10.0-dd10d17-linux-64bit"
curl -LO https://github.com/openshift/origin/releases/download/v3.10.0/${oc_tool_version}.tar.gz && \
tar -xvzf ${oc_tool_version}.tar.gz && chmod +x $PWD/${oc_tool_version}/oc && sudo mv $PWD/${oc_tool_version}/oc /usr/local/bin/ && \
rm -rf ${oc_tool_version}.tar.gz
echo "Installed OC CLI tool"
tmp=`mktemp`
echo 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry 172.30.0.0/16"' > ${tmp}
sudo mv ${tmp} /etc/default/docker
sudo mount --make-shared /
sudo service docker restart
echo "Configured Docker daemon with insecure-registry"
oc cluster up
sleep 10
oc login -u system:admin
echo "Configured OpenShift cluster : v3.10.0"
- run:
command: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B install -P itests-openshift
no_output_timeout: 3600
OPENSHIFT_3.11.0:
machine: true
steps:
- checkout
- run:
command: |
kube_version=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -LO https://storage.googleapis.com/kubernetes-release/release/${kube_version}/bin/linux/amd64/kubectl && \
chmod +x kubectl && sudo mv kubectl /usr/local/bin/
echo "Installed kubectl CLI tool"
echo "Installing nsenter"
if ! which nsenter > /dev/null; then
echo "Did not find nsenter. Installing it."
NSENTER_BUILD_DIR=$(mktemp -d /tmp/nsenter-build-XXXXXX)
pushd ${NSENTER_BUILD_DIR}
curl https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.gz | tar -zxf-
cd util-linux-2.31
./configure --without-ncurses
make nsenter
sudo cp nsenter /usr/local/bin
rm -rf "${NSENTER_BUILD_DIR}"
popd
fi
if ! which systemd-run > /dev/null; then
echo "Did not find systemd-run. Hacking it to work around Kubernetes calling it."
echo '#!/bin/bash
echo "all arguments: "$@
while [[ $# -gt 0 ]]
do
key="$1"
if [[ "${key}" != "--" ]]; then
shift
continue
fi
shift
break
done
echo "remaining args: "$@
exec $@' | sudo tee /usr/bin/systemd-run >/dev/null
sudo chmod +x /usr/bin/systemd-run
fi
oc_tool_version="openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit"
curl -LO https://github.com/openshift/origin/releases/download/v3.11.0/${oc_tool_version}.tar.gz && \
tar -xvzf ${oc_tool_version}.tar.gz && chmod +x $PWD/${oc_tool_version}/oc && sudo mv $PWD/${oc_tool_version}/oc /usr/local/bin/ && \
rm -rf ${oc_tool_version}.tar.gz
echo "Installed OC CLI tool"
tmp=`mktemp`
echo 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry 172.30.0.0/16"' > ${tmp}
sudo mv ${tmp} /etc/default/docker
sudo mount --make-shared /
sudo service docker restart
echo "Configured Docker daemon with insecure-registry"
oc cluster up
sleep 10
oc login -u system:admin
echo "Configured OpenShift cluster : v3.11.0"
- run:
command: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B install -P itests-openshift
no_output_timeout: 3600
RELEASE:
machine: true
steps:
Expand All @@ -143,12 +24,26 @@ jobs:
command: |
bash ./scripts/prepare-environment.sh
bash ./scripts/release.sh
javadoc:
machine: true
steps:
- checkout
- restore_cache:
key: fabric8-kubernetes-client-{{ checksum "pom.xml" }}
- run:
command: |
# Run Maven build with javadoc jar generation
mvn clean install javadoc:jar -DskipTests -Pjavadoc-test
- save_cache:
key: fabric8-kubernetes-client-{{ checksum "pom.xml" }}
paths:
- ~/.m2

workflows:
version: 2
build_and_test:
jobs:
- OPENSHIFT_3.10.0
- OPENSHIFT_3.11.0
- javadoc
- RELEASE:
filters:
branches:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# Copyright (C) 2015 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.
#

name: E2E Tests

on:
push:
branches:
- master
pull_request:
schedule:
- cron: '0 1 * * *' # Everyday at 1

env:
IT_REVISION: master
IT_DIR: kubernetes-itests

jobs:
minikube:
name: K8S
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetes: [v1.18.3,v1.12.0]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Minikube-Kubernetes
uses: manusa/[email protected]
with:
minikube version: v1.9.2
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Install Kubernetes Client
run: mvn -f pom.xml -B -DskipTests clean install
- name: Install and Run Integration Tests
run: |
cd $IT_DIR
mvn test -Dtest="io.fabric8.kubernetes.**"
openshift:
name: OpenShift
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
openshift: [v3.11.0,v3.10.0]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup OpenShift
uses: manusa/[email protected]
with:
oc version: ${{ matrix.openshift }}
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Install Kubernetes Client
run: mvn -f pom.xml -B -DskipTests clean install
- name: Install and Run Integration Tests
run: |
cd $IT_DIR
mvn test -Dtest="io.fabric8.openshift.**"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ This client provides access to the full [Kubernetes](http://kubernetes.io/) &
[OpenShift](http://openshift.org/) REST APIs via a fluent DSL.

[![Build](https://github.com/fabric8io/kubernetes-client/workflows/Sonar%20Scanner/badge.svg)](https://github.com/fabric8io/kubernetes-client/actions)
[![Integration Tests](https://img.shields.io/circleci/project/github/fabric8io/kubernetes-client/master.svg)](https://circleci.com/gh/fabric8io/kubernetes-client)
[![CircleCI](https://img.shields.io/circleci/project/github/fabric8io/kubernetes-client/master.svg)](https://circleci.com/gh/fabric8io/kubernetes-client)
![E2E Tests](https://github.com/fabric8io/kubernetes-client/workflows/E2E%20Tests/badge.svg)
[![Release](https://img.shields.io/github/v/release/fabric8io/kubernetes-client)](https://search.maven.org/search?q=g:io.fabric8%20a:kubernetes-client)
[![Twitter](https://img.shields.io/twitter/follow/fabric8io?style=social)](https://twitter.com/fabric8io)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fabric8io_kubernetes-client&metric=bugs)](https://sonarcloud.io/dashboard?id=fabric8io_kubernetes-client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static boolean isDeploymentReady(Deployment d) {
}

return spec.getReplicas().intValue() == status.getReplicas() &&
spec.getReplicas().intValue() <= status.getAvailableReplicas();
spec.getReplicas() <= status.getAvailableReplicas();
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Copyright (C) 2015 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 io.fabric8.commons;

import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.NamespaceList;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.openshift.client.DefaultOpenShiftClient;
import io.fabric8.openshift.client.OpenShiftClient;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

public class ClusterEntity {

public static final String FRAMEWORK = "framework";
public static final String ARQUILLIAN = "arquillian";

public static void apply(InputStream inputStream) {
try (KubernetesClient client = new DefaultKubernetesClient()) {
String namespace = getArquillianNamespace();
if (namespace != null) {
client.load(inputStream).inNamespace(namespace).createOrReplace();
}
}
}

public static void remove(InputStream inputStream) {
try (KubernetesClient client = new DefaultKubernetesClient()) {
List<HasMetadata> items = client.load(inputStream).get();
client.resourceList(items).inNamespace(getArquillianNamespace()).withPropagationPolicy(DeletionPropagation.BACKGROUND).delete();
}
}

public static String getArquillianNamespace() {
try (KubernetesClient client = new DefaultKubernetesClient()) {
NamespaceList namespaceList = client.namespaces().list();
for (Namespace namespace : namespaceList.getItems()) {

// Namespace should not be in terminating state and it should have
// labels.
if (namespace.getMetadata().getDeletionTimestamp() == null) {
if (namespace.getMetadata().getLabels() != null) {
Map<String, String> labels = namespace.getMetadata().getLabels();
if (labels.containsKey(FRAMEWORK) &&
labels.get(FRAMEWORK).equals(ARQUILLIAN)) {
return namespace.getMetadata().getName();
}
}

if (namespace.getMetadata().getName().startsWith("itest-")) {
return namespace.getMetadata().getName();
}
}
}
}
return null;
}
}
Loading

0 comments on commit 7868b41

Please sign in to comment.