[08:59] welcome to day 1 post-Quino [08:59] Quino ? [09:03] bthomas: https://en.wikipedia.org/wiki/Quino [09:08] bthomas: https://i.imgur.com/wDlx65Z.jpg [09:09] thanks [09:10] bthomas: or maybe https://i.imgur.com/MvUSF2A.jpg [09:11] nice and deep [09:11] his best ones were like that imho [09:11] although not all, eg https://pbs.twimg.com/media/C-WT7p-W0AAs8tl?format=jpg&name=medium [09:12] (there is social commentary in there, but it's not the joke) [09:13] :) I like dilbert a lot [09:13] BTW there is a comic book mode for emacs [09:13] of course there is :) [09:13] of COURSE there is :-p [09:13] hehe [09:35] Chipaca: thx for the heads-up, yesterday re: charm-gitlab-k8s use of "self" as self.on_database_lost. I think I now have a clear idea on how to work with relations and events (+custom events) [09:36] now, I'm trying to create a simple test https://pastebin.ubuntu.com/p/5Dm35vNVxk/ [09:36] aluria: FWIW, if you're not creating an interface, custom events should not be on your radar at all [09:36] but I get "AttributeError: 'Unit' object has no attribute 'framework'" because of the use of self.model.unit as "charm" attribute [09:37] Chipaca: yep, understood re: custom events (and I'm creating a interface-vpn one to be used on 2 different charms (one using the requires side, and the other one the provides one) [09:37] nice [09:38] the previous pastebin also should have a method on the VPNProvides class that uses self.model -> https://pastebin.ubuntu.com/p/f9Byk5SFRB/ [09:39] how should I mock the "self.model" from the VPNProvides class using the harness capabilities? [09:39] aluria: er [09:39] I know VPNProvides.model = self.harness.model can't be done because it is immutable [09:40] aluria: you're doing VPNProvides(self.model.unit, 'vpn') [09:40] aluria: but VPNPRovides' first argument is called 'charm' [09:40] not 'unit' [09:41] aluria: and it looks like it should be a charm, indeed, not a unit :) [09:41] aluria: so you want harness.charm [09:41] which will only be not-None after you've done harness.begin [09:44] Chipaca: ah, cheers - I also see an example here -> https://github.com/openstack-charmers/ops-openstack/blob/ea51b43ec2a714aab3202d071d50a98cb7a4522d/unit_tests/test_ops_openstack.py#L77 [09:44] ty [14:07] Chipaca: can an interface class inherit from CharmBase instead of Object? [14:09] something like ClassName(self.harness.charm, relation_name) <-- works, but ops.testing.Harness(ClassName) fails because: ops/testing.py", line 136, in begin -> self._charm = TestCharm(self._framework) -> TypeError: __init__() missing 1 required positional argument: 'relation_name' [14:10] aluria: i don't think you want your interface to be a charm, no [14:10] aluria: but, in your tests, you can create a charm that uses the interface [14:10] nop [14:10] aaah, ok [14:11] I'll try that, ty [14:40] Chipaca: that worked for general methods of the interface class, ty - last Q of the day is that I have an on_relation_joined(self, event) method which has -> event.relation.data[self.model.unit]["ip"] = value <-- and I want to check if the value has correctly been shared [14:40] in the setUp method, I've done -> self.relation_id_vpn = self.harness.add_relation("vpn", "vpn-client"); self.harness.begin() [14:40] and on the test case, I've done -> self.harness.add_relation_unit(self.relation_id_vpn, "vpn-client/0") [14:41] however, rel_data = self.harness.get_relation_data(self.relation_id_vpn, "vpn-client/0") <-- returns an empty dict [14:46] aluria: shouldn't that be vpn/0? [14:47] vpn is the interface name, and vpn-client is the appname (hence, vpn-client/0 for the unit name) [14:47] aluria: but what's the name of the other side of the relation? [14:48] it's that data that you're setting, aiui [14:49] ok, so I was trying to test the VPNProvides class, and the later do the same for a VPNRequires class... for the on_relation_joined part, should I test both classes together? [14:49] *then [14:49] you lost me :) [14:50] aluria: in that test, what is self.harness.unit.name ? [14:51] self.assertEqual(self.harness.unit.name, "asdf") -> AttributeError: 'Harness' object has no attribute 'unit' [14:52] aluria: self.harness.model.unit sorry [14:52] ...name [14:53] myapp/0 <-- b/c in the Harness call, I set up a meta value where "name: myapp" [14:53] aluria: and what's in self.harness.get_relation_data(self.relation_id_vpn, self.harness.model.unit.name) ? [14:53] yeah, I just tested that and it returns what it should [14:53] :) [14:54] I was not understanding which unit name or app name to use [14:54] yeah, it takes some mind-melding [14:54] I thought the ones in self.harness.add_relation and add_relation_unit were used [14:54] i still need to think really slowly through it [14:54] (in my defense, i'm new to juju) [14:55] thx Chipaca - I think I have minimum tests running for the VPNProvides interface - I'll work on the requires part but don't expect to interrupt you (at least, today :) [14:55] i might ignore you preƫmptively [14:55] (got meetings coming up) [14:56] which reminds me, bthomas, justinclark, [dylan], you're going to be all lonesome during standup (conflicting meeting) [14:56] * bthomas is already feeling lonesome [14:56] :( [15:13] I have a couple questions about relation related hooks in operator [15:15] for the event argument of relation_changed, what is event.unit? Is it a unit from the application you are related to? [15:15] If so, why do I always see people checking if event.unit is None? What would be the case where this is true? [15:19] dstathis yes, event.unit is the unit from the application you're related to. My understanding is that this can be None if the relation is broken and the remote unit is no longer available [15:20] I actually found "The remote unit that has triggered this event. This may be None if the relation event was triggered as an Application level event" [15:21] Interesting. Now I'm curious if a broken relation would also lead to event.unit being None or I was misunderstanding the use for that.