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

test: Improve integration test framework #295

Merged
merged 5 commits into from
Mar 8, 2018
Merged

test: Improve integration test framework #295

merged 5 commits into from
Mar 8, 2018

Conversation

IgorPerikov
Copy link
Contributor

according to this issue #106
this pull request

  1. introduce testcontainers framework usage for all suitable tests rewrite all tests, so they use their separate etcd clusters and nodes
  2. remove old script
  3. fixed travis build command (I hope 😄 ) so It doesn't launch old script anymore
  4. fixed README section about launching tests

thirdNode.start();
endpoints = TestUtil.buildClientEndpoints(firstNode, secondNode, thirdNode);
peerUrls = TestUtil.buildPeerEndpoints(firstNode, secondNode, thirdNode);
TimeUnit.SECONDS.sleep(5);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client was saying, that cluster is unhealthy. So I gave him some time here

@fanminshi
Copy link
Member

fanminshi commented Mar 5, 2018

@IgorPerikov Thanks for the pr. I give this a thought. If we can wrap all the etcd containers creation logic into a new class called Cluster can probably a better abstraction over just launch each node by itself. I am suggestion the following interface:

/**
 * Cluster is an etcd cluster.
 */
public interface Cluster {

  // randClient randomly picks a etcd client within the cluster.
  Client randClient();

  // client gets the member client based on member idx within the cluster.
  Client client(int i);

  // terminate terminates the etcd cluster.
  void terminate();
}

Also a factory class to create it.

public class ClusterFactory {
  // newCluster returns a launched cluster with client connection
  // for each cluster member.
  public static Cluster newCluster(int size) {
    return null;
  }
}

Let me know what you think. also the above idea is based on the integration test framework from etcd. ref: https://github.com/coreos/etcd/blob/master/integration/cluster.go#L1000

cc/ @lburgazzoli

@IgorPerikov
Copy link
Contributor Author

I'm not exactly agree with Cluster interface, but it's a good idea to build another abstraction, which will handle all this infrastructure logic. I'll develop the concept and show it to you later

@IgorPerikov
Copy link
Contributor Author

@fanminshi I've pushed draft of the cluster abstraction. There might be still some small mistakes/bad namings or so, but general idea is there. More about some design decisions I've made:

  1. Since many of the tests manipulate over endpoints themselves, I decided not to hide endpoints inside cluster abstraction, I don't think that rewriting logic of tests is good goal here, but eventually it might be a good idea to hide them too
  2. As I can see there is no point in methods like randClient() and client(int idx), because we operate with whole cluster anyway
  3. Simple factory class/no fascinate builder etc: since all the tests requires either single node or 3 node cluster there is no big point in implementing extremely flexible method which can create custom size cluster, looks like overengineering for me
  4. There is some custom annotations for test frameworks which will call close() methods on marked objects, but since it's not very common libraries I decided to kept the explicit cluster.close() calls in @AfterXXX methods

@fanminshi
Copy link
Member

fanminshi commented Mar 7, 2018

I'm not exactly agree with Cluster interface
Those are copy/pasted from etcd's Cluster. It is okay that jetcd's abstraction is different. I just want us to start thinking about the new interface.

As I can see there is no point in methods like randClient() and client(int idx), because we operate with whole cluster anyway
Yeah, for now those are not useful. we don't have to include those.

@@ -221,4 +227,9 @@ public void testNestedTxn() throws Exception {
test.assertEquals(getResp2.getKvs().size(), 1);
test.assertEquals(getResp2.getKvs().get(0).getValue().toStringUtf8(), oneTwoThree.toStringUtf8());
}

@AfterTest
public void stop() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use public void tearDown() instead? that is being used in everywhere else i think.

@@ -117,4 +121,9 @@ public void testMoveLeader() throws ExecutionException, InterruptedException {
client.getMaintenanceClient().moveLeader(followers.get(0)).get();
}
}

@AfterTest
public void stopContainers() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use public void tearDown()?

@fanminshi
Copy link
Member

@IgorPerikov the new interface looks great! just some nits then lgtm. thanks for the great work!

@fanminshi
Copy link
Member

fanminshi commented Mar 7, 2018

Also after you have addressed my comments/suggestions, could you also rebase the commits? e.g
a commit for updating readme.md, a commit for update travis, a commit for adding EtcdCluster and its related stuff, a commit for updating tests using EtcdCluster, and etc. I hope you get the idea.

If you can follow the commit style guide line from here will be great: https://github.com/coreos/etcd/blob/master/CONTRIBUTING.md#format-of-the-commit-message

@fanminshi fanminshi changed the title Improve integration test framework test: Improve integration test framework Mar 7, 2018
@fanminshi
Copy link
Member

@IgorPerikov kindly ping?

@IgorPerikov
Copy link
Contributor Author

IgorPerikov commented Mar 8, 2018

@fanminshi Hi! I had a day off, and I'm gonna do the rest of the pr-related work tonight, stay tuned!

@IgorPerikov
Copy link
Contributor Author

@fanminshi done

@fanminshi fanminshi merged commit 5ceec9c into etcd-io:master Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants