Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-13434 add assertion test #8259

Merged
merged 15 commits into from
Sep 24, 2020
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.ignite.internal.ducktest.tests.smoke_test;

import com.fasterxml.jackson.databind.JsonNode;
import java.util.UUID;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
import org.apache.ignite.internal.util.typedef.internal.U;

/**
* Simple application that used in smoke tests
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
*/
public class AssertionApplication extends IgniteAwareApplication {
/** {@inheritDoc} */
@Override public void run(JsonNode jsonNode) {
assert false;
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
}
}
73 changes: 73 additions & 0 deletions modules/ducktests/tests/ignitetest/tests/assertion_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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.

"""
This module contains smoke tests that checks that services work
"""

import datetime

from ducktape.mark.resource import cluster

from ignitetest.services.ignite import IgniteService
from ignitetest.services.ignite_app import IgniteApplicationService
from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
from ignitetest.utils import ignite_versions
from ignitetest.utils.ignite_test import IgniteTest
from ignitetest.utils.version import DEV_BRANCH, IgniteVersion


# pylint: disable=W0223
class SmokeServicesTest(IgniteTest):
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
"""
Tests services implementations
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
"""

@cluster(num_nodes=2)
@ignite_versions(str(DEV_BRANCH))
def test_ignite_app_start_stop(self, ignite_version):
"""
Test to make sure Java assertions are converted to python exceptions
"""
server_configuration = IgniteConfiguration(version=IgniteVersion(ignite_version))

ignite = IgniteService(self.test_context, server_configuration, num_nodes=1)
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved

client_configuration = server_configuration._replace(client_mode=True,
discovery_spi=from_ignite_cluster(ignite))
app = IgniteApplicationService(
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
self.test_context,
client_configuration,
java_class_name="org.apache.ignite.internal.ducktest.tests.smoke_test.AssertionApplication")

ignite.start()

ts = int(round(datetime.datetime.now().timestamp() * 1000))

try:
app.start()
app.stop()
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
assert str(e) == "Java application execution failed. java.lang.AssertionError"

"""
Check the test timeout is not exceeded
"""
assert int(round(datetime.datetime.now().timestamp() * 1000)) - ts < IgniteTest.timeout()
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
else:
assert False
finally:
ignite.stop()
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions modules/ducktests/tests/ignitetest/utils/ignite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ def monotonic():
so that only the difference between the results of consecutive calls is valid.
"""
return monotonic()

@staticmethod
oleg-ostanin marked this conversation as resolved.
Show resolved Hide resolved
def timeout():
return 300000